Last active
January 23, 2022 11:50
-
-
Save varunchandak/95e391467e25bd5b5aa794df669d3b87 to your computer and use it in GitHub Desktop.
Enable AWS Config in all 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
#!/bin/bash | |
aws ec2 describe-regions | jq -r '.Regions[].RegionName' | while read REGION; do | |
export AWS_DEFAULT_REGION="$REGION" | |
export AWS_REGION="$REGION" | |
export AWS_DEFAULT_OUTPUT="json" | |
export AWS_ACCOUNT_ID="$(aws sts get-caller-identity --output json | jq -r .Account)" | |
export CENTRAL_AWS_BUCKET="config-bucket-123456789012" | |
echo "$REGION" | |
echo "{\"name\": \"default\",\"s3BucketName\": \"$CENTRAL_AWS_BUCKET\",\"configSnapshotDeliveryProperties\": {\"deliveryFrequency\": \"Three_Hours\"}}" > deliveryChannel.json | |
aws configservice put-configuration-recorder --configuration-recorder name="default",roleARN=arn:aws:iam::"$AWS_ACCOUNT_ID":role/aws-service-role/config.amazonaws.com/AWSServiceRoleForConfig --recording-group allSupported=true,includeGlobalResourceTypes=true | |
aws configservice put-delivery-channel --delivery-channel file://deliveryChannel.json || exit 1 | |
aws configservice start-configuration-recorder --configuration-recorder-name default | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment