By using AWS re:Post, you agree to the Terms of Use

ECS Fargate - How to get IP Address


Hi All,

I am running an ECS Cluster for our Kafka Connect Images and have a working configuration deployed. To scale up Kafka Connect one of the things you need to do for each container is ensure that the Kafka Connect Rest Hostname is set to prevent a 409 Conflict when adding tasks (if you are running as part of a cluster). Using localhost is fine for a single node - but not for multiple.

Since I am running ECS in Fargate awsvpc mode. I didn't see a way to get the IP of the Container (per AWS docs not supported in awsvpc mode).

To work around this problem I added a custom command for the container on startup to call the container metadata service and set it that way e.g.

TASK=$(echo $JSON | jq -r '.Containers[0].Networks[0].IPv4Addresses[0]')

Is there a more native way to do this?

Best, Wayne

1 Answer
Accepted Answer

The container metadata URI is the AWS native way to get node ENI IP.

answered 9 months ago
reviewed 8 months ago
  • Thank you for feedback.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions