# Deploy docker image from ECR to EC2 instance

**URL:** <https://discuss.circleci.com/t/deploy-docker-image-from-ecr-to-ec2-instance/38586>\
**Category:** Build Environment\
**Tags:** docker, circle-yml\
**Created:** [December 21, 2020, 12:07pm UTC](https://discuss.circleci.com/t/deploy-docker-image-from-ecr-to-ec2-instance/38586 "2020-12-21T12:07:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![juanibe](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/juanibe/32/26283_2.png) [@juanibe](https://discuss.circleci.com/u/juanibe)\
**Post date:** [December 21, 2020, 12:07pm UTC](https://discuss.circleci.com/t/deploy-docker-image-from-ecr-to-ec2-instance/38586/1 "2020-12-21T12:07:52Z")

</div>

Hi!,  
I am trying to deploy to an instance of EC2 an image that I have already uploaded to ECR repository.  
For that I am using orb

> circleci/aws-ecr@6.15.0

which works perfect.  
But I want to continue with the deployment, and I want my docker container to be updated with the new changes. I saw that the orb

> circleci/aws-ecs@01.4.0

can do the job, but I am stuck there. This is my yaml file;

```
version: 2.1
orbs:
  node: circleci/node@4.1.0
  aws-ecr: circleci/aws-ecr@6.15.0
  aws-ecs: circleci/aws-ecs@01.4.0
workflows:
  build_and_push_image:
    jobs:
      - aws-ecr/build-and-push-image:
          repo: node.js-api
          tag: "latest,v0.1.${CIRCLE_BUILD_NUM}"
          dockerfile: "Dockerfile"
          path: .
      - aws-ecs/deploy-service-update:
          requires:
            - aws-ecr/build-and-push-image
          family: "${AWS_RESOURCE_NAME_PREFIX}-service"
          cluster-name: "${AWS_RESOURCE_NAME_PREFIX}-cluster"
          container-image-name-updates: "container=${AWS_RESOURCE_NAME_PREFIX}-service,tag=${CIRCLE_SHA1}"

```

With that, I am getting this error during the second job:

> aws: error: argument --task-definition: expected one argument

Any advise on how can I achieve this?  
Thank you!

---

<div class="post-metadata">

**Author:** ![EdEngle](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/edengle/32/26286_2.png) [@EdEngle](https://discuss.circleci.com/u/EdEngle)\
**Post date:** [December 21, 2020, 6:00pm UTC](https://discuss.circleci.com/t/deploy-docker-image-from-ecr-to-ec2-instance/38586/2 "2020-12-21T18:00:13Z")

</div>

I know that build-and-push requires that you have the AWS\_ACCESS\_KEY\_ID, AWS\_SECRET\_ACCESS\_KEY, and AWS\_DEFAULT\_REGION setup as environment variables. I set them up as a Context in Organizational Settings. That also means you need to include the context in the jobs: section of your config.
