Forked from gene1wood/aws_iam_managed_policies_2019-02-12.json
Created
July 12, 2017 02:30
-
-
Save lucasproclc/47c89790b034d23fc9445f5bdcb5689d to your computer and use it in GitHub Desktop.
Revisions
-
gene1wood revised this gist
Feb 17, 2017 . 2 changed files with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes.File renamed without changes. -
gene1wood created this gist
Feb 17, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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=(',', ': '))