29 lines
1.1 KiB
Bash
Executable File
29 lines
1.1 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
function formatprint() {
|
|
cat - > /tmp/formatprint.tmp
|
|
echo "# $1 ($(cat /tmp/formatprint.tmp | wc -l))"
|
|
cat /tmp/formatprint.tmp | sed -e 's/^/ /g'
|
|
rm -f /tmp/formatprint.tmp
|
|
}
|
|
|
|
# Generate inventory of ec2, rds, lb, and s3 buckets.
|
|
|
|
# aws eks list-clusters | jq '.[][]' | awk -F/ '{print $NF}' | formatprint EKS
|
|
|
|
# IAM roles"
|
|
# aws iam list-roles | jq -cr '.Roles[] | .RoleName' | grep -v AWSServiceRoleFor
|
|
|
|
# IAM users
|
|
aws iam list-users | jq -cr '.Users[] | .UserName' | while read u; do
|
|
echo "User: $u"
|
|
aws iam list-attached-user-policies --user-name $u | jq -cr '.AttachedPolicies[] | .PolicyArn' | formatprint UserManagedPolicies
|
|
aws iam list-user-policies --user-name $u | jq -cr '.PolicyNames[]' | formatprint UserInlinePolicies
|
|
aws iam list-groups-for-user --user-name $u | jq -cr '.Groups[] | .GroupName' | while read g; do
|
|
echo "Groups: $g"
|
|
aws iam list-attached-group-policies --group-name $g | jq -cr '.AttachedPolicies[] | .PolicyArn' | formatprint GroupManagedPolicies
|
|
aws iam list-group-policies --group-name $g | jq -cr '.PolicyNames[]' | formatprint GroupInlinePolicies
|
|
done
|
|
echo ""
|
|
done
|