AWS: Terminate an EC2 Instance Belonging to an ASG

Description

Terminate an EC2 instance that belongs to an Auto Scaling Group (ASG). You can choose whether to decrement the ASG's desired capacity when the instance is terminated. This action is useful for:

  • Completing an instance-rotation runbook after the instance has been moved to Standby and a replacement is in service
  • Removing an unhealthy or problematic instance from the group and optionally letting the ASG launch a replacement (when Should Decrement Desired Capacity is false)
  • Automating termination as part of a multi-step workflow that includes Describe Auto Scaling Instances, Set Instance Protection, Enter Standby, and a delay
  • Recording the termination activity (activity ID, cause, description, status) for audit or incident notes

Instructions

Inputs

NameDescription
IntegrationSelect a Workflow Integration or click New AWS Connection to establish a new one.
Instance IDThe EC2 instance ID to terminate. Must be an instance that belongs to an Auto Scaling Group.
AWS RegionThe AWS region where the instance and ASG are located. If left blank, the action uses us-east-1 as the default.
Should Decrement Desired CapacityWhether to reduce the ASG's desired capacity when this instance is terminated. Default: false. Set to false when a replacement is already in service (e.g., after Enter Standby and a delay); set to true to shrink the group.

Outputs

NameDescription
ActivityJSON object for the Auto Scaling activity: activityId, cause, description, statusCode, startTime, endTime (null until the activity completes). Use this for incident notes or audit.
ResultWhether the action succeeded: Success or Failed.
Result SummaryBrief description of what the action did or if it failed.
ErrorError message, if the action failed.
📘

Tips

  • Instance Rotation: In a rotate-instance runbook, run Enter Standby and a Delay step first so a replacement instance is in service before terminating. Use Should Decrement Desired Capacity = false so the group size stays the same.
  • Field References: Reference the Instance ID from Auto Scaling: Describe Auto Scaling Instances (e.g., instances[0].instanceId) or from the incident's custom details so the workflow works when triggered by an alert.