Pipe "atlassian/aws-ecr-push-image:2.0.0" fails to push the image to ECR
Asked by Arman Koradia:

Pipe "atlassian/aws-ecr-push-image:2.0.0" fails to push the image to ECR even when login to ECR is successful.

Below is the step that I have for building the docker image, tagging it and pushing it to ECR. Please let me know if I am missing anything here.  

```
- step:
  name: Build Docker image
  script:
    - IMAGE_NAME="aws_account_number.dkr.ecr.us-east-1.amazonaws.com/tn-springboot-bitbucket-demo"
    - docker build -t ${IMAGE_NAME} .
  after-script:
    - pipe: atlassian/aws-ecr-push-image:2.0.0
      variables:
        AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
        AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
        AWS_DEFAULT_REGION: $AWS_REGION
        IMAGE_NAME: $ECR_REPOSITORY
        TAGS: latest
```

The logs that are generated are as follows:  

```
Status: Downloaded newer image for bitbucketpipelines/aws-ecr-push-image:2.0.0
INFO: Using default authentication with AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY
INFO: Executing the aws-ecr-push-image pipe...
INFO: Found credentials in environment variables.
INFO: Successfully logged in to https://aws_account_number.dkr.ecr.us-east-1.amazonaws.com
INFO: {'status': 'The push refers to repository [aws_account_number.dkr.ecr.us-east-1.amazonaws.com/<aws_account_number>.dkr.ecr.us-east-1.amazonaws.com/tn-springboot-bitbucket-demo]'}
INFO: {'status': 'Preparing', 'progressDetail': {}, 'id': '25428ec2c0ce'}
INFO: {'status': 'Preparing', 'progressDetail': {}, 'id': '6b5aaff44254'}
INFO: {'status': 'Preparing', 'progressDetail': {}, 'id': '53a0b163e995'}
INFO: {'status': 'Preparing', 'progressDetail': {}, 'id': 'b626401ef603'}
INFO: {'status': 'Preparing', 'progressDetail': {}, 'id': '9b55156abf26'}
INFO: {'status': 'Preparing', 'progressDetail': {}, 'id': '293d5db30c9f'}
INFO: {'status': 'Preparing', 'progressDetail': {}, 'id': '03127cdb479b'}
INFO: {'status': 'Preparing', 'progressDetail': {}, 'id': '9c742cd6c7a5'}
INFO: {'status': 'Waiting', 'progressDetail': {}, 'id': '293d5db30c9f'}
INFO: {'status': 'Waiting', 'progressDetail': {}, 'id': '03127cdb479b'}
INFO: {'status': 'Waiting', 'progressDetail': {}, 'id': '9c742cd6c7a5'}
INFO: {'status': 'Retrying in 5 seconds', 'progressDetail': {}, 'id': '25428ec2c0ce'}
INFO: {'status': 'Retrying in 5 seconds', 'progressDetail': {}, 'id': 'b626401ef603'}
INFO: {'status': 'Retrying in 5 seconds', 'progressDetail': {}, 'id': '6b5aaff44254'}
INFO: {'status': 'Retrying in 5 seconds', 'progressDetail': {}, 'id': '53a0b163e995'}
INFO: {'status': 'Retrying in 5 seconds', 'progressDetail': {}, 'id': '9b55156abf26'}
INFO: {'status': 'Retrying in 4 seconds', 'progressDetail': {}, 'id': '25428ec2c0ce'}
INFO: {'status': 'Retrying in 4 seconds', 'progressDetail': {}, 'id': 'b626401ef603'}
INFO: {'status': 'Retrying in 4 seconds', 'progressDetail': {}, 'id': '6b5aaff44254'}
INFO: {'status': 'Retrying in 4 seconds', 'progressDetail': {}, 'id': '53a0b163e995'}
INFO: {'status': 'Retrying in 4 seconds', 'progressDetail': {}, 'id': '9b55156abf26'}
INFO: {'status': 'Retrying in 3 seconds', 'progressDetail': {}, 'id': '25428ec2c0ce'}
INFO: {'status': 'Retrying in 3 seconds', 'progressDetail': {}, 'id': 'b626401ef603'}
INFO: {'status': 'Retrying in 3 seconds', 'progressDetail': {}, 'id': '6b5aaff44254'}
INFO: {'status': 'Retrying in 3 seconds', 'progressDetail': {}, 'id': '53a0b163e995'}
INFO: {'status': 'Retrying in 3 seconds', 'progressDetail': {}, 'id': '9b55156abf26'}
INFO: {'status': 'Retrying in 2 seconds', 'progressDetail': {}, 'id': '25428ec2c0ce'}
INFO: {'status': 'Retrying in 2 seconds', 'progressDetail': {}, 'id': 'b626401ef603'}
INFO: {'status': 'Retrying in 2 seconds', 'progressDetail': {}, 'id': '6b5aaff44254'}
INFO: {'status': 'Retrying in 2 seconds', 'progressDetail': {}, 'id': '53a0b163e995'}
INFO: {'status': 'Retrying in 2 seconds', 'progressDetail': {}, 'id': '9b55156abf26'}
INFO: {'status': 'Retrying in 1 second', 'progressDetail': {}, 'id': '25428ec2c0ce'}
INFO: {'status': 'Retrying in 1 second', 'progressDetail': {}, 'id': 'b626401ef603'}
INFO: {'status': 'Retrying in 1 second', 'progressDetail': {}, 'id': '6b5aaff44254'}
INFO: {'status': 'Retrying in 1 second', 'progressDetail': {}, 'id': '53a0b163e995'}
```

    INFO: {'errorDetail': {'message': 'EOF'}, 'error': 'EOF'}

    ? Docker push error: EOF

<br />

Despite this failure, the pipeline is shown as "Successful" which is terribly wrong. This consumed most of my Premium Trial Build Limits. :(  
Attaching multiple instances of the same as screenshot below:  
![Screenshot 2023-04-05 at 5.35.43 PM.png](https://community.atlassian.com/t5/image/serverpage/image-id/249984iA6F8453B4E8CD321/image-size/large?v=v2&px=999 "Screenshot 2023-04-05 at 5.35.43 PM.png")![Screenshot 2023-04-05 at 5.36.12 PM.png](https://community.atlassian.com/t5/image/serverpage/image-id/249985i944C12E77E578EA9/image-size/large?v=v2&px=999 "Screenshot 2023-04-05 at 5.36.12 PM.png")  


Answers:
author: Oleksandr Kyrdan
body: Hi [@Arman Koradia](/t5/user/viewprofilepage/user-id/5188739)

Thank you for your question!

We'll investigate the issue and notify you.

Please, pay attention that IMAGE_NAME variable for the pipe should be IMAGE_NAME that you build according to the documentation in the readme. (i.e. "tn-springboot-bitbucket-demo" according to the logs you provided)

Also, have you tried push the image with the pipe in the same step and script section instead of after-script section?

```
- step:
  name: Build Docker image
  script:
    - IMAGE_NAME="aws_account_number.dkr.ecr.us-east-1.amazonaws.com/tn-springboot-bitbucket-demo"
    - docker build -t ${IMAGE_NAME} .
    - pipe: atlassian/aws-ecr-push-image:2.0.0
      variables:
        IMAGE_NAME: $IMAGE_NAME
        TAGS: latest
```

Best regards,  
Oleksandr Kyrdan

comments: author: rmontano
body: I hit the same issue. My problem was that the IMAGE_NAME was incorrect.


Tags: bitbucket-cloud

cloud