Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change Instance type of a cluster registered ec2 instance

I have an Amazon EC2 instance which is registered to a cluster of Amazon ECS.

And I want to change this instance's type from c4.large to c4.8xlarge.

I'm able to change its type from c4.large to c4.8xlarge in AWS console. But after the change, I found

[ERROR] Could not register module="api client" err="ClientException: Container instance type changes are not supported. Container instance XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX was previously registered as c4.large.

being printed in /var/log/ecs/ecs-agent.log.20XX-XX-XX-XX file.

Is it possible to change ec2 instance type and re-register it to a cluster?

I think maybe deregister it first, then register it again should work. But I'm afraid this may cause something irreversible in my AWS working environment. So I haven't tried this method yet.

like image 673
Brian Avatar asked Aug 23 '16 04:08

Brian


1 Answers

To solve this connection problem between the agent and cluster, just delete the file /var/lib/ecs/data/ecs_agent_data.json and restart docker and ECS. After that, a new container instance will be created in your cluster with the new size.

sudo rm /var/lib/ecs/data/ecs_agent_data.json
sudo service docker restart
sudo start ecs

Then you can go to the ECS cluster console and deregister the old container instance

UPDATE: According to @florins and @MBear commented below, AWS updated the data file on ECS instances.

sudo rm /var/lib/ecs/data/agent.db
sudo service docker restart
sudo start ecs
like image 109
Icaro M. Bichir Avatar answered Oct 14 '22 19:10

Icaro M. Bichir