Menu
Auto Scaling
User Guide

Temporarily Removing Instances from Your Auto Scaling Group

Auto Scaling enables you to put an instance that is in the InService state into the Standby state, update or troubleshoot the instance, and then return the instance to service. Instances that are on standby are still part of the Auto Scaling group, but they do not actively handle application traffic.

Important

You are billed for instances that are in a standby state.

For example, you can change the launch configuration for an Auto Scaling group at any time, and any subsequent instances that the Auto Scaling group launches use this configuration. However, the Auto Scaling group does not update the instances that are currently in service. You can either terminate these instances and let the Auto Scaling group replace them, or you can put the instances on standby, update the software, and then put the instances back in service.

How the Standby State Works

The standby state works as follows to help you temporarily remove an instance from your Auto Scaling group:

  1. You put the instance into the standby state. The instance remains in this state until you exit the standby state.

  2. If there is a load balancer or target group attached to your Auto Scaling group, the instance is deregistered from the load balancer or target group.

  3. By default, Auto Scaling decrements the desired capacity of your Auto Scaling group when you put an instance on standby. This prevents Auto Scaling from launching an additional instance while you have this instance on standby. Alternatively, you can specify that Auto Scaling does not decrement the capacity. This causes Auto Scaling to launch an additional instance to replace the one on standby.

  4. You can update or troubleshoot the instance.

  5. You return the instance to service by exiting the standby state.

  6. Auto Scaling increments the desired capacity when you put an instance that was on standby back in service. If you did not decrement the capacity when you put the instance on standby, Auto Scaling detects that you have more instances than you need, and applies the termination policy in effect to reduce the size of your Auto Scaling group. For more information, see Controlling Which Instances Auto Scaling Terminates During Scale In.

  7. If there is a load balancer or target group attached to your Auto Scaling group, the instance is registered with the load balancer or target group.

The following illustration shows the transitions between instance states in this process:


                    Instances enter and exit the standby state.

For more information about the complete lifecycle of instances in an Auto Scaling group, see Auto Scaling Lifecycle.

Health Status of an Instance in a Standby State

Auto Scaling does not perform health checks on instances that are in a standby state. While the instance is in a standby state, its health status reflects the status that it had before you put it on standby. Auto Scaling does not perform a health check on the instance until you put it back in service.

For example, if you put a healthy instance on standby and then terminate it, Auto Scaling continues to report the instance as healthy. If you return the terminated instance to service, Auto Scaling performs a health check on the instance, determines that it is unhealthy, and launches a replacement instance.

Temporarily Remove an Instance Using the AWS Management Console

The following procedure demonstrates the general process for updating an instance that is currently in service.

To temporarily remove an instance using the console

  1. Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.

  2. On the navigation pane, under Auto Scaling, choose Auto Scaling Groups.

  3. Select the Auto Scaling group.

  4. On the Instances tab, select the instance.

  5. Choose Actions, Set to Standby.

  6. On the Set to Standby page, select the checkbox if you want Auto Scaling to launch a replacement instance, or leave it unchecked to decrement the desired capacity. Choose Set to Standby.

  7. You can update or troubleshoot your instance as needed. When you have finished, continue with the next step to return the instance to service.

  8. Select the instance, choose Actions, Set to InService. On the Set to InService page, choose Set to InService.

Temporarily Remove an Instance Using the AWS CLI

The following procedure demonstrates the general process for updating an instance that is currently in service.

To temporarily remove an instance using the AWS CLI

  1. Use the following describe-auto-scaling-instances command to identify the instance to update:

    Copy
    aws autoscaling describe-auto-scaling-instances

    The following is an example response:

    {
        "AutoScalingInstances": [
            {
                "AvailabilityZone": "us-west-2a",
                "InstanceId": "i-5b73d709",
                "AutoScalingGroupName": "my-asg",
                "HealthStatus": "HEALTHY",
                "LifecycleState": "InService",
                "LaunchConfigurationName": "my-lc"
            },
            ...
        ]
    }
  2. Move the instance into a Standby state using the following enter-standby command. The --should-decrement-desired-capacity option decreases the desired capacity so that Auto Scaling does not launch a replacement instance.

    Copy
    aws autoscaling enter-standby --instance-ids i-5b73d709 --auto-scaling-group-name my-asg --should-decrement-desired-capacity

    The following is an example response:

    {
        "Activities": [
            {
                "Description": "Moving EC2 instance to Standby: i-5b73d709",
                "AutoScalingGroupName": "my-asg",
                "ActivityId": "3b1839fe-24b0-40d9-80ae-bcd883c2be32",
                "Details": "{\"Availability Zone\":\"us-west-2a\"}",
                "StartTime": "2014-12-15T21:31:26.150Z",
                "Progress": 50,
                "Cause": "At 2014-12-15T21:31:26Z instance i-5b73d709 was moved to standby 
                  in response to a user request, shrinking the capacity from 4 to 3.",
                "StatusCode": "InProgress"
            }
        ]
    }
  3. (Optional) Verify that the instance is in Standby using the following describe-auto-scaling-instances command:

    Copy
    aws autoscaling describe-auto-scaling-instances --instance-ids i-5b73d709

    The following is an example response. Notice that the status of the instance is now Standby.

    {
        "AutoScalingInstances": [
            {
                "AvailabilityZone": "us-west-2a",
                "InstanceId": "i-5b73d709",
                "AutoScalingGroupName": "my-asg",
                "HealthStatus": "HEALTHY",
                "LifecycleState": "Standby",
                "LaunchConfigurationName": "my-lc"
            }
        ]
    }
  4. You can update or troubleshoot your instance as needed. When you have finished, continue with the next step to return the instance to service.

  5. Put the instance back in service using the following exit-standby command:

    Copy
    aws autoscaling exit-standby --instance-ids i-5b73d709 --auto-scaling-group-name my-asg

    The following is an example response:

    {
        "Activities": [
            {
                "Description": "Moving EC2 instance out of Standby: i-5b73d709",
                "AutoScalingGroupName": "my-asg",
                "ActivityId": "db12b166-cdcc-4c54-8aac-08c5935f8389",
                "Details": "{\"Availability Zone\":\"us-west-2a\"}",
                "StartTime": "2014-12-15T21:46:14.678Z",
                "Progress": 30,
                "Cause": "At 2014-12-15T21:46:14Z instance i-5b73d709 was moved out of standby in
                   response to a user request, increasing the capacity from 3 to 4.",
                "StatusCode": "PreInService"
            }
        ]
    }
  6. (Optional) Verify that the instance is back in service using the following describe-auto-scaling-instances command:

    Copy
    aws autoscaling describe-auto-scaling-instances --instance-ids i-5b73d709

    The following is an example response. Notice that the status of the instance is InService.

    {
        "AutoScalingInstances": [
            {
                "AvailabilityZone": "us-west-2a",
                "InstanceId": "i-5b73d709",
                "AutoScalingGroupName": "my-asg",
                "HealthStatus": "HEALTHY",
                "LifecycleState": "InService",
                "LaunchConfigurationName": "my-lc"
            }
        ]
    }