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

Amit Bhandari picture Amit Bhandari · Jan 17, 2019 · Viewed 8.3k times · Source

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.

[email protected]

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.

Answer

Most Wanted picture Most Wanted · Mar 4, 2020

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