Last active
May 10, 2024 14:48
-
-
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
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 characters
#!/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