Search code examples
amazon-web-servicesimagedockeraws-cliamazon-ecs

AWS CLI Query for pulling image from ecs describe-task-definition?


So I'm trying to pull just the image from a task-definition. I'm running:

aws ecs describe-task-definition --task-definition nameoftaskdefinition --output text

And I'm trying add in the --query option so that result will look like

VAR = $(aws ecs describe-task-definition --task-definition nameoftaskdefinition --output text)

where echo $VAR would return image


Solution

  • Based on the output from the docs, you'll want something like this (untested)

    aws ecs describe-task-definition \
        --task-definition nameoftaskdefinition \
        --query 'taskDefinition.containerDefinitions[].image' \
        --output text
    

    Note that depending on your task, you may have multiple containerDefinitions, so the output from that command ($VAR in your example) could be a space separated string