AWS – Using CloudWatch to trigger script on ec2 instance


I’ve found a lot of similar questions but none that seem to be specific to my question here: I have a python script that deletes old log files. I have Cloudwatch to monitor available storage, is it possible to trigger that script (IE, run this command: python when alarm is triggered.

From all my research this does not appear to be possible unless we developed a system that interpreted the emails sent by CloudWatch and SNS and then run a script based on that interpretation.

The goal is self-healing this issue when it alarms, but from what we’ve gathered it doesn’t appear to be possible that CloudWatch itself can trigger anything to happen on the EC2 instance. If this is true, I’m just looking for confirmation from people smarter than I!



CloudWatch, by itself, cannot run a command on your EC2 instance. You could however combine CloudWatch with some other AWS services to accomplish your goal. The way I would recommend accomplishing this is the following:

Leave a Reply