How to bind Elastic IP to a Fargate container?

I am exploring the use of the new Fargate option for my ECS containers. One limitation is that a working task should always be available at the same public IP address.

My first thought was to allocate Elastic IP, but I can’t say what to associate it with. It seems that Elastic IP can be connected to an instance (which is not related to Fargate) or to a network interface. However, if I associate it with ENI, I don’t see how to ensure that my task container has this network interface. When creating a service, I see that I can put it in a VPC, but what is it.

From an experiment, if I kill a task so that the service restarts a new one, or if I update the service to start a new revision of the task, the container that starts the new task will each time have a new ENI.

Is there a way to ensure that this service has the same public IP address, even if its tasks are killed and restarted?

+5
source share
2 answers

Fargate does not currently support ENI assignment, so it is not possible to have an Elastic IP associated with a Fargate task definition.

The only way to use a static IP address with Fargate is to use application load balancing with an alias.

+3
source

Actually, you can do this by balancing network load. This is a special type of load balancer where elastic IP can be added. This instruction can really help https://docs.aws.amazon.com/elasticloadbalancing/latest/network/introduction.html

-1
source

Source: https://habr.com/ru/post/1274202/


All Articles