ECS Fargate - How to get IP Address

0

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.

JSON=$(curl ${ECS_CONTAINER_METADATA_URI}/task)
TASK=$(echo $JSON | jq -r '.Containers[0].Networks[0].IPv4Addresses[0]')
CONNECT_REST_ADVERTISED_HOST_NAME=$TASK

Is there a more native way to do this?

Best, Wayne

xathras
質問済み 2年前5011ビュー
1回答
1
承認された回答

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

Jason_S
回答済み 2年前
AWS
エキスパート
レビュー済み 2年前
  • Thank you for feedback.

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ