Problem in getting result from 'aws ecr get-login'

I am getting following error when given following command.

aws ecr get-login --region eu-central-1 

Error

An error occurred (AccessDeniedException) when calling the GetAuthorizationToken operation: User: arn:aws:iam::314xxxx91079:user/git is not authorized to perform: ecr:GetAuthorizationToken on resource: * 

My admin has given me access for this 'GetAuthorizationToken' resource.

Most probably what I think the problem is 'arn:aws:iam::314xxxx91079:user/git' user being used for this command. When I login into aws console, I see my user name (IAM) as follow.

 

How do I make 'get-login' to take this user name instead of user/git. I am very new to aws cli, and this command happens to be one of the build step.

4 Answers

For newer version just use

aws ecr get-login-password \ --region us-east-1 | docker login \ --username AWS \ --password-stdin <account-id>.dkr.ecr.us-east-1.amazonaws.com 

The AWS cli command looks good and the output should be similar to below

Sample output: docker login -u AWS -p password 

Please check if you have correctly set the AWS credentials for cli to use.

If not done, try below to configure the credentials

aws configure AWS Access Key ID [None]: Access Key AWS Secret Access Key [None]: Secret Key Default region name [None]: eu-central-1 Default output format [None]: json 

Note : This should be your default profile, else pass profile name as well for ecr get-login command

aws ecr get-login --region eu-central-1 --profile <profile name> 

Hope this helps !!!

3

With newer versions of AWS CLI, we can request the password for ECR docker login with get-login-password and pipe the password to Docker login, something like:

aws ecr get-login-password \ --region us-east-1 \ | docker login \ --username AWS \ --password-stdin 123456789101.dkr.ecr.us-east-1.amazonaws.com 

Documentation:

with CLI V2, following syntax is going to throw error:

$(aws ecr get-login --no-include-email --region us-east-1) 
 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: 

Please find below the step that push the local docker image to AWS ECR we can get login succeeded:

  1. C:>aws ecr get-login-password --no-verify We will get the password.Please find below the password column

  2. C:\docker login --username AWS --password eyJwYXlsb2Fk...kRBVEFfS0VZIn0=

  3. docker tag user-mysql account_id

  4. Push the image on ECR : C:\docker push account_id

Username : AWS
Password : eyJwYXlsb2Fk...kRBVEFfS0VZIn0=
ProxyEndpoint :
Endpoint :
ExpiresAt : 9/26/2017 6:08:23 AM
Command : docker login --username AWS --password eyJwYXlsb2Fk...kRBVEFfS0VZIn0=

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like