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
.