Day 25.Setting Up an EC2 Instance and CloudWatch Alarm
Source: Dev.to
Lab Information
The Nautilus DevOps team needs to set up an EC2 instance for their application and create a CloudWatch alarm to monitor CPU utilization. The alarm must trigger if CPU utilization exceeds 90 % for one consecutive 5‑minute period. Notifications should be sent to the existing SNS topic datacenter-sns-topic.
Step 1: Launch the EC2 Instance
- AWS Console → EC2 → Launch instance
- Configure instance
- Name:
datacenter-ec2 - AMI: Ubuntu Server (20.04 LTS or 22.04 LTS)
- Instance type:
t2.micro(or any allowed type) - Key pair: Select or create one (lab choice)
- Network: Default VPC, default subnet
- Security group: Allow SSH (port 22)
- Name:
- Launch
- Click Launch instance
- Wait until the instance state is Running and status checks are 2/2 passed
Step 2: Create the CloudWatch Alarm
- AWS Console → CloudWatch → Alarms → Create alarm
- Select the Metric
- Click Select metric → EC2 → Per-Instance Metrics → CPUUtilization
- Choose the metric for
datacenter-ec2and click Select metric
- Configure Alarm Conditions
- Alarm state trigger: In alarm
- Threshold type: Static
- Whenever CPUUtilization is ≥ 90 % for 5 minutes (period)
- Send notification to: Select existing SNS topic → datacenter-sns-topic
- Name the Alarm
- Alarm name:
datacenter-alarm - Description (optional): Alarm when CPU exceeds 90 % for 5 minutes
- Click Create alarm
- Alarm name:
Step 3: Verify Configuration
- Initial state:
OK(normal) - Metric:
CPUUtilization - Threshold: ≥ 90 %
- Period: 5 minutes
- SNS Action: Alarm action shows
datacenter-sns-topic