AWS – Amazon EC2 Auto Scaling instance lifecycle states are now available via the Instance Metadata Service
Amazon EC2 Auto Scaling now publishes Auto Scaling instance lifecycle states in the Amazon EC2 Instance Metadata Service (IMDS), enabling you to easily initiate on-instance actions as an instance transitions from one lifecycle state to another. Instances in an Auto Scaling group transition through various lifecycle states from the time they are launched and placed in service to when they are removed from service and terminated. By polling IMDS, you can setup your on-instance application to easily determine its lifecycle state without having to setup Amazon CloudWatch Events or other services.
Read More for the details.