Home > Software engineering >  ECS Fargate - Can a container access its own Public IP address
ECS Fargate - Can a container access its own Public IP address

Time:04-13

I am deploying JVM applications in Fargate. I need to be able to determine the public IP address within the application. Is this directly possible at all? I have tried the task metadata endpoints, but only seem to be able to access the private IP address.

Many thanks in advance

CodePudding user response:

The easiest way would be to use an external service, such as curl ifconfig.me. If you don't like doing that you can get TaskARN from the tesk metadata. Once you have the arn, you can use AWS SDK/CLI to get ENI id of your task using describe-tasks api call, and then query the ENI to get its public Ip using describe-network-interfaces.

  • Related