Getting Started: Amazon CloudWatch Events
I am a serverless enthusiast.
The Covid-19 lockdown and meetups subsequently going online presented me with an opportunity to attend some really awesome meetups held in all parts of the world.
I especially enjoyed #AWSSWalesUG not only because of how welcoming this group is but also because of the never-ending supply of serverless talks.
I was for the first time, introduced to Amazon Eventbridge while attending a couple of this group’s meetups.
What interested me during a couple of the talks, was learning about the close relationship between Amazon Eventbridge and Amazon CloudWatch Events — that they both use the same underlying services and API, with Eventbridge providing more features.
I have started experimenting with Eventbridge; for this article, however, I will focus on CloudWatch Events as a start.
What is Amazon CloudWatch Events?
CloudWatch Events help you configure and deliver near-real-time streams of events that describe changes in your AWS resources.
The following services can be configured as targets for your CloudWatch Events:
Amazon CloudWatch Events in action
My use case is to track and report whenever a new EC2 instance is launched.
Amazon CloudWatch Events made it so easy to set this up.
For the use case, SNS was chosen as the target. I therefore created an Amazon SNS Topic EC2Launched as seen in Figure 3, to send an email notification when an EC2 instance is launched.
Creating the event followed a few, very quick steps:
Depicted above is the following:
- Event Type: EC2 Instance State-change Notification — this is the event that is being tracked and will be reported on
- State: Running — this is from a list of valid states of EC2 (e.g. Pending, Running, Stopped, Terminated, etc.)
- Target: The service as seen in Figure 2, that will be the target for this rule. Here the target is the SNS topic EC2Launched created in Figure 3.
The next time that an EC2 was launched, with the instance state as shown in Figure 4 (running),
The following notification was sent to the email as specified in the SNS Topic:
It was that simple, quick, and fun, and I’m looking forward to more use cases where I can start experimenting with other targets that are available.
Reference:
MyCloudSeries is a training and consulting firm with expertise in Cloud Computing and DevOps. We assist organizations in their DevOps strategies, transformation, and implementation. We also provide Cloud Computing Support contact us at www.mycloudseries.com