Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I associate an Elastic IP with a Fargate container?

Tags:

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?

like image 326
Gabe Durazo Avatar asked Dec 19 '17 19:12

Gabe Durazo


People also ask

How do I associate AWS Elastic IP?

To associate an Elastic IP address with an instance Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/ . In the navigation pane, choose Elastic IPs. Select an Elastic IP address and choose Actions, Associate address. Select the instance from Instance and then choose Associate.

How do I assign an Elastic IP to an instance?

Click the Elastic IPs link in the EC2 Dashboard. Click Allocate New Address and choose VPC or EC2 from the drop-down list, depending whether you're going to associate this IP with an instance in Amazon EC2-Virtual Private Cloud (VPC) or Amazon EC2-Classic, respectively. Click Yes, Allocate to confirm your choice.

Can you ssh into fargate container?

I can confirm, yes you can SSH into a Fargate container by running sshd and properly configuring the security group.


2 Answers

Actually your can do it with Network Load balancer. It 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

like image 128
user2105282 Avatar answered Oct 21 '22 10:10

user2105282


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.

like image 35
Greg Perry Avatar answered Oct 21 '22 10:10

Greg Perry