I want to allow the tasks in my Amazon Elastic Container Service (Amazon ECS) services to communicate with each other.
Short description
You can use Amazon ECS Service Connect or service discovery to allow your tasks to communicate with each other. It's a best practice to use ECS Service Connect which provides Amazon ECS configuration for service discovery, connectivity, and traffic monitoring. Service discovery helps manage HTTP and DNS namespaces for your Amazon ECS services.
Note: Service Connect isn't compatible with Host network mode. Service discovery supports the A and SRV DNS record types. DNS records are automatically added or removed as tasks start or stop in the Amazon ECS service.
Resolution
To determine the option that fits your architecture, see Interconnecting services.
Use Service Connect
Note: If you receive errors when you run AWS Command Line Interface (AWS CLI) commands, then see Troubleshoot AWS CLI errors. Also, make sure that you're using the most recent AWS CLI version.
Before you use Service connect, see Service Connect considerations. Use either the Amazon ECS console or the AWS CLI to configure Service Connect.
Important: After you have configured service connect, use the endpoint URL to connect with other service within the same namespace.
Use service discovery
Before you use service discovery, see Service discovery considerations. Use either the Amazon ECS console or the AWS CLI to configure service discovery.
Important: After you configure service discovery, use the YourServiceDiscoveryServiceName.YourServiceDiscoveryNamespace format to query DNS records for a discovery service within your Amazon Virtual Private Cloud (Amazon VPC).