#6341·spinnaker

Terminating EC2 Instance in ASG without Shrinking ASG

Author: karlskewesCreated Feb 18, 2021Updated Jul 26, 2026
Labelsenhancementprovider/awsno-lifecycle

Issue Summary:

When terminating EC2 instances via the AWS Console or API's there are generally 2 options.

  1. Terminate EC2 immediately, this is available for raw EC2 and ASG EC2 Instances. This does not trigger any termination lifecycle hook.
  2. Terminate EC2 in ASG, this is only for ASG EC2 instances and will trigger any termination lifecycle hook configured.

Both options have their use case. This issue is about the second case, terminating EC2 Instances in an ASG.

Currently the UI has a:

  1. Terminate instance option which uses raw EC2 termination - not honouring lifecycle hooks. https://github.com/spinnaker/clouddriver/blob/c9c9608b58d9c48ccd6545c9acdb632ebaa67c1f/clouddriver-aws/src/main/groovy/com/netflix/spinnaker/clouddriver/aws/deploy/ops/TerminateInstancesAtomicOperation.groovy#L18

  2. Terminate and shrink ASG option which uses ASG termination and honours lifecycle hooks. https://github.com/spinnaker/clouddriver/blob/c9c9608b58d9c48ccd6545c9acdb632ebaa67c1f/clouddriver-aws/src/main/groovy/com/netflix/spinnaker/clouddriver/aws/deploy/ops/TerminateInstanceAndDecrementAsgAtomicOperation.groovy#L22

Option 1 is useful when the instance can be destroyed without customer impact.

Option 2 is safer as it will engage any lifecycle hook and drain customer sessions. However we don't always want to shrink the ASG. It would be nice to be able to select in the UI whether we want to use withShouldDecrementDesiredCapacity(Boolean shouldDecrementDesiredCapacity) or not per Javadoc - TerminateInstanceInAutoScalingGroupRequest.

Perhaps add a new option Terminate in Autoscaling Group:

  1. Terminate << unchanged
  2. Terminate in Server Group << new option
  3. Terminate and Shrink Server Group << unchanged

Are we open to a PR? And do I need to plumb through Clouddriver <- Gate <- Deck ?

Cloud Provider(s):

AWS EC2

Environment:

Spinnaker 1.24.2 on Kubernetes

Feature Area:

UI, possibly pipelines

Description:

Steps to Reproduce:

  1. deploy AWS EC2 ASG
  2. navigate to Infrastructure -> Clusters
  3. select an instance and click Instance Actions
  4. choose Terminate and Shrink Server Group