Level 200: Automated Deployment of Detective Controls: Lab Guide
- Ben Potter, Security Lead, Well-Architected
Table of Contents
AWS CloudTrail is a service that enables governance, compliance, operational auditing, and risk auditing of your AWS account. With CloudTrail, you can log, continuously monitor, and retain account activity related to actions across your AWS infrastructure. CloudTrail provides event history of your AWS account activity, including actions taken through the AWS Management Console, AWS SDKs, command line tools, and other AWS services.
Amazon GuardDuty is a threat detection service that continuously monitors for malicious or unauthorized behavior to help you protect your AWS accounts and workloads. It monitors for activity such as unusual API calls or potentially unauthorized deployments that indicate a possible account compromise. GuardDuty also detects potentially compromised instances or reconnaissance by attackers.
Using AWS CloudFormation, we are going to configure GuardDuty, and configure alerting to your email address.
AWS Config is a service that enables you to assess, audit, and evaluate the configurations of your AWS resources. AWS Config continuously monitors and records your AWS resource configurations and allows you to automate the evaluation of recorded configurations against desired configurations.
- Download the latest version of the cloudtrail-config-guardduty.yaml CloudFormation template from GitHub raw, or by cloning this repository.
- Sign in to the AWS Management Console, select your preferred region, and open the CloudFormation console at https://console.aws.amazon.com/cloudformation/. Note if your CloudFormation console does not look the same, you can enable the redesigned console by clicking New Console in the CloudFormation menu.
- Click Create stack.
- Enter the following details for each section: General
- Stack name: The name of this stack. For this lab, use
- CloudTrail: Enable CloudTrail Yes/No. If you already have CloudTrail enabled select No.
- Config: Enable Config Yes/No. If you already have Config enabled select No.
- GuardDuty: Enable GuardDuty Yes/No. If you already have GuardDuty enabled select No. Note that GuardDuty will create and leave an IAM role the first time its enabled.
- S3BucketPolicyExplicitDeny: (Optional) Explicitly deny destructive actions to the bucket. AWS root user will be required to modify this bucket if configured.
- S3AccessLogsBucketName: (Optional) The name of an existing S3 bucket for storing S3 access logs. CloudTrail
- CloudTrailBucketName: The name of the new S3 bucket to create for CloudTrail to send logs to. IMPORTANT Specify a bucket name that is unique.
- CloudTrailCWLogsRetentionTime: Number of days to retain logs in CloudWatch Logs.
- CloudTrailS3RetentionTime: Number of days to retain logs in the S3 bucket before they are automatically deleted.
- CloudTrailEncryptS3Logs: (Optional) Use AWS KMS to encrypt logs stored in Amazon S3. A new KMS key will be created.
- CloudTrailLogS3DataEvents: (Optional) These events provide insight into the resource operations performed on or within S3. Config
- ConfigBucketName: The name of the new S3 bucket to create for Config to save config snapshots to. IMPORTANT Specify a bucket name that is unique.
- ConfigSnapshotFrequency: AWS Config configuration snapshot frequency
- ConfigS3RetentionTime: Number of days to retain logs in the S3 bucket before they are automatically deleted. Guard Duty
GuardDutyEmailAddress: The email address you own that will receive the alerts, you must have access to this address for testing.
Once you have finished entering the details for the template continue to the bottom of the page and click Next.
- In this lab, we won't add any tags or other options. Click Next. Tags, which are key-value pairs, can help you identify your stacks. For more information, see Adding Tags to Your AWS CloudFormation Stack.
- Review the information for the stack. When you're satisfied with the configuration, check I acknowledge that AWS CloudFormation might create IAM resources with custom names then click Create stack.
- After a few minutes the stack status should change from CREATE_IN_PROGRESS to CREATE_COMPLETE. You have now set up detective controls to log to your buckets and retain events, giving you the ability to search history and later enable pro-active monitoring of your AWS account!
- You should receive an email to confirm the SNS email subscription, you must confirm this. Note as the email is directly from GuardDuty via SNS is will be JSON format.
- Automate alerting on key indicators AWS Cloudtrail, AWS Config and Amazon GuardDuty provide insights into your environment.
- Implement new security services and features: New features such as Amazon GuardDuty have been adopted.
- Automate configuration management: CloudFormation is being used to configure AWS CloudTrail, AWS Config and Amazon GuardDuty.
- Implement managed services: Managed services are utilized to increase your visibility and control of your environment.
The following instructions will remove the resources that have a cost for running them.
Note: If you are planning on doing the lab 300_Incident_Response_with_AWS_Console_and_CLI we recommend you only tear down this stack after completing that lab as their is a dependency on AWS CloudTrail being enabled for the other lab.
Delete the stack:
- Sign in to the AWS Management Console, and open the CloudFormation console at https://console.aws.amazon.com/cloudformation/.
- Select the
- Click the Actions button then click Delete Stack.
- Confirm the stack and then click the Yes, Delete button.
Empty and delete the S3 buckets:
- Sign in to the AWS Management Console, and open the S3 console at https://console.aws.amazon.com/s3/.
- Select the CloudTrail bucket name you previously created without clicking the name.
- Click Empty bucket and enter the bucket name in the confirmation box.
- Click Confirm and the bucket will be emptied when the bottom task bar has 0 operations in progress.
- With the bucket now empty, click Delete bucket.
- Enter the bucket name in the confirmation box and click Confirm.
- Repeat steps 2 to 6 for the Config bucket you created.
References & useful resources
Licensed under the Apache 2.0 and MITnoAttr License.
Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. A copy of the License is located at
or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.