Day 25.Setting Up an EC2 Instance and CloudWatch Alarm

Published: (December 23, 2025 at 05:21 PM EST)
1 min read
Source: Dev.to

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

  1. AWS Console → EC2 → Launch instance
  2. 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)
  3. Launch
    • Click Launch instance
    • Wait until the instance state is Running and status checks are 2/2 passed

Step 2: Create the CloudWatch Alarm

  1. AWS Console → CloudWatch → Alarms → Create alarm
  2. Select the Metric
    • Click Select metricEC2 → Per-Instance Metrics → CPUUtilization
    • Choose the metric for datacenter-ec2 and click Select metric
  3. 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
  4. Name the Alarm
    • Alarm name: datacenter-alarm
    • Description (optional): Alarm when CPU exceeds 90 % for 5 minutes
    • Click Create alarm

Step 3: Verify Configuration

  • Initial state: OK (normal)
  • Metric: CPUUtilization
  • Threshold: ≥ 90 %
  • Period: 5 minutes
  • SNS Action: Alarm action shows datacenter-sns-topic
Back to Blog

Related posts

Read more »