AWS SNS + EventBridge

Daily Goal – AWS App Services Challenge Labs

Challenge Lab #1 – Configure an Amazon EventBridge Rule That Triggers an Action

Scenario:

In this Challenge Lab, I will configure an Amazon EventBridge rule that will send an email when an Amazon Elastic Cloud Compute (Amazon EC2) instance shuts down. First, I will verify that the EC2 instance is running, and then I will subscribe to an Amazon Simple Notification Service (Amazon SNS) topic. Next, I will create an Amazon EventBridge rule to monitor the status of the EC2 instance and generate a notification when the instance is stopped. Finally, I will simulate a failure of the EC2 instance, and then I will verify that you received an email notification.

  • Verify that the WebServer EC2 instance is running.
  • Subscribe to the CWAlarm SNS topic.
  • Create an EventBridge rule to monitor the status of the WebServer EC2 instance.
  • Test the EventBridge rule.

AWS Notification – Subscription Confirmation

Inbox

AWS Notifications <no-reply@sns.amazonaws.com>2:54 PM (10 minutes ago)
to me

You have chosen to subscribe to the topic:
arn:aws:sns:us-east-2:572311113237:CWAlarm

To confirm this subscription, click or visit the link below (If this was in error no action is necessary):
Confirm subscription

Please do not reply directly to this email. If you wish to remove yourself from receiving all future SNS subscription confirmation requests please send an email to sns-opt-out

AWS Notification Message

Inbox

AWS Notifications <no-reply@sns.amazonaws.com>3:01 PM (6 minutes ago)
to me

{“version”:”0″,”id”:”0e4ae69b-0817-6949-0037-2981356fd993″,”detail-type”:”EC2 Instance State-change Notification”,”source”:”aws.ec2″,”account”:”572311113237″,”time”:”2022-09-22T19:01:44Z”,”region”:”us-east-2″,”resources”:[“arn:aws:ec2:us-east-2:572311113237:instance/i-0630f66e4c279c28d”],”detail”:{“instance-id”:”i-0630f66e4c279c28d”,”state”:”stopped”}}


If you wish to stop receiving notifications from this topic, please click or visit the link below to unsubscribe:
https://sns.us-east-2.amazonaws.com/unsubscribe.html?SubscriptionArn=arn:aws:sns:us-east-2:572311113237:CWAlarm:c4f5713e-1c6e-422b-bf52-2c13061a75b3&Endpoint=r.tarasevich860@gmail.com

Please do not reply directly to this email. If you have any questions or comments regarding this email, please contact us at https://aws.amazon.com/support

Challenge Lab #2 – Configure an Amazon EventBridge Rule that Sends an Automated Email by Using the Simple Notification Service (SNS)

Scenario:

I am a systems operations specialist responsible for an Amazon Web Services (AWS) environment. I need to monitor an Amazon Elastic Compute Cloud (Amazon EC2) instance and generate an email if the instance is stopped. First, I will create a new Amazon Simple Notification Service (Amazon SNS) topic, and then I will create an email subscription. Next, I will create an Amazon EventBridge rule to monitor my EC2 instance for state changes. Finally, I will stop the EC2 instance, and then I will verify that I received an email when the state changed.

  • Created an SNS topic.
  • Created an email subscription to the topic.
  • Created an EventBridge rule that is invoked when an EC2 instance is stopped and that uses an SNS topic as a target.
  • Tested the EventBridge rule by stopping an instance.
AWS Notifications <no-reply@sns.amazonaws.com>3:19 PM (6 minutes ago)
to me
  • You have chosen to subscribe to the topic:
    arn:aws:sns:us-east-2:101505747733:Topic-25862749
  • To confirm this subscription, click or visit the link below (If this was in error no action is necessary):
    Confirm subscription
  • Please do not reply directly to this email. If you wish to remove yourself from receiving all future SNS subscription confirmation requests please send an email to sns-opt-out
AWS Notifications <no-reply@sns.amazonaws.com>3:25 PM (1 minute ago)
to me