eval
eval

Reputation: 1239

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:

screenshot of EC2 web console

where there's always a running instance.

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

enter image description here enter image description here

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

Upvotes: 4

Views: 3197

Answers (3)

João Nunes
João Nunes

Reputation: 11

As pointed out by Michael - sqlbot, the AWS Auto Scaling mechanisms are likely re-creating the instances to meet the initial configuration demands (e.g. 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!

Upvotes: 0

Sushil Dhayal
Sushil Dhayal

Reputation: 87

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

Upvotes: 0

Michael - sqlbot
Michael - sqlbot

Reputation: 178956

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.

Upvotes: 14

Related Questions