ECS cluster has no ecs instances but two ecs instances are visible in EC2
I am trying to create a very simple cluster in sydney region.
It is a very straightforward setup. I specified the harddisk to be 60G. I want to have two ec2 instances in the cluster.
They show up as expected in ec2 panel.
However the ec2 instances are not showing up in the ecs cluster page:
1) Why It happens?
2) Is there any logging I can examine to find out the underlying problem?
Solution 1:
You indicated in your comment that the instances have no public IP addresses. I'm extrapolating from that comment that your instances likely have no route to the Internet as well.
In order to use ECS, your instances need to have a route to reach (at a minimum) the ECS service endpoints. A route to the Internet can be through an Internet Gateway (IGW), Network Address Translation (NAT), or through an HTTP Proxy. Without a route to reach the ECS service endpoints, the ECS agent will be unable to register itself into your cluster and you will be unable to use those instances with ECS.
Solution 2:
Fixed the issue by following the following two steps:
1) Make sure 'auto-assign public IPv4 address' is enabled
2) Create and attached a gateway to the VPC. Then add a route to the gateway.
Solution 3:
are you using an ecs optimized
ami?
i would do that and then include this in your user-data when you spawn the instance
#!/bin/bash
echo ECS_CLUSTER=your-cluster-name >> /etc/ecs/ecs.config
if you ssh onto the box, you should be able to see it register with the cluster then in the ecs agent docker logs
eg.
[ec2-user@ip-10-0-X-XXX ~]$ docker logs my-ecs-agent-container-id
---snip----
2019-04-23T20:46:19Z [INFO] Registered container instance with cluster!
2019-04-23T20:46:19Z [INFO] Registration completed successfully. I am running as 'arn:aws:ecs:us-west-2:XXXXXXX:container-instance/xxxxx-yyyy-zzz-ddd-12345gdd' in cluster 'your-cluster'
---snip----