docker login –username AWS –password-stdin https://<accountNumber>.dkr.ecr.<region>.amazonaws.com exited with error code 1:

Question:

I’m simply adopting the Eventbridge ETL design pattern and it gives me this error when I deploy:

[100%] fail: docker login –username AWS –password-stdin https://315997497220.dkr.ecr.us-west-2.amazonaws.com exited with error code 1:

❌ the-eventbridge-etl failed: Error: Failed to publish one or more
assets. See the error messages above for more information. at
Object.publishAssets
(/home/mubashir/.nvm/versions/node/v16.3.0/lib/node_modules/aws-cdk/lib/util/asset-publishing.ts:25:11)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at Object.deployStack
(/home/mubashir/.nvm/versions/node/v16.3.0/lib/node_modules/aws-cdk/lib/api/deploy-stack.ts:237:3)
at CdkToolkit.deploy
(/home/mubashir/.nvm/versions/node/v16.3.0/lib/node_modules/aws-cdk/lib/cdk-toolkit.ts:194:24)
at initCommandLine
(/home/mubashir/.nvm/versions/node/v16.3.0/lib/node_modules/aws-cdk/bin/cdk.ts:267:9)
Failed to publish one or more assets. See the error messages above for
more information.

The steps I took. Github repo has a video I followed

npx cdkp init the-eventbridge-etl --lang=python
cd the-eventbridge-etl
python3 -m venv .env
source .env/bin/activate
pip install -r requirements.txt
cdk synth
cdk deploy

The first error I get is related to bootstrapping. So I bootstrap.

export CDK_NEW_BOOTSTRAP=1
npx cdk bootstrap aws://315997497220/us-east-2 --cloudformation-execution-policies arn:aws:iam::aws:policy/AdministratorAccess --trust 315997497220 aws://315997497220/us-east-2

I’ve naturally updated the cdk.json file for using the above bootstrapping technique. I’ve tried all bootstrap techniques, with and without a qualifier, and with its subsequent changes to cdk.json. I don’t think it’s a bootstrap issue.

I get the above error and I don’t know what the issue is. I have not made any changes to the code.

Answers:

I geuss you need to get and pipe a password first as you use the --password-stdin flag. Try:

aws ecr get-login-password | docker login --username AWS --password-stdin https://315997497220.dkr.ecr.us-west-2.amazonaws.com
Answered By: Robert-Jan Kuyper

For me Robert-Jan Kuyper’s doesn’t work directly in bash, I’ve split into two.

  1. Execute aws ecr get-login-password. Copy long output string it’s password

  2. docker login --username AWS -p <password_from_step_1> https://315997497220.dkr.ecr.us-west-2.amazonaws.com

Note : Replace 315997497220 with your AWS account id

Answered By: Akshay Bhimani