Is there a way to delete a number of AWS IAM customer managed policies in one shot using CLI or GUI?

413 views Asked by At

I am trying to delete all of my customer managed policies but I am not able to figure out a way to delete all of them in one click or using only one command

1

There are 1 answers

0
jellycsc On BEST ANSWER
#!/bin/sh

customer_managed_policy_arns=`aws iam list-policies --scope Local --query 'Policies[*].Arn' --output text`
for arn in $customer_managed_policy_arns; do
    echo aws iam delete-policy --policy-arn "$arn"
done

Make sure you delete echo after you confirm all the commands you are expecting it to run.