How to Dynamically Retrieve CloudWatch Log Links for an ECS Fargate Task?

I have a task that runs on ECS fargate. That task generate logs on cloudwatch when it starts running. Is there a way to make my script lookup the log link from cloudwatch for it’s own task?

https://docs.aws.amazon.com/AmazonECS/latest/userguide/task-metadata-endpoint-v4-fargate.html|https://docs.aws.amazon.com/AmazonECS/latest/userguide/task-metadata-endpoint-v4-fargate.html

Pull the arn from the metadata endpoint. Then you should know how to call the logs.

How can I access these Task metadata endpoint information? The documentation says ${ECS_CONTAINER_METADATA_URI_V4}/task/stats. What’s that?

Checking this other doc page: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-metadata-endpoint.html

it says that the endpoint is a url, pointing to an ip… but that’s for ECS on EC2…

what about ecs fargate?

This documentation for ecs fargate (https://docs.aws.amazon.com/AmazonECS/latest/userguide/task-metadata-endpoint-v4-fargate.html) does not mention any url.

nevermind, I was able to make it work… that’s actually already the endpoint…