Skip to content

Instantly share code, notes, and snippets.

@dgwhited
Created June 3, 2020 01:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dgwhited/64118a7c48fd0aaa33627e68bcef61ca to your computer and use it in GitHub Desktop.
Save dgwhited/64118a7c48fd0aaa33627e68bcef61ca to your computer and use it in GitHub Desktop.
import boto3
profile_name = 'dev'
role_name = 'test-role'
session = boto3.Session(profile_name=profile_name)
iam = session.client('iam')
def get_policies_for_role(rolename):
all_policies = {}
# two possible types of policies - inline and managed
inline_policies = iam.list_role_policies(RoleName=rolename)['PolicyNames']
attached_policies = iam.list_attached_role_policies(RoleName=rolename)['AttachedPolicies']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment