Skip to content

Instantly share code, notes, and snippets.

@relotnek
Created October 10, 2018 23:01
Show Gist options
  • Save relotnek/073569144ab5a7c4bde75a65c5283e8a to your computer and use it in GitHub Desktop.
Save relotnek/073569144ab5a7c4bde75a65c5283e8a to your computer and use it in GitHub Desktop.
Quick script to enumerate assumable roles in an AWS Account
import boto3
client = boto3.client('iam', region_name="us-east-1")
response = client.list_roles()
roles = response.get("Roles")
for role in roles:
if "AWS" in role["AssumeRolePolicyDocument"]["Statement"][0]["Principal"]:
print(role["RoleId"] + " " + role["RoleName"])
print(role["AssumeRolePolicyDocument"]["Statement"][0]["Principal"]["AWS"])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment