how to update ecs taskdefinition using AWS CLI

Viewed 933

I need to change the environment variable under container definition in the ecs Task Definition.

TASK_DEFINITION=$(aws ecs describe-task-definition --task-definition $TASKDEFINITION_ARN --output json)
echo $TASK_DEFINITION | jq '.taskDefinition.containerDefinitions[0] | ( .environment[] |= if   
    .name == "ES_PORT_9200_TCP_ADDR" then .value = "vpc-kkslke-shared-3-abcdkalssdfy.us-east-1.es.amazonaws.com" 
    else . end)' | jq -s . >container-definition.json
CONTAINER_DEF=$(<$container-definition.json)
aws ecs register-task-definition --family $FAMILY_NAME --container-definitions $CONTAINER_DEF

Error Message:

Error parsing parameter '--container-definitions': Invalid JSON: Expecting property name enclosed in double quotes: line 1 column 2 (char 1) JSON received: {

One observation not sure if it is related to a bug in VScode or not . When I try to use the view the variable value in debug mode. I only get partial text as seen below. But when I do echo for the same variable I do see the full json. Not sure if the whole value is being passed to the container definition.

enter image description here

0 Answers
Related