We will now focus on the creation and configuration of the CloudTrail service. This represents the source of record for all API calls generated within our architecture which we will apply filters to later. Note in the architecture below how CloudTrail integrates with the other AWS services we will deploy:
Firstly, download the logging template from here.
To deploy from the command line, ensure that you have installed and configured AWS CLI with the appropriate credentials. When your environment is ready, run the following command, taking note of the points below.
aws cloudformation create-stack --stack-name pattern1-logging \
--template-body file://pattern1-logging.yml \
--parameters ParameterKey=AppECSTaskRoleArn,ParameterValue="<ECS Task Role ARN>" ParameterKey=EmailAddress,ParameterValue=< Email Address > \
--capabilities CAPABILITY_NAMED_IAM \
--region ap-southeast-2
Firstly, download the logging template from here.
To deploy the template from the console, please follow this guide for information on how to deploy the cloudformation template, noting the following points before starting your deployment:
pattern1-logging
as the Stack Name.Note: Dont forget to acknowledge the capabilities checkbox at the bottom of the screen.
To create a trail for use within this lab, complete the following steps:
Navigate to CloudTrail within the console, then click on Create trail as shown here:
Enter pattern1-logging-trail
as the Trail name.
Select Create new S3 bucket and enter a name for your logging s3 bucket.
Note that the name needs to be globally unique, so you can use your accountid or uuid to keep it unique for you.
Enter the remainder of the settings as per the following example:
Complete the following configuration choices:
pattern1-logging-loggroup
CloudTrailRoleForCloudWatchLogs_pattern1-logging
Your configuration should match the screenshot below:
When you are complete, click Next.
On the next screen, complete the following configuration choices:
Check your selection against the following screenshot and then click Next.
Review the settings and click Create Trail
Now that your CloudWatch configuration is completed, we need to confirm that the log group is operational.
Follow the steps below to confirm the state of the Log Group:
Navigate to CloudWatch in your console and click on Log Groups on the side menu.
Locate the pattern1-logging-loggroup
you created before and click on the the log group as show:
Click on the available log stream, and confirm that you are seeing logs being generated.
If you have completed the configuration correctly, you should see an ongoing record of all the API calls within your account as show here:
In the next section, we are going to filter out the Events which matter to us. In doing this we will be able to create an appropriate Alarm
END OF SECTION 3