DEV Community

Udoh Deborah
Udoh Deborah

Posted on

Day 46: Set-up CloudWatch alarms and SNS topics on AWS

What is Amazon CloudWatch?

Amazon CloudWatch monitors your AWS resources and applications in real time. It collects and tracks metrics (like CPU usage, memory, billing, etc.), sets alarms, and triggers automated actions or notifications.

What is Amazon SNS?

Amazon Simple Notification Service (SNS) is a fully managed pub/sub messaging service. It’s widely used to send alerts and notifications via Email, SMS, Mobile Push, and even integrate with Lambda functions or SQS queues.

Prerequisites
1. You must be signed in as the root account user to enable billing metrics/alerts. (Billing metrics require root-level permission.)
2. Set your AWS region to us-east-1 for the CloudWatch Billing metrics (billing metrics are published only in us-east-1).
3. Have the AWS Console or AWS CLI configured (if using CLI, ensure aws configure is set up with credentials and region us-east-1).

A. Console method (recommended for beginners)

1) Enable billing alerts (root user)
1. Sign in to the AWS console as the root user.
2. Open the Billing dashboard (top-right account menu → Billing).
3. In the left menu choose Billing preferences (or Preferences).
4. Check Receive Billing Alerts and Save.
• Wait a few minutes — CloudWatch will start publishing AWS/Billing → EstimatedCharges.

2) Create an SNS topic + subscribe your email
1. Console → SNS → Topics → Create topic.
• Type: Standard, Name: billing-alerts (or any name).
2. After topic is created → Create subscription: Protocol = Email, Endpoint = youremail@example.com.
3. Check your email and click the confirmation link from AWS SNS to activate the subscription.

3) Create the CloudWatch billing alarm
1. Console → CloudWatch → Alarms → Create alarm.
2. Click Select metric → Choose Billing → EstimatedCharges. (If you don’t see Billing, switch region to us-east-1 and ensure billing alerts are enabled.)
3. Dimension: Currency = USD. Click Select metric.
4. Configure the alarm:
• Statistic: Maximum (or SampleCount/Average also possible; Maximum is common here)
• Period: 6 Hours (21600 seconds) — billing metrics are coarse, 6 hours is typical.
• Threshold type: Static
• Whenever EstimatedCharges >= 2 (USD)
• For: 1 consecutive period
5. Under Configure actions, set Send notification to → select your SNS topic billing-alerts.
6. Name alarm: Billing-Alert-$2 (or similar). Create alarm.

4) Test that SNS works
• From the SNS console, select your topic → Publish message → enter subject & message → Publish.
• Confirm you receive the test email. (This proves notifications are working even before a billing value reaches $2.)

Top comments (0)