- Newest
- Most votes
- Most comments
You can connect your tasks to internet using either public subnet and internet gateway (with public IP) or private subnet and NAT gateway. The public IP is required to be able to reach out public internet endpoints.
If the selected subnet is a private subnet, the NAT gateway (which has a public IP on its interface attached on public subnet) will allow your task running on this private subnet to reach out to internet endpoints.
To ilustrate:
Using a public subnet and internet gateway
Using a private subnet and NAT gateway
Please refer this Best Practices documentation to read more about Connecting your ECS tasks to the internet.
I assume the LB is in the public subnet for the services configured in fargate. You don't want the fargate pods to have public IP but also want those pods to connect outbound on the internet.
In that case launch the fargate pods in private subnet where the outbound traffic is routed via NAT. That should suffice for your requirement.
Any instance without public IP but launched in public subnet wont have outbound connection to internet. So the behaviour you are observing is normal
--Syd
Relevant content
- Accepted Answerasked 2 months ago
- AWS OFFICIALUpdated 6 months ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 10 days ago