Skip to content

Instantly share code, notes, and snippets.

@gene1wood
Last active November 15, 2024 10:24
Show Gist options
  • Save gene1wood/55b358748be3c314f956 to your computer and use it in GitHub Desktop.
Save gene1wood/55b358748be3c314f956 to your computer and use it in GitHub Desktop.

Revisions

  1. gene1wood revised this gist Nov 18, 2019. 1 changed file with 19833 additions and 9597 deletions.
    29,430 changes: 19,833 additions & 9,597 deletions all_aws_managed_policies.json
    19,833 additions, 9,597 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
  2. gene1wood revised this gist Nov 16, 2018. 1 changed file with 20275 additions and 3273 deletions.
    23,548 changes: 20,275 additions & 3,273 deletions all_aws_managed_policies.json
    20,275 additions, 3,273 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
  3. gene1wood revised this gist Nov 12, 2015. 2 changed files with 1999 additions and 2716 deletions.
    4,711 changes: 1,997 additions & 2,714 deletions all_aws_managed_policies.json
    1,997 additions, 2,714 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
    4 changes: 2 additions & 2 deletions show_all_aws_managed_policies.py
    Original file line number Diff line number Diff line change
    @@ -22,8 +22,8 @@ def json_serial(obj):

    for policy_name in policies:
    response = client.get_policy_version(
    PolicyArn=policy['Arn'],
    VersionId=policy['DefaultVersionId'])
    PolicyArn=policies[policy_name]['Arn'],
    VersionId=policies[policy_name]['DefaultVersionId'])
    for key in response['PolicyVersion']:
    policies[policy_name][key] = response['PolicyVersion'][key]

  4. gene1wood created this gist Nov 12, 2015.
    6,710 changes: 6,710 additions & 0 deletions all_aws_managed_policies.json
    6,710 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
    34 changes: 34 additions & 0 deletions show_all_aws_managed_policies.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,34 @@
    import boto3
    from datetime import datetime
    import json

    def json_serial(obj):
    """JSON serializer for objects not serializable by default json code"""

    if isinstance(obj, datetime):
    serial = obj.isoformat()
    return serial
    raise TypeError ("Type not serializable")

    client = boto3.client('iam')

    policies = {}

    paginator = client.get_paginator('list_policies')
    response_iterator = paginator.paginate(Scope='AWS')
    for response in response_iterator:
    for policy in response['Policies']:
    policies[policy['PolicyName']] = policy

    for policy_name in policies:
    response = client.get_policy_version(
    PolicyArn=policy['Arn'],
    VersionId=policy['DefaultVersionId'])
    for key in response['PolicyVersion']:
    policies[policy_name][key] = response['PolicyVersion'][key]

    print(json.dumps(policies,
    sort_keys=True,
    indent=4,
    separators=(',', ': '),
    default=json_serial))