AWS CLI Delete Multiple IAM Roles

0

HI Everyone,

Below is the AWS CLI command to delete an IAM role.

aws iam delete-role --role-name Test-Role

I need to delete multiple IAM roles using AWS CLI. Is there any AWS CLI command I can use to delete multiple roles at once?

1 個回答
1
已接受的答案

Hey @tausif no there isn't a means to do this natively with AWS CLI.

However dependent on which OS you are running you can run a quick powershell script or linux bash script to perform the same.

Example for bash could start off with gathering those roles that you list all cleaned up by performing something like this aws iam list-roles | jq -r '.Roles[] | "\(.RoleName)"'

jq is an additional package I use for dealing with json outputs.

Let me know if you have any issues with this, or if it helps you then please accept my answer after you've tried it out - it would be much appreciated! Good luck :)

profile picture
D G
已回答 1 年前
profile picture
專家
已審閱 1 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南