CloudFormation template related to this blog published on the AWS Infrastructure & Automation blog
This is a sample solution using Amazon EC2 Auto Scaling Lifecycle Hooks to perform any desired actions before terminating the instance within the Auto Scaling group. lifecycle hook puts the instance in Terminating:Wait
status. The Terminating:Wait
status will be monitored by an Amazon CloudWatch event, which triggers an AWS Systems Manager automation document to perform the action you want.
The CloudFormation template RunSSMAutomationBeforeTermination.json will go through the following steps:
For more details about launching a stack, refer to Creating a Stack on the AWS CloudFormation Console.
The stack template includes the following parameters:
Parameter | Required | Description |
---|---|---|
AutoScalingGN | Yes | Enter the name of the auto scaling group to monitor and add the lifecycle hook. |
DomainUserName | Yes | The name of the String parameter for the DomainUser. The user would need to have enough permissions to remove the computer from the domain. |
DomainPassword | Yes | The name of the SecureString parameter that have the password of DomainUserName. |
ExistingAutomationAssumeRole | No | The ARN of AWS Systems Manager Automation assume role. If not specified, the template will create a role with minimum permissions as describe in the blog. |
ExistingCloudWatchEventRole | No | The Role ARN to be used by CloudWatch event to trigger the AWS Systems Manager Automation execution.If not specified, the template will create a role with minimum permissions as describe in the blog. |
See CONTRIBUTING for more information.
This library is licensed under the MIT-0 License. See the LICENSE file.