问题
I have a set of instances running within an ELB and an API to stop/ start any of those instance developed using java SDKs.
However the instances are getting terminated as soon as it goes to stopped state, which i don't want to happen. Is this a known behavior and is there a way to stop this from happening and to keep these instances in the stopped state?
回答1:
Instances are terminated if they are associated with an auto scaling group
Check this Instance Termination in autoscaling groups for more details.
You can detach the instance from the autoscaling group using the AWS JAVA SDK
Detatch Instances Request Detach them first and then stop the instance to prevent termination.
If you do not specify the option to decrement the desired capacity, Auto Scaling launches instances to replace the ones that are detached. So keep that in mind.
来源:https://stackoverflow.com/questions/50128185/stopping-ec2-instance-in-an-elb-using-java-sdk