How do I remove a terminated EC2 instance from my Auto Scaling group?
"I have a terminated Amazon Elastic Compute Cloud (Amazon EC2) instance. However, the instance shows as healthy (Healthy) and in the standby state (InStandby) in the Amazon EC2 console."
"I have a terminated Amazon Elastic Compute Cloud (Amazon EC2) instance. However, the instance shows as healthy (Healthy) and in the standby state (InStandby) in the Amazon EC2 console.Short descriptionEC2 Auto Scaling doesn’t perform health checks for instances in the standby state. EC2 Auto Scaling isn’t aware of instance terminations for instances in standby.Use one of the following methods to remove terminated instances from your EC2 Auto Scaling group that are still listed as Healthy and InStandby:Use the AWS Command Line Interface (AWS CLI) to terminate the instance.Detach the instance from your EC2 Auto Scaling group to remove it from the EC2 Auto Scaling console.Take the instance out of InStandby to allow Auto Scaling to use health checks to discover the instance termination.ResolutionNote: If you receive errors when running AWS CLI commands, make sure that you're using the most recent version of the AWS CLI.Terminate the instanceRun the following command to terminate your instance. Replace YOUR-INSTANCE-ID with your instance's resource ID.aws autoscaling terminate-instance-in-auto-scaling-group --instance-id YOUR-INSTANCE-ID --no-should-decrement-desired-capacityImportant: If you configured the lifecycle hook EC2_INSTANCE_TERMINATING for your EC2 Auto Scaling group, then use CompleteLifecycleAction to immediately remove the instance from the group.Detach the instanceRunt he following command to detach your instance from the EC2 Auto Scaling group. Replace YOUR-INSTANCE-ID with your instance's resource ID and YOUR_ASG_NAME with your EC2 Auto Scaling group's name.aws autoscaling detach-instances --instance-ids YOUR-INSTANCE-ID --no-should-decrement-desired-capacity --auto-scaling-group-name YOUR-ASG-NAMETake the instance out of standby1.    Use the AWS CLI or the Amazon EC2 console to edit your EC2 Auto Scaling group’s maximum size. When you put the instance back into service, the desired capacity is incremented by one and must not exceed the maximum size value for the group. Set the maximum size to the current value + the number of instances being returned to service (1), or you might receive an error similar to the following one:An error occurred (ValidationError) when calling the ExitStandby operation: AutoScalingGroup YOUR-ASG-NAME has min-size=1, max-size=1, and desired-size=1. To place in service 1 instance, please update the AutoScalingGroup sizes appropriately.Note: After your you terminate your instance, Amazon EC2 launches a replacement instance to match the desired capacity.2.    Take your instance out of standby using the following command. Be sure to replace YOUR-INSTANCE-ID with your instance's resource ID and YOUR_ASG_NAME with your EC2 Auto Scaling group's name.aws autoscaling exit-standby --instance-ids YOUR-INSTANCE-ID --auto-scaling-group-name YOUR-ASG-NAMERelated informationTemporarily remove instances from your Auto Scaling groupFollow"