Overview
Lab details
- This lab walks you through the steps to configure CloudTrail to be able to access your log files.
- You will practice using AWS CloudTrail, Amazon S3 and Amazon EC2.
- Duration: 45 minutes
- AWS Region: US East (N. Virginia) us-east-1
Introduction
What is Cloud Trail ?
AWS CloudTrail is a service that enables governance, compliance, operational auditing, and risk auditing of your Amazon Web Services 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 Amazon Management Console, Amazon SDKs, command line tools, and other AWS services. This event history simplifies security analysis, resource change tracking, and troubleshooting. Here are some of the benefits of using CloudTrail:- Improved security: CloudTrail can help you identify and respond to unauthorized or malicious activity in your AWS account.
- Increased compliance: CloudTrail can help you demonstrate compliance with industry regulations, such as PCI DSS, HIPAA, and SOX.
- Simplified auditing: CloudTrail can help you simplify your auditing process by providing a centralized repository of audit logs.
- Better troubleshooting: CloudTrail can help you troubleshoot problems in your AWS environment by providing a historical record of events.
Architecture diagram

Task details
- Sign into the AWS management Console
- Configuring CloudTrail and S3 Bucket.
- Checking the S3 Bucket .
- Viewing the logs in the S3 Bucket
- Launching an EC2 Instance
- Checking Log files created by EC2
- Connecting to EC2 instance
- Access log files in S3 created for the events.
- Validation of the lab.
Launching the lab environment
- To launch the lab environment, Click on the Launch lab button.
- Please wait until the cloud environment is provisioned. It will take less than a minute to provision.
- Once the Lab is started, you will be provided with IAM user name, Password, Access Key, and Secret Access Key.
You can only start one lab at any given time
Lab guide
Lab steps
Task 1: Sign in to AWS Management Console
- Click on the Open console button, and you will get redirected to AWS Console in a new browser tab.
- On the AWS sign-in page,
- Leave the Account ID as default. Never edit/remove the 12 digit Account ID present in the AWS Console. otherwise, you cannot proceed with the lab.
- Now copy your User Name and Password in the Lab Console to the IAM Username and Password in AWS Console and click on the Sign in button
- Once Signed in to the AWS Management Console, Make the default AWS Region as US East (N. Virginia) us-east-1.
Task 2: Configuring CloudTrail and an S3 Bucket
- Navigate and click on CloudTrail, which will be available under the Management and Governance section of Services.
- Click on menu icon on the top-left corner and click on Trails. Now click on Create trail
- Under Create Trail, enter these details:
- Trail name : Enter My_First_Trail
-
Storage Location : Select Create a new S3 Bucket
- Trail log bucket and folder : Leave it as default
- Log file SSE-KMS encryption : Uncheck Enabled
-
Additional Settings:
- Log file validation : Uncheck Enabled
-
SNS notification delivery : Leave it as default

- CloudWatch Logs : Leave it as default
-
Tags- optional:
- Key: Enter Name
-
Value: Enter my_logs

- Click on Next.
-
Choose Log Events:
- Leave everything as default and click on Next.
- Review and click on Create trail.
-
A CloudTrail instance that delivers logs to an S3 bucket has now been created.

Task 3: Checking the S3 Bucket
- Navigate to Services. Under Storage, click and open S3 in a new tab.
-
Under S3 Buckets, you can see the bucket which was created by CloudTrail.

Task 4: Viewing the Logs in the S3 Bucket
- AWS CloudTrail captures AWS API calls and related events made by or on behalf of an AWS account and delivers log files to a specified S3 bucket. CloudTrail typically delivers log files within 15 minutes of an API call and publishes new log files multiple times an hour, usually about every 5 minutes.
- Wait for a few minutes until the first log is created.
- Keep refreshing the page and then open the bucket once logs appear.
-
Click and open the folders inside the bucket in the below order:
- bucket name -> AWS Logs -> Account No. -> CloudTrails -> us-east-1 -> Year No. -> Month No. -> Day No.
-
You can see the logs are being created inside the bucket.

-
Click on the file and choose Open.

- You will see a JSON file content. To format the content, we will use a JSON formatter. Copy the content.
-
Click JSONFormatter and paste the file content in the user input field. Click on Format/Beautify to format the JSON blob.

- You will see the Username, EventTime, EventSource, EventName, etc. You can see all the details about the particular event that happened.
Task 5: Launching an EC2 Instance
- Make sure you are in US East(N.Virginia) Region.
- Navigate to the Services menu at the top, then click on EC2 in the Compute section.
- Navigate to Instances on the left panel and click on Launch Instances
-
Name: enter whizlabs-instance.

- Choose an Amazon Machine Image (AMI): Select Amazon Linux 2023 AMI in the drop-down.

- Choose an Instance Type: Select t2.micro**.**
- Key Pair: Select Proceed without a Key Pair

- On the right side under the Summary section ,
- Number of Instances: 1
- Click on the Launch Instances.
- Launch Status: Your instance is now launching, Click on the instance ID and wait for complete initialization of instance (until the status changes to running).

Note the creation time of your instance.
Task 6: Checking Log files created by the EC2 Instance
- Navigate back to S3 and go to the latest log file (as mentioned above).
- Wait for 5-10 minutes if the new log has not been created yet.
- Click on the log, open the file and copy the content and format it with JSONFormatter.
-
You will see the eventName of all the resources created like Securitygroups, VPC, etc. while launching the EC2 Instances.

Be patient as CloudTrail delivers log files to your S3 bucket approximately every 10-15 minutes. CloudTrail does not deliver log files if no API calls are made on your account.
Task 7: Connecting to the EC2 Instance
- Navigate to EC2.
-
Select your EC2 Instance and click on Connect.

-
Select EC2 Instance Connect (browser-based SSH connection) and click on Connect.

- Since this is for demo purposes, we can close the window after verifying a connection to the instance.
Task 8: Checking for a log file after connecting to the EC2 Instance
- Navigate back to S3 and go to Logs (as mentioned above).
- Click on the latest log created and open it.
- Copy the file content to the JSON Formatter and format the JSON blob.
-
You can see the eventTime, eventSource, eventName, and the rest of the fields in the JSON blob.

Task 9: Validation Test
- Once the lab steps are completed, please click on the Check my work button on the right side panel.
- This will validate the resources in the AWS account and displays whether you have completed this lab successfully or not.
-
Sample output :

Completion and conclusion
- You have successfully used the AWS management console to create an AWS CloudTrail.
- You have successfully created an Amazon S3 Bucket.
- You have formatted the new Log file and confirmed the events inside the JSON blob.
- You have launched an EC2 Instance and connected to it via browser.
- You have tested the log file from the. EC2 creation and the log file from connecting to the instance via SSH.
End lab
- Sign out of AWS Account.
- You have successfully completed the lab.
- Once you have completed the steps click on End lab in the IP Lab Portal.
What gets checked
When you press Check my work, the platform verifies each of these:- Check Cloudtrail logs — Check whether cloudtrail log is created or not
- Launch an EC2 Instance — Check whether an EC2 Instance is launched or not.