Search code examples
amazon-ecs

Access AWS Tags inside ECS docker containers


I am creating a ECS Service with a few resource tags through a cloudformation template. Once the service is up and running, is there a way I can access these aws tags from within the container?

I was thinking if there is a way to make them available as environment variables in the container?


Solution

  • Run one of the following command from within the container:

    list-tags-for-resource CLI commands with task ARN 3

    aws ecs list-tags-for-resource --resource-arn arn:aws:ecs:<region>:<Account_Number>:task/test/186de825c8EXAMPLE10bf1c3bb142
    

    list-tags-for-resource CLI commands with service ARN 3

    aws ecs list-tags-for-resource --resource-arn arn:aws:ecs:<region>:<Account_Number>:service/test/service