AWS Assignment– 7
CloudWatch, CloudTrail & CloudFormation
Basic Questions
- Enable CloudWatch monitoring for an EC2 instance.
- View CPU utilization metrics for your EC2 instance in CloudWatch.
- Use the AWS CLI to list available CloudWatch metrics.
- Create a CloudWatch alarm that triggers if CPU usage > 70%.
- Configure the alarm to send a notification via SNS.
- Stop and start an instance to test CloudWatch alarm behavior.
- Enable detailed monitoring for an EC2 instance and compare with basic monitoring.
- Use the AWS CLI to get the latest CPU metric for an instance.
- Create a CloudWatch dashboard and add a CPU utilization widget.
- Add memory utilization to the dashboard using CloudWatch agent.
- Enable CloudTrail in your AWS account.
- Verify CloudTrail is logging events for your EC2 actions.
- Use AWS CLI to list the last 5 CloudTrail events.
- Find the IAM user who launched an EC2 instance from CloudTrail logs.
- Enable multi-region trail in CloudTrail.
- Send CloudTrail logs to an S3 bucket.
- Create a basic CloudFormation stack to launch one EC2 instance.
- Use AWS CLI to deploy the same stack.
- Update the stack to add a new Security Group rule.
- Delete the CloudFormation stack and verify resources are removed.
Intermediate Questions
- Create a CloudWatch alarm to stop an EC2 instance when CPU usage < 5% for 15 minutes.
- Configure a CloudWatch alarm to automatically reboot an EC2 instance.
- Install and configure the CloudWatch agent on Linux EC2 to send disk metrics.
- Use AWS CLI to check disk utilization metrics collected by the CloudWatch agent.
- Create a CloudWatch alarm for root disk utilization > 80%.
- Export CloudWatch logs to S3 for archival.
- Enable VPC Flow Logs and send them to CloudWatch Logs.
- Create a CloudWatch Logs group and push custom application logs from EC2.
- Set a metric filter on CloudWatch Logs to detect failed SSH login attempts.
- Create a CloudWatch alarm on the above filter and trigger SNS notification.
- Use CloudTrail to track IAM user activity (who created/modified users).
- Enable CloudTrail log file integrity validation.
- Create an Athena table to query CloudTrail logs from S3.
- Query CloudTrail logs to find all EC2 terminate events.
- Create a CloudFormation template to deploy an S3 bucket with versioning enabled.
- Add bucket policy in CloudFormation to allow only your IAM user access.
- Create a CloudFormation template with Parameters (e.g., instance type).
- Launch the template with different parameter values and compare results.
- Use CloudFormation Outputs to export Security Group ID.
- Reference exported values from another CloudFormation stack.
Advanced Questions
- Create a CloudWatch dashboard with CPU, disk, and memory metrics for multiple EC2s.
- Configure CloudWatch alarms to automatically recover an unhealthy instance.
- Enable CloudTrail event logging for S3 bucket activity (uploads, deletes).
- Use CloudTrail logs to detect unauthorized IAM access attempts.
- Write a Linux script that downloads CloudTrail logs from S3 and filters EC2 events.
- Create a CloudFormation template that provisions a VPC with a public subnet + EC2.
- Extend the template to include Security Groups and Internet Gateway.
- Add Outputs in CloudFormation to display the EC2 public IP after stack creation.
- Enable Stack rollback and test by intentionally giving an invalid parameter.
- Final Hands-on Project:
- Enable CloudWatch + CloudTrail for your account
- Install CloudWatch agent on Linux EC2 for custom metrics
- Create alarms for CPU, disk, and failed SSH logins
- Store logs in S3 and analyze with Athena
- Create a CloudFormation stack for EC2 + S3 + Security Groups
- Document monitoring + auditing + IaC best practices