amazon-ecr-credential-helper: Doesn't work with AWS SSO
I’m trying to make it work with AWS SSO but i’m getting NoCredentialProviders.
I used aws configure sso to create a profile on my local machine and i can manually docker login and pull images from ECR like this:
aws ecr get-login-password --region us-west-2 --profile my-profile | docker login --username AWS --password-stdin my-account-id.dkr.ecr.us-west-2.amazonaws.com
docker pull account-id.dkr.ecr.us-west-2.amazonaws.com/my-repo:latest
My ~/.aws/config looks something like:
[profile my-profile]
sso_start_url = https://my-company.awsapps.com/start
sso_region = us-east-1
sso_account_id = my-account-id
sso_role_name = MyRoleName
region = us-west-2
output = json
Nothing was added to ~/.aws/credentials.
I logged out docker, installed docker-credential-helper-ecr and set:
~/.docker/config.json
{
"credsStore": "ecr-login"
}
and:
export AWS_PROFILE=my-profile
export AWS_REGION=us-west-2
When i:
docker pull account-id.dkr.ecr.us-west-2.amazonaws.com/repo:latest
I get:
no basic auth credentials
It works fine on another AWS account which is not SSO and i have my access keys set to ~/.aws/credentials.
Does it work with AWS SSO somehow?
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 30
- Comments: 39 (6 by maintainers)
Seconding (Nth-ing?) the request for a homebrew release with this change included 🙏
thanks @awilkins sad
anyone here able to kick off a release and get it on brew?
Same problem here, setting AWS_PROFILE= doesn’t work aswell. I tried many different combinations and the credential helper did not work.
no basic auth credentialsLet us take a look this week.
It’s not a solution in all situations but for those looking for a workaround for trying to push from a local computer the following might work:
@gondalez thanks for the interest in the project and the feedback. As others have noted building from main will help the immediate pain. That said let me bring this up with the team to see about an updated release with these fixes.
This command works
But this don’t, is there anyone has similar problem?
For those that need to support many teams with this, I’ve created a temporary workaround credential helper. https://github.com/dougrday/docker-credential-plaintext
It’s working with our teams with AWS SSO, but it’s definitely not the “secure” solution. Our tokens only live for 4 hours though, so the security window is fairly small.
I’d definitely prefer that other credential helpers step up and resolve the issue in a more secure fashion.
This issue is becoming more important with the release of the latest version of docker v2.4.0. There seems to be a limit of 2500 characters on the auth token that makes the
aws ecr get-login-passwordmethod not working (check here https://github.com/aws/aws-cli/issues/5636).Thanks for the heads-up @vtatarin. I’ve had a few issues with SSO bugs in my team.
@samuelkarp @austinvazquez I noticed you have changed
CHANGELOG.mdin the past… any insights as to why there are master commits but no releases past 0.6.0 for ?I’d love to see the newer version with bugfixes released. I assume that would allow it to make its way into a future Docker Desktop release as well for ultimate 😌
This is what I see locally; my credentials helper is packaged with with docker and pinned at 0.6.0:
FYI, SSO-related issues seem to be gone in a new binary version (077b4a9), which can be built manually from the sources. Not sure why new releases are not posted for such a long time already
@matuszeman yes, I have the permsision GetAuhtorizationToken permission. I’m also able to perform pulls authenticating via aws ecr get-login-password | docker login, but not via credential helper =/
I noticed a log file inside .ecr folder with this line that might help:
time="2022-10-04T00:25:03-03:00" level=error msg="Error retrieving credentials" error="ecr: Failed to get authorization token: NoCredentialProviders: no valid providers in chain. Deprecated.\n\tFor verbose messaging see aws.Config.CredentialsChainVerboseErrors"It looks like the Homebrew formula is updated now. In my case, I had to force-link it after installing, to overwrite the
0.5.0version installed with Docker Desktop. I also had to clean up a bunch of pre-SSO config, but the most relevant things were:rm ~/.ecr/cache.jsonrm ~/.aws/credentials(not 100% sure if this is required, but it’s not needed/used anymore with SSO)aws sso loginAfter all of the above, I was able to painlessly pull images from ECR again.
For anyone wandering in from Google, I can confirm that #267 fixes this for me after building from source.
Special thanks to @fangn2 who worked to push this through. v0.7.0 is available with fix for the issue.
@gondalez I no longer work at Amazon.
I am using
amazon-ecr-credential-helperfor first time, I installed 0.6.0 version via brew. When I pull from private ECR repo, I seeError response from daemon: Head "https://***.dkr.ecr.us-east-1.amazonaws.com/v2/prisidio/service-base-image/manifests/latest": no basic auth credentialsWhat am I missing? 🤔 I use AWS SSO. Exporting correct profile, and sos sso login as well.
My dockerconfig is:
I was wondering if a release is planned in the next coming weeks 😃 This is also one of the last tools I need for AWS SSO adoption. For now I guess I will build it from source, but a release would be better!
I can confirm this particular issue with
credential_processnot working with was fixed with this PR: https://github.com/awslabs/amazon-ecr-credential-helper/pull/240 - however a version of amazon-ecr-credential-helper hasn’t been released with this update.As for native support of SSO I imagine this is stalled until something like this: https://github.com/aws/aws-sdk-go/pull/3610 is merged to the SDK, then it will Just Work™ with another SDK upgrade because it seems it’ll be part of the default profile credential parser.
Also, sidebar - it seems that Docker Desktop for Mac is overwriting /usr/local/bin/docker-credential-ecr-login when the application is started, which is seemingly terrible and and they should feel bad for doing that. So that’s also a mess 🤸
@gautam-nutalapati I had the same problem as you reported. I fixed it by setting AWS profile via environment variable.
This is still a problem for Homebrew users as the current formula is pinned at 0.5.0 (b19192b6522b2da02d14ec394c331f3b1a70efe2).
I’ve also taken a stab at this, and ended up with something that doesn’t rely on node and doesn’t store temp credentials anywhere*. It’s working well for me, and hopefully it’s of some value to the rest of you as well.
https://github.com/TylerLubeck/docker-credentials-aws-ecr-sso
*Not to say that these things are bad, they just don’t fit for my use case
I @otaviomedeirossb, as already stated, AWS CLI v2 will write AWS SSO temporary credentials under ~/.aws/cli/cache folder, which in many cases ends up to a “credentials not found” issue. I’m currently working on an open source project that addresses this problem too. Indeed, it provides support to AWS SSO and lists you all the IAM Roles that your AWS SSO User can access. By clicking a session card associated with a IAM Role, Leapp will generate temporary credentials to access your AWS Organization’s Account, inside ~/.aws/credentials file. Let me know if it makes sense to you and if you have questions about it.
@dougrday . Your solution is the only one that worked for me. I understand the risk of exposing the password for a short period of time. That said, it is the only workaround until other credential helpers solve this issue. Thanks!