Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save lucasproclc/47c89790b034d23fc9445f5bdcb5689d to your computer and use it in GitHub Desktop.

Select an option

Save lucasproclc/47c89790b034d23fc9445f5bdcb5689d to your computer and use it in GitHub Desktop.

Revisions

  1. @gene1wood gene1wood revised this gist Feb 17, 2017. 2 changed files with 0 additions and 0 deletions.
  2. @gene1wood gene1wood created this gist Feb 17, 2017.
    8,669 changes: 8,669 additions & 0 deletions aws_iam_managed_policies_2017-02-17.json
    8,669 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
    22 changes: 22 additions & 0 deletions export_aws_managed_policies.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    import boto3
    import json
    client = boto3.client('iam')
    paginator = client.get_paginator('list_policies')
    response_iterator = paginator.paginate(Scope='AWS')

    managed_policies = []

    for response in response_iterator:
    for policy in response['Policies']:
    response_policy_version = client.get_policy_version(
    PolicyArn=policy['Arn'],
    VersionId=policy['DefaultVersionId']
    )
    managed_policies.append({
    'Document': response_policy_version['PolicyVersion']['Document'],
    'VersionId': response_policy_version['PolicyVersion']['VersionId'],
    'PolicyName': policy['PolicyName'],
    'PolicyId': policy['PolicyId']
    })
    with open('aws_iam_managed_policies.json') as f:
    json.dump(managed_policies, f, sort_keys=True, indent=4, separators=(',', ': '))