11 Oct

Add EC2 to ECS Cluster

I have had a lot of problems with ecs-agent always connecting to the “default” cluster rather than the one I want it to connect to. All the other instructions missed one vital step – removing ecs-agent from docker and reinstalling – that way it re-reads the ECS config file – without this step I could not get ecs-agent to connect to anything other than “default” cluster.

To put an EC2 ecs-agent into a specific cluster do the following:

Edit the ecs configuration file at /etc/ecs/ecs.config: sudo vi /etc/ecs/ecs.config
Add: ECS_CLUSTER=YourCluster
Close the editor “:wq”

Stop ecs-agent: sudo docker stop ecs-agent

Remove ecs-agent from docker: sudo docker rm ecs-agent

Remove the ecs-agent checkpoint file: sudo rm /var/lib/ecs/data/ecs_agent_data.jsonRead the rest