-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
240 additions
and
37 deletions.
There are no files selected for viewing
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 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 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 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 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 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 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
AWSTemplateFormatVersion: '2010-09-09' | ||
Description: Configure a Slack Chatbot for an account | ||
# TemplateSource: https://github.com/primeharbor/aws-account-automation/blob/master/cloudformation/SecurityAlertChatBot-Template.yaml | ||
# S3-Source: https://s3.amazonaws.com/pht-cloudformation/aws-account-automation/SecurityAlertChatBot-Template.yaml | ||
|
||
|
||
Parameters: | ||
|
||
pChatBotWorkspaceId: | ||
Description: pre-created Workspace ID | ||
Type: String | ||
|
||
pSlackChannelId: | ||
Description: To get the ID, open Slack, right click on the channel name in the left pane, then choose Copy Link. | ||
Type: String | ||
|
||
pSnsTopicName: | ||
Description: Name of the SNS Topic which will send events to ChatBot & Slack | ||
Type: String | ||
|
||
Resources: | ||
|
||
# | ||
# Chat Bot | ||
# | ||
Chatbot: | ||
Type: AWS::Chatbot::SlackChannelConfiguration | ||
Properties: | ||
ConfigurationName: !Sub "${AWS::StackName}-Chatbot" | ||
# GuardrailPolicies: | ||
# - String | ||
IamRoleArn: !GetAtt ChatbotRole.Arn | ||
LoggingLevel: INFO | ||
SlackChannelId: !Ref pSlackChannelId | ||
SlackWorkspaceId: !Ref pChatBotWorkspaceId | ||
SnsTopicArns: | ||
- !GetAtt SlackSNSTopic.TopicArn | ||
# UserRoleRequired: Boolean | ||
|
||
SlackSNSTopic: | ||
Type: AWS::SNS::Topic | ||
Properties: | ||
DisplayName: !Sub "${AWS::StackName}-topic" | ||
TopicName: !Ref pSnsTopicName | ||
|
||
ChatbotRole: | ||
Type: AWS::IAM::Role | ||
Properties: | ||
AssumeRolePolicyDocument: | ||
Version: '2012-10-17' | ||
Statement: | ||
- Effect: Allow | ||
Principal: | ||
Service: | ||
- chatbot.amazonaws.com | ||
Action: | ||
- sts:AssumeRole | ||
Path: / | ||
# ManagedPolicyArns: | ||
# - TBD | ||
Policies: | ||
- PolicyName: Logging | ||
PolicyDocument: | ||
Version: '2012-10-17' | ||
Statement: | ||
- Resource: '*' | ||
Action: | ||
- logs:* | ||
Effect: Allow | ||
|
||
|
||
Outputs: | ||
|
||
ChatbotTopicArn: | ||
Value: !GetAtt SlackSNSTopic.TopicArn |
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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/bin/bash | ||
|
||
# Script to enable Inspector in each region in the Delegated Admin Account | ||
|
||
# We need to get a list of the accounts to then add as members. This actually comes from the Organizations API which we now have access to as a Delegated Admin Child | ||
ACCOUNT_LIST=`aws organizations list-accounts --query Accounts[].Id --output text` | ||
ME=`aws sts get-caller-identity --query Account --output text` | ||
|
||
trap "exit 1" SIGINT | ||
|
||
REGIONS=`aws ec2 describe-regions --query 'Regions[].[RegionName]' --output text` | ||
for r in $REGIONS ; do | ||
echo "Associating accounts in $r" | ||
|
||
for a in $ACCOUNT_LIST ; do | ||
if [ $a != $ME ] ; then | ||
aws inspector2 associate-member --account-id $a --region $r --output text | ||
fi | ||
done | ||
|
||
echo "Enable Inspector in this delegated Admin account" | ||
aws inspector2 enable --resource-types EC2 --account-ids $ACCOUNT_LIST --output text --region $r --no-paginate | ||
sleep 10 | ||
|
||
echo "Update the org config to auto-enable new accounts" | ||
aws inspector2 update-organization-configuration --auto-enable ec2=true,ecr=false,lambda=false --region $r | ||
|
||
done |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/bash | ||
|
||
# Script to enable SecurityHub in each region in the Delegated Admin Account | ||
|
||
# We need to get a list of the accounts to then add as members. This actually comes from the Organizations API which we now have access to as a Delegated Admin Child | ||
aws organizations list-accounts | jq '[ .Accounts[] | { AccountId: .Id, Email: .Email } ]' > ACCOUNT_INFO.txt | ||
|
||
REGIONS=`aws ec2 describe-regions --query 'Regions[].[RegionName]' --output text` | ||
for r in $REGIONS ; do | ||
echo "Enabling SecurityHub Delegated Admin in $r" | ||
|
||
# Enable Security Hub in this delegated Admin account | ||
aws securityhub enable-security-hub --no-enable-default-standards --output text --region $r | ||
|
||
# Update the org config to auto-enable new accounts | ||
aws securityhub update-organization-configuration --auto-enable --region $r | ||
|
||
# Add all of the existing accounts | ||
aws securityhub create-members --account-details file://ACCOUNT_INFO.txt --region $r | ||
|
||
# Configure the Consolidated controls and enable all the controls for the enabled frameworks | ||
aws securityhub update-security-hub-configuration --auto-enable-controls --control-finding-generator SECURITY_CONTROL --region $r | ||
done | ||
|
||
# cleanup | ||
rm ACCOUNT_INFO.txt |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/bin/bash | ||
|
||
# Script to enable Delegated Admin in a payer account for all Regions | ||
|
||
SECURITY_ACCOUNT=$1 | ||
|
||
if [ -z $SECURITY_ACCOUNT ] ; then | ||
echo "Usage: $0 <security_account_id>" | ||
exit 1 | ||
fi | ||
|
||
REGIONS=`aws ec2 describe-regions --query 'Regions[].[RegionName]' --output text` | ||
for r in $REGIONS ; do | ||
echo "Enabling Inspector Delegated Admin in $r" | ||
aws inspector2 enable-delegated-admin-account --delegated-admin-account-id $SECURITY_ACCOUNT --region $r | ||
|
||
done |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/bash | ||
|
||
# Script to enable Delegated Admin in a payer account for all Regions | ||
|
||
SECURITY_ACCOUNT=$1 | ||
|
||
if [ -z $SECURITY_ACCOUNT ] ; then | ||
echo "Usage: $0 <security_account_id>" | ||
exit 1 | ||
fi | ||
|
||
REGIONS=`aws ec2 describe-regions --query 'Regions[].[RegionName]' --output text` | ||
for r in $REGIONS ; do | ||
echo "Enabling SecurityHub Delegated Admin in $r" | ||
aws securityhub enable-organization-admin-account --admin-account-id $SECURITY_ACCOUNT --region $r | ||
aws securityhub enable-security-hub --no-enable-default-standards --output text --region $r | ||
|
||
done |