Search code examples
ubuntuaws-cliamazon-ecr

AWS ECR get-login-password - Invalid choice on Ubuntu 18.04


When trying to run the get-login-password command in aws ecr, I get a message saying it's an invalid choice:

$ aws --region=us-west-1 ecr get-login-password
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-repository                        | delete-repository-policy                
describe-images                          | describe-repositories                   
get-authorization-token                  | get-download-url-for-layer              
get-lifecycle-policy                     | get-lifecycle-policy-preview            
get-repository-policy                    | initiate-layer-upload                   
list-images                              | put-image                               
put-lifecycle-policy                     | set-repository-policy                   
start-lifecycle-policy-preview           | upload-layer-part                       
get-login                                | help            

Is this a Mac-only tool? ECR does seem to be installed but the issue is get-login-password. I installed the latest AWS client via these instructions https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2-linux.html


Solution

  • AWS CLI have two versions available at the moment, get-login-password is only available in the v2 of the SDK/CLI.

    aws ecr get-login-password --region eu-west-1 | docker login --username AWS --password-stdin 123456789.dkr.ecr.eu-west-1.amazonaws.com
    

    Previous version v1 uses the following command. aws ecr get-login

    eval $(aws ecr get-login --registry-ids 123456789 --region eu-west-1 --no-include-email)
    

    You can use aws --version to check what version of the CLI is installed at the moment.

    aws --version
    aws-cli/2.0.38 Python/3.7.4 Darwin/20.3.0 exe/x86_64
    

    As per your question is this a "Mac-only" tool? No this is available for Windows, Mac and Linux as well as for x86 and ARM architecture.

    I've just ran their installation command and it works for me.

    root@Dummy:~# curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100 35.8M  100 35.8M    0     0  8827k      0  0:00:04  0:00:04 --:--:-- 8827k
    root@Dummy:~# unzip awscliv2.zip
    Archive:  awscliv2.zip
       creating: aws/
       creating: aws/dist/
      inflating: aws/README.md
      inflating: aws/THIRD_PARTY_LICENSES
      inflating: aws/install
       creating: aws/dist/_struct/
       creating: aws/dist/awscli/
    ......
    root@Dummy:~#
    root@Dummy:~#
    root@Dummy:~# aws --version
    aws-cli/2.1.37 Python/3.8.8 Linux/5.4.34-1-pve exe/x86_64.ubuntu.20 prompt/off
    root@Dummy:~#