Migrating from aws ecr get-login to aws ecr get-login-password

Josh Sherman
1 min read
Command-line Interface AWS DevOps

I’m not entirely sure when the change happens, but recently as I was upgrading AWS CodeBuilds to use a newer version of Ubuntu, I ran into some problems with aws ecr get-login.

Without making any code changes, my build started to fail with the following:

[Container] 2021/06/21 20:44:19 Running command $(aws ecr get-login --no-include-email --region us-east-1)

usage: aws [options] <command> <subcommand> [<subcommand> ...] [parameters]
To see help text, you can run:

  aws help
  aws <command> help
  aws <command> <subcommand> help

aws: error: argument operation: Invalid choice, valid choices are:

batch-check-layer-availability           | batch-delete-image
batch-get-image                          | complete-layer-upload
create-repository                        | delete-lifecycle-policy
delete-registry-policy                   | delete-repository
delete-repository-policy                 | describe-image-scan-findings
describe-images                          | describe-registry
describe-repositories                    | get-authorization-token
get-download-url-for-layer               | get-lifecycle-policy
get-lifecycle-policy-preview             | get-registry-policy
get-repository-policy                    | initiate-layer-upload
list-images                              | list-tags-for-resource
put-image                                | put-image-scanning-configuration
put-image-tag-mutability                 | put-lifecycle-policy
put-registry-policy                      | put-replication-configuration
set-repository-policy                    | start-image-scan
start-lifecycle-policy-preview           | tag-resource
untag-resource                           | upload-layer-part
get-login-password                       | wait
help

At a glance I spotted the get-login-password and jumped to the conclusion that they simply renamed the command. Easy fix!

Except that assumption was wrong, and my next build failed a bit differently:

[Container] 2021/06/21 21:16:25 Running command $(aws ecr get-login-password --no-include-email --region us-east-1)

Unknown options: --no-include-email

At this point it was time to do some digging to figure out what the new syntax was supposed to be.

Turns out, the newer command didn’t need any of the arguments and could be easily piped directly to the docker login command as such:

[Container] 2021/06/21 21:21:46 Running command aws ecr get-login-password | docker login --username AWS --password-stdin $AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com

Login Succeeded

And we were off to the races and my builds started to pass again!

Join the Conversation

Good stuff? Want more?

Weekly emails about technology, development, and sometimes sauerkraut.

100% Fresh, Grade A Content, Never Spam.

About Josh

Husband. Father. Pug dad. Musician. Founder of Holiday API, Head of Engineering and Emoji Specialist at Mailshake, and author of the best damn Lorem Ipsum Library for PHP.

Currently Reading

Parasie Eve

Previous Reads

Buy Me a Coffee Become a Sponsor

Related Articles