Skip to main content

Sending SNS Alerts for Amazon ECS Events

Hands-On Lab

 

Photo of Mark Richman

Mark Richman

AWS Training Architect II in Content

Length

01:00:00

Difficulty

Intermediate

In this hands-on learning activity, you will learn how to configure SNS Alerts for ECS Events. These events can be sent via email, SMS, or even be used to trigger Lambda functions.

What are Hands-On Labs?

Hands-On Labs are scenario-based learning environments where learners can practice without consequences. Don't compromise a system or waste money on expensive downloads. Practice real-world skills without the real-world risk, no assembly required.

Sending SNS Alerts for Amazon ECS Events

Introduction

In this hands-on lab, we will configure SNS Alerts for ECS Events. These events can be sent via email, SMS, or even be used to trigger Lambda functions.

Solution

Log in to the live AWS environment using the credentials provided. Make sure you're in the N. Virginia (us-east-1) region throughout the lab.

Create and Subscribe to an Amazon SNS Topic

  1. Navigate to SNS.
  2. Click Get started.
  3. Click Create topic.
  4. Give it a Topic name of "MyTopic".
  5. Click Create topic.
  6. On the Topic details page, click Create subscription.
  7. In the dialog, set the following values:
    • Protocol: Email
    • Endpoint: Enter your email address
  8. Click Create subscription.
  9. Check your email inbox.
  10. In the subscription confirmation email, click Confirm subscription.
  11. Click Public to topic.
  12. Set the following values:
    • Subject: Test
    • Message format: Raw
    • Message: Test
  13. Click Publish message.
  14. Check your inbox, where you should see the test message.

Register an ECS Event Rule in CloudWatch

  1. Navigate to CloudWatch.
  2. Click Rules in the left-hand menu.
  3. Click Create rule.
  4. In the Event Source section, select Event Pattern, and set the following values:
    • Service Name: EC2 Container Service (ECS)
    • Event Type: All Events
  5. In the Targets section, click Add target, and set the following values:
    • In the dropdown, select SNS topic.
    • Topic: MyTopic
  6. Click Configure details.
  7. Give it a Name of "MyRule".
  8. Click Create rule.

Test the Rule by Starting or Stopping a Task

  1. Navigate to ECS.
  2. Click the cluster link.
  3. In the Tasks tab, select the listed task, and click Stop.
  4. In the dialog, click Stop.
  5. Check your inbox, where you should have an email notifying you of the stopped task.

Conclusion

Congratulations on completing this hands-on lab!