I'm trying to setup a scheduled task with ECS Fargate.Task was dockerized and will be run through AWS ECS with Fargate. Unfortunately the service I want to run needs to access an API of a partner where the IP needs to be whitelisted. I see that for each execution of the task with Fargate a new ENI with an different IP is assigned.
How is it possible to assign a static IP to a AWS ECS Fargate Task?
CodePudding user response:
In order to assign a Static IP on your AWS Fargate task, you will have to create a static IP address (AWS calls this elastic IP) that will serve as the origin address of traffic originating your VPC from network outsiders point of view. To implement this:
You need the following
- A VPC
- 1x Private Subnet
- 1x Public Subnet
- 1x Internet Gateway attached to public subnet
- An elastic IP (Will serve as static IP of all resources inside the private subnets)
- 1x NAT Gateway
- A route table attached to
privatesubnet with route0.0.0.0/0pointing to the NAT Gateway - A route table attached to
publicsubnet with route0.0.0.0/0pointing to the internet gateway
You will then need to make sure that:
- Your ECS Fargate task is using the VPC mentioned above
- And that the private subnet(s) mentioned above is selected as the
service task placement
If my explanation is still confusing, you could try giving this guide a read.
