Tell us about your request
According to official AWS documentation for the ECS Fargate Task Metadata Endpoint version 3
I can execute the following command inside my ECS Fargate Task curl -s $ECS_CONTAINER_METADATA_URI/task and expect a response similar to one mentioned at the bottom of said documentation.
Unfortunately, the actual response I get is missing the field AvailabilityZone. I've talked to AWS Enterprise Support and they confirm that this feature hasn't actually been implemented (yet), so I am retroactively adding it to the roadmap 馃槈
Which service(s) is this request for?
Fargate
Tell us about the problem you're trying to solve. What are you trying to do, and why is it hard?
I want to be able to read the AZ of my running instance from inside my Docker entrypoint shell script. My specific use-case is to enable a diagnostics tracing agent on my application, but only on one instance to limit the output and not affect performance too much.
Are you currently working around this issue?
Well I haven't yet, but my best solution right now is to regex the $HOSTNAME variable and determine the AZ based on the assigned IP's subnet.
Additional context
The guy at AWS Enterprise Support mentioned this is already an internal Feature Request. I'm opening an issue here just to give it some more support 馃槉
There's another guy here who ran into the same problem: https://github.com/aws/amazon-ecs-agent/issues/1559#issuecomment-505461249
Attachments
1 - The official docs including a sample response: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-metadata-endpoint-v3.html
2 - The actual response I am seeing: https://gist.github.com/MartinDevillers/de26710f2d28a5f9ef76db4f40046bd5
Thanks @MartinDevillers. I'm the "other guy" who was looking into this and would love to see this get fixed. In our EC2 classic infrastructure we load balance to a local AZ first to save some bandwidth costs but came across this issue when looking into moving some of that workload over to Fargate.
Shipped! Learn more here: https://aws.amazon.com/blogs/containers/aws-fargate-launches-platform-version-1-4/
Can confirm. The output from curl -s $ECS_CONTAINER_METADATA_URI_V4/task now contains the element "AvailabilityZone": "us-west-1c". Good job on adding this to the 1.4 release of the Fargate platform. 馃憤
Most helpful comment
Shipped! Learn more here: https://aws.amazon.com/blogs/containers/aws-fargate-launches-platform-version-1-4/