iam
AWS IAM CLI Cheatsheet for managing AWS IAM policies. View policy ARN, detach role policy, and delete roles using AWS CLI commands.
AWS IAM CLI Cheatsheet
AWS IAM CLI Commands
View Policy ARN:
$ aws --profile dev iam list-attached-user-policies --user my-policy | jq -r '.AttachedPolicies[].PolicyArn'
arn:aws:iam::000000000000:policy/my-policy
Detach Role Policy and Delete Role
export iam_profile=dev
export role_name=MyRole
export role_arn=arn:aws:iam::aws:policy/ReadOnlyAccessX
aws --profile ${iam_profile} iam detach-role-policy --role-name ${role_name} --policy-arn ${role_arn}
aws --profile ${iam_profile} iam delete-role --role-name ${role_name}
This AWS IAM CLI Cheatsheet provides essential commands for managing AWS Identity and Access Management (IAM) policies and roles. Use these commands to view policy ARNs, detach role policies, and delete roles efficiently. Ensure you have the AWS CLI configured with the appropriate profile before executing these commands. For more information, refer to the AWS IAM CLI documentation.