I would like to get a list of task definitions I can create a list from via AWS CLI. Here is a partial list from the command;
aws ecs list-task-definitions --region eu-west-1
{
"taskDefinitionArns": [
"arn:aws:ecs:eu-west-1:543573289192:task-definition/audience-view-dev-api:4",
"arn:aws:ecs:eu-west-1:543573289192:task-definition/audience-view-dev-groups:4",
"arn:aws:ecs:eu-west-1:543573289192:task-definition/audience-view-dev-groups:5",
"arn:aws:ecs:eu-west-1:543573289192:task-definition/audience-view-dev-mock-api:1",
"arn:aws:ecs:eu-west-1:543573289192:task-definition/audience-view-dev-mock-responder:1"
]
}
From this I would like to only show;
audience-view-dev-api
audience-view-dev-groups
audience-view-dev-groups
audience-view-dev-mock-api
audience-view-dev-mock-responder
I believe if I pipe this to jq
then I can get what I'm after? I am trying various combinations of; aws ecs list-task-definitions --region eu-west-1 | jq -r '.taskDefinitionArns[].<something_here>'
to no avail
Try this:
$ aws ecs list-task-definitions --region eu-west-1 \
| jq -Mr '.taskDefinitionArns[] | split(":")[5] | split("/")[1]'
Expanded:
.taskDefinitionArns[] # for each taskDefinitionArns
| split(":")[5] # take entry [5] after splitting by :
| split("/")[1] # take entry [1] after splitting by /
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With