Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Register an instance to an AWS ECS cluster

I created an EC2 instance on AWS to use as an ECS instance. I followed these steps here to do that.

I also created a new Cluster under ECS but for some reasons, I cannot see the instance under the cluster:

enter image description here

Any ideas on what might be the issue here?

like image 243
tugberk Avatar asked Mar 13 '23 09:03

tugberk


2 Answers

I found the missing piece. It was stated here as part of 10th item on the list that:

By default, your container instance launches into your default cluster. If you want to launch into your own cluster instead of the default, choose the Advanced Details list and paste the following script into the User data field, replacing your_cluster_name with the name of your cluster.

like image 51
tugberk Avatar answered Mar 20 '23 01:03

tugberk


I would strongly suggest letting ECS Cluster create its own EC2 Instance(s), especially if you are new to this. You can define the type of instance that you want when you create the cluster and everything will magically work.

Doing it the other way around (EC2 Instance first, then feeding/attaching it into the Cluster) might sound quite natural to you, but it means that you have to handle a lot of things by yourself. You have to manually spend time on

  • Making sure you pick the right AMI (ecs-optimized),
  • Making sure the VPC-Subnets are right,
  • Making sure the architecture is right (e.g. t4g medium instances don't take x86 containers),
  • Making sure the Cluster Name is in /etc/ecs/ecs.config and then after that restart docker & ecs-agent.
  • Making sure ecs-agent is properly set up and connecting,
  • ... and blah blah blah.

Maybe, and hopefully, in future they will add an "attaching this EC2 Instance to that Cluster" button that does all these chores. But until then, save yourself this list of headaches and try to get the instance created by the cluster.

like image 39
Aidin Avatar answered Mar 20 '23 01:03

Aidin