1
votes

Our containers launched in ECS using an EC2 cluster used the "ECS_CONTAINER_METADATA_FILE" mechanism of the container agent to get its task id.

This doesn't appear to work with Fargate launched containers. Is there a mechanism to introspect when running in a Fargate launched container using the "ECS_CONTAINER_METADATA_FILE"?

I understand that info for all tasks may be obtained with curl http://localhost:51678/v1/tasks

1

1 Answers

0
votes

This doesn't appear to work with Fargate launched containers. Is there a mechanism to introspect when running in a Fargate launched container using the "ECS_CONTAINER_METADATA_FILE"?

No. You don't have control of the underlying host or ECS agent, so there's no way to enable or disable this file like you could in an EC2 launch type.

Fortunately, from within a Fargate task, you can get this metadata with the metadata endpoint.

169.254.170.2/v2/metadata will return a json object with all the info you need. You should be able to parse the taskID out of the TaskArn.