Search code examples
amazon-web-servicesamazon-iam

AWS IAM find a role that has a specific policy?


Kind of a newbie still with AWS IAM. Is there a way to find all of the available Roles in a given account that have a specific Policy attached? i.e. if you only know the Policy, and you don't know the roles it's attached to, how do you find all of the roles that a given policy is attached?


Solution

  • If you're using API/CLI, you can make use of the ListEntitiesForPolicy call. A CLI command that you could run would be:

    $ aws iam list-entities-for-policy --policy-arn <arn_of_policy> --entity-filter Role