0
0

アクセスキーリストを作成する

Posted at

CloudShellに アクセスキーを持っているユーザ一覧をリストアップする。

IAMユーザーのリストを取得

users=$(aws iam list-users --query "Users[].UserName" --output text)

各ユーザーについてアクセスキーの有無を確認

for user in $users; do    
    # アクセスキーのリストを取得
    keys=$(aws iam list-access-keys --user-name $user --query "AccessKeyMetadata[].AccessKeyId" --output text)
    # アクセスキーが存在する場合、ユーザー名を出力
    if [[ ! -z $keys ]]; then
        echo $user
    fi
done
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0