Skip to content

Access ECS Service from outside ECS (Public internet)

0

I have a service in ECS with the internal url: http://debug-executor-svc.devstage.internal.local:8082/ This service all other service can connect through the private network "devstage.internal.local" For debug purpose I need to access this service in ECS with public internet. What I have to change to access the service from outside?

1 Answer
3

I understand that you would like to access your ECS service, currently available at the internal URL http://debug-executor-svc.devstage.internal.local:8082/, from the public internet for debugging purposes.

Option 1: To connect to your ECS service, you first need to determine the launch type. If you're using the Fargate launch type, deploy the service in a public subnet with the Public IP option enabled. In this case, your ECS service subnets must have an Internet Gateway available, with a default route or routes to your public IP addresses pointing to the Internet Gateway. This setup allows you to access the Fargate task directly via its assigned public IP. For the EC2 launch type, ensure that your instance is launched with public IP access enabled in a public subnet. You can then use the same subnet in your ECS service to access the task using the instance's IP address and port.

Note: Ensure that the necessary IPs and ports are allowed in the respective security group and Network Access Control List (NACL) for the subnets. If you haven't mapped a domain, you can use the public IP address to access the service

For more information, refer to the following documents

  1. Amazon ECS Launch Types documentation.
  2. Add internet access to a subnet
  3. Security Group.
  4. Network ACLs.

Option 2: You can also deploy your ECS service behind an internet-facing or public Elastic Load Balancer (ALB/NLB). This will require you to redeploy your service and associate the load balancer during the service creation process.

For further details, see the Using Application Load Balancers with Amazon ECS documentation.

Note: You can access the service using the public domain of the Elastic Load Balancer (ELB) or its public IP address. Ensure that the ELB is deployed in a public subnet with an Internet Gateway and the necessary routes, while your ECS service can remain in a private subnet.

Option 3: If your ECS launch type is Fargate, consider using ECS Exec, which allows you to connect directly to the container (task). This feature leverages AWS Systems Manager (SSM) to provide direct access to the container for troubleshooting purposes.

For more information on this feature, check out the ECS Exec documentation.

Please let me know if you have any additional questions, or feel free to mark this as answered if I’ve provided the information you needed.

AWS

answered 2 years ago

EXPERT

reviewed 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.