When I go to EC2 console, I click one of:
- Shutdown
- Terminate
- Reboot
- Start
... I want to get a message on my "Director" machine, that the instance is e.g. booting, that it is shutting down, actually without need to poll all the statuses from the API.
The reason for this is, that I run my own Nagios monitoring with API, so I want director machine to receive / catch the event, and schedule the Down Time on Nagios.
Also, if it's "Terminate", the Director will update Chef server the way that it will remove the node.
Another reason for this is that polling the statuses very frequently is very limited to the API and I cant make continuous requests, but every 1-5 minutes. But this way, if I terminate the instance myself from the console, it takes too long for me to actually discover this information, and update other services accordingly.
Currently I am investigating that I could use the shutdown script on Linux instance, which would make remote API call to Director, and Director at the same time would be polling the statuses as well. However the best way would be to have a queue of the messages from EC2 directly without need to write additional APIs were there are reliable notifications about events on the instances.
I would really prefer to use AWS functionality to do it, except for Nagios.
AWS has recently introduced a feature that addresses this - CloudWatch Events: https://aws.amazon.com/blogs/aws/new-cloudwatch-events-track-and-respond-to-changes-to-your-aws-resources/
You're going to need to handle this on your own. There's no way to add this type of hooks to AWS API actions.
Instead of using the AWS control panel, just perform all of these actions programmatically, via a scripting language of your choice. Then you can make sure to prep your environment however you need before calling the AWS API.