Login doesn't support using EC2 instance credentials with ECR login
See original GitHub issueBehaviour
I am using self-hosted runners with an IAM role attached (with ECR permissions) and the login action fails.
Steps to reproduce this issue
- Create a self hosted runner with IAM role attached (with ECR permissions)
- Create a workflow with
uses: docker/login-action@v1
- Try to run the workflow
Expected behaviour
The login should use the EC2 instance credentials and login to ECR.
Actual behaviour
The login action fails
Error: An error occurred (UnrecognizedClientException) when calling the GetAuthorizationToken operation: The security token included in the request is invalid.
IMO the action should not attempt to overwrite the env vars for AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY in this case.
I can make it work using this manual run step:
- name: ECR login
run: |
aws ecr get-login-password | docker login --username AWS --password-stdin <aws-account-id>.dkr.ecr.<aws-region>.amazonaws.com
Configuration
- Repository URL (if public): private
- Build URL (if public): private
- name: ECR login
uses: docker/login-action@v1
with:
registry: <aws-account-id>.dkr.ecr.<aws-region>.amazonaws.com
Logs
Sorry private repo, I can’t share the logs.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Private registry authentication - Amazon ECR
To authenticate Docker to an Amazon ECR registry with get-login-password, run the aws ecr get-login-password command. When passing the authentication token ...
Read more >Problem in getting result from 'aws ecr get-login' - Stack Overflow
My admin has given me access for this 'GetAuthorizationToken' resource. Most probably what I think the problem is 'arn:aws:iam::314xxxx91079: ...
Read more >amazon web services - Error to login ecr docker - Server Fault
I'm following the documentation that aws provides, but still to no avail. Command login. aws ecr get-login-password \ --region REGION \ | docker ......
Read more >AWS EC2 Container Registry (ECR) Support - CircleCI
AWS ECR provides a Docker registry service, but it doesn't provide proper docker login credentials. Instead, per the AWS CLI Docs, ...
Read more >Resolve "Unable to locate credentials" error in Amazon S3
An "Unable to locate credentials" error indicates that Amazon S3 can't find the credentials to authenticate AWS API calls. To resolve this issue,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I did some testing to simulate what happens in the login-action
Given this step below I will get the expected output (running on a self-hosted runner)
Where as if I added the process.env vars as the login-action does here the step fails
a simple change to how we set the env vars should resolve it
Which will get me my EC2 credentials again 😃
Created a PR #114
I’m running into the same issue.
@crazy-max
If the self hosted running is using an IAM role then these environment variables would not be set as the EC2 should reuse the IAM role for authentication, no ?