Skip to content

Instantly share code, notes, and snippets.

@stewmi
Created November 22, 2021 21:47
Show Gist options
  • Save stewmi/665cdd6135d006347ff41c1885e2e1df to your computer and use it in GitHub Desktop.
Save stewmi/665cdd6135d006347ff41c1885e2e1df to your computer and use it in GitHub Desktop.
import boto3
import json
orgs = boto3.client("organizations")
paginator = orgs.get_paginator('list_policies')
page_iterator = paginator.paginate(Filter="SERVICE_CONTROL_POLICY")
for page in page_iterator:
for policy in page['Policies']:
policy_desc = orgs.describe_policy(PolicyId=policy['Id'])
with open('{}.json'.format(policy['Name']), 'w') as f:
json.dump(json.loads(policy_desc['Policy']['Content']), f, ensure_ascii=False, indent=4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment