I'm exploring using the new Fargate option for my ECS containers. One constraint is that the running task must always be accessible at the same Public IP address.
My first thought was to allocate an Elastic IP but I can't tell what to associate it to. It seems an Elastic IP can be associated to an instance (which is irrelevant for Fargate) or a Network Interface. However, if I associate it with an ENI, I can't see how to ensure my task's container has that Network Interface. When creating a Service, I see that I can put it in a VPC, but that's it.
From experimentation, if I kill a task so that the service restarts a new one, or if I update the service to run a new task revision - the container that starts running the new task will have a new ENI each time.
Is there some way to ensure that a given service has the same public IP address, even if its tasks are killed and restarted?
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 you can use a static IP address with Fargate is via the Application Load Balancer with an alias.