Feature request: expose a task's availability zone through the task metadata endpoint
Since the EC2 instance metadata is not available in Fargate, Fargate tasks cannot easily discover what zone they are in. They have to query the task metadata endpoint for the ENI, then query EC2 to discover the zone that the ENI is in. Request is to expose AZ as an attribute in the task metadata endpoint's response.
Ok, so... I'm an idiot and I have no idea how to write go but I would imagine we could do something like the following. https://github.com/ranman/amazon-ecs-agent/commit/8da6946e563bd1312d5548443166faf0c53131e1
Changes I would make if I knew more about how to go:
Again, no idea what I'm doing here... just really want this feature :)
Nice! This would solve the general case running on standard EC2. Unfortunately, using the instance metadata won't cover all of our use cases. I talked with some team members this morning and we think that the right way to handle this would be to stream the AZ mappings down to the agent. This means we also have some work on the service side.
Also -- theres a nifty function that parses ec2 metadata. I think it can handle points 1 and 2... in case you ever want to write more go :smile:
Any movement on this ?
It could also be nice to have that available in the ECS metadata file (https://docs.aws.amazon.com/AmazonECS/latest/developerguide/container-metadata.html).
It could also be nice to have that available in the ECS metadata file (https://docs.aws.amazon.com/AmazonECS/latest/developerguide/container-metadata.html).
/ping @cyastella
closing issue, changes were included with https://github.com/aws/amazon-ecs-agent/pull/1674 and https://github.com/aws/amazon-ecs-agent/pull/1675 and released with v1.23.0
Hey guys, is the AZ supposed to be available in the Fargate tasks metadata endpoint? We're using Fargate (agent 1.30) and the v3 endpoint but don't see it. Here's the data we get back right now: https://gist.github.com/travisbell/54f4d801779a96f52c60f8c02116e4ae
The docs seem to indicate it should be there but it's not.
What I'm trying to understand is whether this is by design now or not. Thanks!
I am seeing the exact same behavior as @travisbell . According to https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-metadata-endpoint-v3.html
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 the documentation.
Unfortunately, the actual response I get is missing the field "AvailabilityZone". Attached the response I am getting from my task. You can see my response here: https://gist.github.com/MartinDevillers/de26710f2d28a5f9ef76db4f40046bd5
I had a talk with AWS Enterprise Support and they confirmed that this feature has not been released yet and that the current documentation does not match the actual implementation. There's an internal Feature Request to add the AZ to the metadata response, but at this moment it's not there. I hope they will add it soon. Love Fargate ❤
Good news @travisbell Today AWS released version 1.4.0 of the Fargate platform which includes a fix for this specific issue. Do note that there are now two environment properties ECS_CONTAINER_METADATA_URI and ECS_CONTAINER_METADATA_URI_V4 (note the _V4 suffix on the second one; this grants access to the version 4 of the Metadata Endpoint)
Most helpful comment
Ok, so... I'm an idiot and I have no idea how to write go but I would imagine we could do something like the following. https://github.com/ranman/amazon-ecs-agent/commit/8da6946e563bd1312d5548443166faf0c53131e1
Changes I would make if I knew more about how to go:
Again, no idea what I'm doing here... just really want this feature :)