简体   繁体   中英

Unable to delete EC2 instance for ECS(EC2 Container Service)

As Amazon ECS being launched recently, I tried to start a sample with it. It looks like ECS will create a EC2 instance as a "cluster" for ECS, whose name is like "ECS Instance - EC2ContainerService-default-e40c3e79-1d27-4512-a790-c6782b45b15a". However, I cannot find a way to delete this EC2 instance when I don't want to serve my container any more.

When I terminate this instance through web console, another instance with the same name(but different instance id) will show up later. It's quite annoying and has already charged my some money. Here's the screenshot of EC2 web console:

EC2 Web控制台的屏幕截图

where there's always a running instance.

Here's my screenshot of ECS web console, where I have deleted all the cluster.

在此处输入图片说明 在此处输入图片说明

At this point, I can't find any documentation or blog on this issue. :(

Note

If your instance is maintained by an Auto Scaling group or AWS CloudFormation stack, terminate the instance by updating the Auto Scaling group or AWS CloudFormation stack; otherwise, the Auto Scaling group will recreate the instance after you terminate it.

http://docs.aws.amazon.com/AmazonECS/latest/developerguide/deregister_container_instance.html

Auto Scaling groups can be found in the the EC2 console navigation pane: under Auto Scaling, click Auto Scaling Group.

If you have created the instance using Elastic Beanstalk. Then you should follow the below link to terminate this permanently.

https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features.terminating.html

As pointed out by Michael - sqlbot, the AWS Auto Scaling mechanisms are likely re-creating the instances to meet the initial configuration demands (eg ECS clusters).

One of the options to prevent this from happening is to update the auto-scaling group to 0 instances by issuing,

aws autoscaling update-auto-scaling-group --auto-scaling-group-name modify-this-with-auto-scaling-group-name --min-size 0 --max-size

and to further, if the auto-scaling group is not required, delete the auto-scaling group, by issuing,

aws autoscaling delete-auto-scaling-group --auto-scaling-group-name modify-this-with-auto-scaling-group-name

Hope it helps!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM