Using Input Transformer while using SNS as CloudWatch Event Target
In this post, we’ll see how we can use Input Transformer while using SNS as CloudWatch Event target. This makes the mail we receive from SNS more readable.
Step 1: Create an SNS topic and subscription.
Step 2: Create a CloudWatch rule to get a notification whenever an instance state is changed. Set your SNS topic as target and under Configure input, select Input Transformer, and in the first text box, paste the following data to create some input variables.
Now in the second text box, paste the following data which uses the variable we created to construct the actual message which SNS will send.
"An EC2 have just been" :<state>,
"Instance State" : <state>,
"Time of event" : <time>,
"AWS Region" : <region>,
"AWSAccount" : <account>,
"Please take a look if you where not expecting any instance": <state>
Step 3: Now our setup is ready and we can test it by launching a few instances or starting/stopping an already existing instance.
Once the CloudWatch rule is triggered, you should be getting a mail like this:
👋 Join us today !!
If this post was helpful, please click the clap 👏 button below a few times to show your support! ⬇