Skip to content

Instantly share code, notes, and snippets.

@houey
Last active May 10, 2024 14:48
Show Gist options
  • Save houey/dd652ab17d00ec72de76aae92282c7a2 to your computer and use it in GitHub Desktop.
Save houey/dd652ab17d00ec72de76aae92282c7a2 to your computer and use it in GitHub Desktop.
Pull down SCPs from AWS and put the content of each into a json file
#!/bin/bash
# Get list of SCPs in the organization
scps=$(aws organizations list-policies --filter SERVICE_CONTROL_POLICY | jq -r '.Policies[].Id')
# Loop through each SCP and save its content into a JSON file
for scp_id in $scps; do
# Get SCP content
scp_content=$(aws organizations describe-policy --policy-id $scp_id)
# Extract SCP name
scp_name=$(echo $scp_content | jq -r '.Policy.PolicySummary.Name')
# Save SCP content into a JSON file
echo $scp_content > "$scp_name.json"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment