Aws-ecr@6.1.0 Fails to push image to ECR after a successful login

So i’m having a problem pushing an image to an AWS ECR under my account.
I am using aws-ecr orb version@6.1.0.
As per job definition in official documentation everything goes fine and it logs into my AWS account as well, but for some reason it fails to push the image to AWS ECR and the error I get is:

#!/bin/bash -eo pipefail
docker push $AWS_ACCOUNT_ID/myrepo:latest
The push refers to repository [<HIDING_ACCOUNT_ID>/myrepo]

denied: requested access to the resource is denied
Exited with code 1

Here is my config.yml:

version: 2.1
  aws-ecr: circleci/aws-ecr@6.1.0
  # aws-ecs: circleci/aws-ecs@0.0.8
      # specify the version you desire here
      - image: circleci/node:12.2.0

      # Specify service dependencies here if necessary
      # CircleCI maintains a library of pre-built images
      # documented at

    working_directory: ~/repo

      - checkout

      # Download and cache dependencies
      - restore_cache:
            - v1-dependencies-{{ checksum "package.json" }}
            # fallback to using the latest cache if no exact match is found
            - v1-dependencies-

      - run: npm install
      - save_cache:
            - node_modules
          key: v1-dependencies-{{ checksum "package.json" }}

  version: 2.1
      - build            
      - aws-ecr/build-and-push-image:
            - build
          account-url: AWS_ACCOUNT_ID
          aws-access-key-id: AWS_ACCESS_KEY_ID
          aws-secret-access-key: AWS_SECRET_ACCESS_KEY
          create-repo: true
          repo: myrepo
          dockerfile: "Dockerfile"
          region: AWS_REGION

It seems that instead of pushing the image to, it tries to push to<HIDING_ACCOUNT_ID>/myrepo and obviously fails.

What can be done to solve this issue?


What I was doing incorrectly was using the env var AWS_ACCOUNT_ID (in my Circle Env Vars) for the account-url.
Solution: I made another env var called AWS_ECR_ACCOUNT_URL with the value in the format of <account-id>-dkr.ecr.<region>

Note: There is a typo in the official documentation:Here the account-url's description is:


when it should really be dkr.ecr :face_with_monocle:

Good spot. Are you able to raise a ticket on GitHub? :innocent:

you git it :+1:

you got it :+1: