Skip to content

Instantly share code, notes, and snippets.

@CodySwannGT
Created May 3, 2019 01:26
Show Gist options
  • Save CodySwannGT/99ba6e63b89a68ad1b8e4f4a5d527dfa to your computer and use it in GitHub Desktop.
Save CodySwannGT/99ba6e63b89a68ad1b8e4f4a5d527dfa to your computer and use it in GitHub Desktop.
Delete unattached customer managed AWS policies
while :; echo $(aws iam list-policies --no-only-attached --scope Local --output text --query 'Policies[?AttachmentCount==`0`]|[0:1].Arn'); do aws iam delete-policy --policy-arn $(aws iam list-policies --no-only-attached --scope Local --output text --query 'Policies[?AttachmentCount==`0`]|[0:1].Arn') || true; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment