I have a docker compose configuration that I'm deploying in an ECS Fargate cluster. The tasks are configured with assign_public_ip: ENABLED
, and they seem to be getting a public IP, but I'm struggling to figure out how to retrieve the IP. The service I'm running must know its public IP or hostname to work properly. There is an env var called ECS_CONTAINER_METADATA_URI
that is supposed to point to the instance metadata, but it seems to be empty when I curl it. Here is the output of env
:
AGENT_NAME=Certifier
APP_ROOT=
AWS_DEFAULT_REGION=us-west-2
AWS_EXECUTION_ENV=AWS_ECS_FARGATE
AWS_REGION=us-west-2
CARGO_HOME=/usr/local/cargo
DESCRIPTION=von-image provides a consistent base image for running VON python web components. Based on Ubuntu bionic, this image includes Python 3.6.9, indy-sdk, and supporting Python libraries.
ECS_CONTAINER_METADATA_URI=http://169.254.170.2/v3/1bbe943c-8fd9-40bf-8aed-477ee26eae69
HOME=/home/indy
HOSTNAME=ip-10-0-1-15.us-west-2.compute.internal
LANG=C.UTF-8
LC_ALL=C.UTF-8
LD_LIBRARY_PATH=/home/indy/.local/lib
LIBINDY_DIR=/home/indy/.local/lib
LIBSOVTOKEN=/home/indy/libsovtoken-1.0.1/libsovtoken/target/debug/libsovtoken.so
PATH=/usr/local/cargo/bin:/home/indy/.local/bin:/home/indy/bin:/home/indy/.pyenv/shims:/home/indy/.pyenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PIP_NO_CACHE_DIR=off
PORT=4000
PWD=/home/indy
PYENV_ROOT=/home/indy/.pyenv
PYTHONIOENCODING=UTF-8
PYTHONUNBUFFERED=1
PYTHON_VERSION=3.6.9
RUSTUP_HOME=/usr/local/rustup
RUST_LOG=warning
RUST_VERSION=1.41.1
SHELL=/bin/bash
SHLVL=1
SUMMARY=von-image including Python 3.6.9 and indy-sdk
_=/usr/bin/env
When I actually attempt to download this metadata, however, it appears to be empty. The following lines in my startup script:
curl "$ECS_CONTAINER_METADATA_URI/task" -o "$HOME/results.json"
cat "$HOME/results.json"
produce the following output:
+ curl http://169.254.170.2/v3/6f818f2c-6a01-4975-b937-6b5658eac7e2/task -o /home/indy/results.json
Dload Upload Total Spent Left Speed
% Total % Received % Xferd Average Speed Time Time Time Current
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:--
0 100 4112 0 4112 0 0 1003k 0 --:--:-- --:--:-- --:--:-- 1003k
+ cat /home/indy/results.json
The results are empty. I'm concerned that maybe there is a permissions issue, but unsure how to verify this or fix it. Thanks in advance for your help.