ECS Service - Automating deploy with new Docker image

后端 未结 3 2092
耶瑟儿~
耶瑟儿~ 2021-02-05 06:18

I want to automate the deployment of my application by having my ECS service launch with the latest Docker image. From what I\'ve read, the way to deploy a new image version is

3条回答
  •  有刺的猬
    2021-02-05 06:59

    The answer provided by Matt Callanan did not work for me: I received an error on this part:

    --container-definitions "'$(echo $NEW_CONTAINER_DEFS)'"
    

    Resulted in: Error parsing parameter '--container-definitions': Expected: '=', received: ''' for input:

    '{ environment: [ { etc etc....

    What I did to resolve it was:

    TASK_FAMILY= 
    DOCKER_IMAGE=
    LATEST_TASK_DEFINITION=$(aws ecs describe-task-definition --task-definition ${TASK_FAMILY})
    
    echo $LATEST_TASK_DEFINITION \
         | jq '{containerDefinitions: .taskDefinition.containerDefinitions, volumes: .taskDefinition.volumes}' \
         | jq '.containerDefinitions[0].image='\"${DOCKER_IMAGE}\" \
         > /tmp/tmp.json
    
    aws ecs register-task-definition --family ${TASK_FAMILY} --cli-input-json file:///tmp/tmp.json
    

    I take both the containerDefinitions and volumes elements from the original json document, because my containerDefinition uses these volumes (so it's not needed if you don't use volumes).

提交回复
热议问题