LoginSignup
2
1

More than 5 years have passed since last update.

aws cli で iam の group に紐づく user, policy を見る

Last updated at Posted at 2015-04-03

#!/bin/bash

aws iam list-groups | jq '.Groups[].GroupName' | xargs -I{} echo {} | \
    while read g
    do
        echo ${g} "-------------------------------------------------------------";
        aws iam get-group --group-name ${g} | jq '(.Group | {GroupName, Arn}), (.Users[] | {UserName, Arn})'
        aws iam list-group-policies --group-name ${g} | jq '.PolicyNames[]' | xargs -I{} echo {} | \
            while read p
            do
                aws iam get-group-policy --group-name ${g} --policy-name ${p}
            done
    one

bash の while が ruby の

a = [1, 2, 3]
a.each do |n|
    echo p
end

のように使えるとわかったので良かった。
あと jq 楽しいよ jq。

2
1
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
2
1