Home > Mobile >  Is there a way to dynamically assign a Fargate Container Public IP in CodeCommit Repository code?
Is there a way to dynamically assign a Fargate Container Public IP in CodeCommit Repository code?

Time:02-04

Is there a way to dynamically assign a Fargate Container Public IP in CodeCommit Repository code? I'm thinking of using a sort of variable.

Reason:

I have a Frontend Application (Node) and a Backend Application (openjdk) that run both in ECS Fargate Containers with a LB in front of the frontend.

Whenever I deploy the Backend ECS Fargate Container, a new Public IP will be assigned to it. This causes issues because I have a "host config" in the frontend where I have to add the IP of the backend in order for the APPs to communicate.

Is there any way I can fix this? I am open to any solution, because at the moment I do not have any ideas how to fix it.

I have thought about an output variable that can be inserted in the code under host config, but couldn't find anything. Also, as far as I read, there is no possibility to assign an Elastic IP the the Backend Task/Service in order for the ECS Fargate Container to have a persistent IP.

Thanks!

I have tried finding an optimal solution, but couldn't really find anyone with a similar issue.

CodePudding user response:

Both containers should be behind your load balancer, with path based routing to send the requests to the correct Fargate service.

You can't assign a static IP (AWS Elastic IP) to Fargate tasks, so the public IP is always going to change. ECS is really designed to use load balancers for any public access like this.

CodePudding user response:

@Mark B, thank you very much! I put the second container under the LB with the necessary configs and now it works (with DNS PORT configured in the host config file of the frontend app).

  • Related