20 C
Jaipur
Thursday, January 21, 2021

How to create a Cloudwatch Event Rule in AWS

Must read

A near-real-time stream of system events that describe changes in AWS resources is delivered by CloudWatch Events. We can create a rule that matches events and route them to one or more target functions. We can use CloudWatch Events to schedule automated actions. These actions can be self-triggered at certain times using cron or rate expressions. We can have EC2 instances, Lambda functions, Kinesis Data Streams, ECS tasks, Batch jobs, SNS topics, SQS queues, and a few more services as target endpoints for CloudWatch Events. To know more about Cloudwatch events, visit the official AWS documentation here.

In this document, we will see steps to create an Event Rule with the target as the SNS Topic. 

Pre-requisites

  1. AWS Account (Create if you don’t have one).
  2. SNS Topic(This will be a target to the Event Rule). 

What will we do?

  1. Login to AWS.
  2. Create an event rule in Cloudwatch.

Login to AWS

Click here to go to AWS Login Page.

When we hit the above link, we will see a web page as follows where we are required to log in using our login details.

Once you successfully login into AWS, you will see the main dashboard as follows. Click on “Service” at the left top.

AWS Console

Create an event rule in Cloudwatch

Once you click on “Services”, search for “Cloudwatch” and then click on the result to go to the Cloudwatch dashboard.

Search Cloudwatch

You will see the main dashboard of Cloudwatch as follows. You may or may not see Alarms. Since I already have a few alarms in my region, they are shown on the dashboard.

Click on the “Rules” in the left panel under “Events”.

Cloudwatch Console

Here, click on “Create rule” to create a new Event Rule.

EventRule Dashboard

Click on the “Schedule” radio button and specify a value in the text box in front of “Fixed rate of “. Here “Fixed rate of 5 minutes” means the event will be triggered every 5th minute.

You can choose any of the targets from the list of available options.

In this case, the target we have selected is an “SNS Topic” which will be triggered after every 5 minutes.

Click on “Configure details”.

Create a rule

Give a name and description to the event and click on “Create rule”.

configure a rule details

Once the rule is created, you can see it under the list of available rules.

When you no longer need the event rule, you can either disable the rule or delete it.

To delete the rule permanently, select the rule to be deleted and click on the “Actions” –> “Delete” button

Event rule dashboard

Click on the “Delete” button to confirm the deletion action.

Once the rule is deleted, it can not be restored. This will permanently delete the rule from the account.

Delete the rule

Conclusion

In this article, we saw the steps to create an Event Rule which will trigger an SNS Topic every 5 minutes. We also saw how the rule can be deleted.

Source link

- Advertisement -

More articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest article