Last active
April 5, 2019 15:07
-
-
Save atulkumar2/aa539c9691932328cdb86abdf64473a8 to your computer and use it in GitHub Desktop.
Delete config rules from AWS regions
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 characters
# This will delete all AWS config rules from regions listed in the string regions below | |
# Run it on one region first to confirm | |
# To run, python 3.* with awscli package is needed | |
# For anaconda, use https://anaconda.org/conda-forge/awscli to install package | |
# List of AWS regions https://docs.aws.amazon.com/general/latest/gr/rande.html | |
# https://docs.aws.amazon.com/config/latest/developerguide/evaluate-config_manage-rules.html | |
# There is dry run option in config rules so beware | |
#regions=(us-east-2 us-east-1 us-west-1 us-west-2 ap-south-1 ap-northeast-2 ap-southeast-1 ap-southeast-2 ap-northeast-1 ca-central-1 cn-north-1 cn-northwest-1 eu-central-1 eu-west-1 eu-west-2 eu-west-3 eu-north-1 sa-east-1 us-gov-east-1 us-gov-west-1) | |
regions=(ap-southeast-2 ap-northeast-1 ap-northeast-2 ca-central-1 cn-north-1 cn-northwest-1 eu-central-1 eu-west-1 eu-west-2 eu-west-3 eu-north-1 sa-east-1) | |
for region in $regions | |
do | |
echo "DELETING CONFIG RULES IN REGION $region" | |
aws configservice describe-config-rules --query 'ConfigRules[].ConfigRuleName' --profile ce-ecs --region $region > $region | |
for CRN in $(cat $region | jq '.[]') | |
do | |
CRN1=$(echo $CRN | tr --delete '"') | |
echo "$region $CRN1 : Deleting config rule" | |
aws configservice delete-config-rule --profile ce-ecs --region $region --config-rule-name $CRN1 | |
done | |
echo "" | |
echo "" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment