- Newest
- Most votes
- Most comments
Actually, figured it out.
Sequence of events:
- Deploy service1
- Deploy service2
- Connect to container in ECS service1 and try
curl http://service2:80
- this results incould not resolve host
- Connect to container in ECS service2 and try
curl http://service1:80
- it works - Restart service1 with
--force-new-deployment
and repeat step 3 - and now it works.
Apparently, ECS adds those ECS Service connect related records in /etc/hosts
. Line Service Connect configures DNS names for your services in the task itself, and doesn't require nor create DNS records in your hosted zones.
suggests this.
/etc/hosts
on service1 in step 3
127.0.0.1 localhost
10.0.20.61 ip-10-0-20-61.eu-west-2.compute.internal
127.255.0.1 service1
2600:f0f0:0:0:0:0:0:1 service1
/etc/hosts
on service2 in step 4
127.0.0.1 localhost
10.0.20.167 ip-10-0-20-167.eu-west-2.compute.internal
127.255.0.1 service1
2600:f0f0:0:0:0:0:0:1 service1
127.255.0.2 service2
2600:f0f0:0:0:0:0:0:2 service2
/etc/hosts
on service1 in step 5
127.0.0.1 localhost
10.0.20.13 ip-10-0-20-13.eu-west-2.compute.internal
127.255.0.1 service1
2600:f0f0:0:0:0:0:0:1 service1
127.255.0.2 service2
2600:f0f0:0:0:0:0:0:2 service2
Looks like ECS does not update /etc/hosts
dynamically when new endpoints are added into CloudMap namespace.
I know this is an old post but there is not much information out there so I thought I would append more information to this solution. I was encountering a similar issue using CloudFormation templates where one service was a client-server service and the others were client only. After stumbling upon this answer, I confirmed it worked in my instance. In order to ensure that it works without manual input, I changed the CloudFormation template to ensure that the client services were "DependsOn" with the client-server service. This allowed the Service Connect sidecar to get properly running since it updates the /etc/hosts file in the running container of all Service Connect services. Now, the client service has the values in the host file when it running.
Relevant content
- asked 8 months ago
- asked 7 months ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 2 months ago
- AWS OFFICIALUpdated a year ago