Run code before terminating an EC2 Auto Scaling instance Learn how to create an AWS CloudFormation template that runs code prior to terminating an EC2 Auto Scaling instance.