Skip to content

Instantly share code, notes, and snippets.

@phwelo
Created August 11, 2022 14:42
Show Gist options
  • Save phwelo/448f1df0a2725d21f3b4364ad1c694fc to your computer and use it in GitHub Desktop.
Save phwelo/448f1df0a2725d21f3b4364ad1c694fc to your computer and use it in GitHub Desktop.
List any inline IAM policies
#!/usr/bin/env python3
import boto3
client = boto3.client('iam')
# three different calls to get inline-policy on all IAM items:
# list_groups - get_group_policy
# list_roles - get_role_policy
# list_users - get_user_policy
def get_resource_list(r_type):
list = ""
exec(list + " = 'list_" + r_type + "()'")
print(list)
print(get_resource_list("group"))
group_inline_policy = client.get_group_policy()
role_inline_policy = client.get_role_policy()
user_inline_policy = client.get_user_policy()
print(group_inline_policy)
print(role_inline_policy)
print(user_inline_policy)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment