Last active
February 21, 2024 09:33
-
-
Save omerap12/1e7fb8bdc14b8fa3af2cab737c917d37 to your computer and use it in GitHub Desktop.
Remove AWS IAM Role
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
role_name=$1 | |
aws iam list-instance-profiles-for-role --role-name $role_name | jq -r '.InstanceProfiles[].InstanceProfileName' | xargs -I {} aws iam remove-role-from-instance-profile --instance-profile-name {} --role-name $role_name | |
aws iam list-role-policies --role-name $role_name | jq -r '.PolicyNames[]' | xargs -I {} aws iam delete-role-policy --role-name $role_name --policy-name {} | |
aws iam list-attached-role-policies --role-name $role_name | jq -r '.AttachedPolicies[].PolicyArn' | xargs -I {} aws iam detach-role-policy --role-name $role_name --policy-arn {} | |
aws iam delete-role --role-name $role_name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment