Created
September 22, 2021 04:41
-
-
Save pataiji/0310bdf385ec6b07e8e29c715ff48387 to your computer and use it in GitHub Desktop.
Create eventbridge rule and sns topic for security hub
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 | |
regions=( \ | |
us-east-1 \ | |
us-east-2 \ | |
us-west-1 \ | |
us-west-2 \ | |
ap-south-1 \ | |
ap-northeast-3 \ | |
ap-northeast-2 \ | |
ap-southeast-1 \ | |
ap-southeast-2 \ | |
ap-northeast-1 \ | |
ca-central-1 \ | |
eu-central-1 \ | |
eu-west-1 \ | |
eu-west-2 \ | |
eu-west-3 \ | |
eu-north-1 \ | |
sa-east-1 \ | |
) | |
for region in ${regions[@]} | |
do | |
topicArn=$(aws sns --region "$region" create-topic --name SecurityHub | jq -r '.TopicArn') | |
AWS_PAGER="" aws events put-rule --region "$region" --name SecurityHub --event-pattern "{\"source\":[\"aws.securityhub\"],\"detail-type\":[\"Security Hub Findings - Imported\"],\"detail\":{\"findings\":{\"Compliance\":{\"Status\":[{\"anything-but\":\"PASSED\"}]},\"Severity\":{\"Label\":[\"CRITICAL\",\"HIGH\"]},\"Workflow\":{\"Status\":[\"NEW\"]},\"RecordState\":[\"ACTIVE\"]}}}" | |
AWS_PAGER="" aws events put-targets --region "$region" --rule SecurityHub --targets "Id"="1","Arn"="$topicArn" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment