Last active
November 15, 2024 10:24
-
-
Save gene1wood/55b358748be3c314f956 to your computer and use it in GitHub Desktop.
Revisions
-
gene1wood revised this gist
Nov 18, 2019 . 1 changed file with 19833 additions and 9597 deletions.There are no files selected for viewing
-
gene1wood revised this gist
Nov 16, 2018 . 1 changed file with 20275 additions and 3273 deletions.There are no files selected for viewing
-
gene1wood revised this gist
Nov 12, 2015 . 2 changed files with 1999 additions and 2716 deletions.There are no files selected for viewing
This file contains 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 @@ -22,8 +22,8 @@ def json_serial(obj): for policy_name in policies: response = client.get_policy_version( PolicyArn=policies[policy_name]['Arn'], VersionId=policies[policy_name]['DefaultVersionId']) for key in response['PolicyVersion']: policies[policy_name][key] = response['PolicyVersion'][key] -
gene1wood created this gist
Nov 12, 2015 .There are no files selected for viewing
This file contains 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,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))