snippetMinor
How to move EC2 instance to another ECS cluster
Viewed 0 times
ecsec2moveinstanceanotherhowcluster
Problem
Assume I have two clusters
How to remove an EC2 instance (ecs-optimized amazon-linux) from
devcluster and qacluster on ECS. How to remove an EC2 instance (ecs-optimized amazon-linux) from
qacluster and add to devcluster?Solution
You need to follow these steps:
To make sure it uses correct cluster, check logs -
- Set
ECS_CLUSTER=devclusterin/etc/ecs/ecs.config
- Stop all tasks/containers
- Remove checkpoint file -
/var/lib/ecs/data/ecs_agent_data.json
- Start ECS agent again as explained here - https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-agent-install.html
To make sure it uses correct cluster, check logs -
docker logs ecs-agent. It should have a message like:[INFO] Registration completed successfully. I am running as 'arn:aws:ecs:eu-west-1:ACCOUNT_ID:container-instance/CLUSTER_ID' in cluster 'devcluster'Code Snippets
[INFO] Registration completed successfully. I am running as 'arn:aws:ecs:eu-west-1:ACCOUNT_ID:container-instance/CLUSTER_ID' in cluster 'devcluster'Context
StackExchange DevOps Q#2048, answer score: 6
Revisions (0)
No revisions yet.