Skip to content

oci/auth: Fix aws login with aws-sdk-go-v2#432

Merged
darkowlzz merged 1 commit intomainfrom
oci-auth-aws-fix
Dec 14, 2022
Merged

oci/auth: Fix aws login with aws-sdk-go-v2#432
darkowlzz merged 1 commit intomainfrom
oci-auth-aws-fix

Conversation

@darkowlzz
Copy link
Copy Markdown
Contributor

@darkowlzz darkowlzz commented Dec 13, 2022

Follow-up of 750df67 , upgrade to aws-sdk-go-v2.

Without this change, the login fails with error:

operation error ECR: GetAuthorizationToken, https response error StatusCode: 400, RequestID: 49826b0a-de68-411d-acb1-3fd1554c64b4, api error MissingAuthenticationTokenException: Missing Authentication Token

As per aws-sdk-go-v2 migration docs, new config for creating a session should use config.LoadDefaultConfig() and account ID is not needed for ECR authorization token.

In order to maintain the auth API compatibility, which is shared with other provider, return an empty client for NewClient(). The login implementation loads the default config if the client config is nil. A test can stub the client config before calling login.

Tested this against EKS using the integration tests with the EKS terraform module fix from fluxcd/test-infra#2.

@darkowlzz darkowlzz added the area/oci OCI related issues and pull requests label Dec 13, 2022
Copy link
Copy Markdown
Member

@stefanprodan stefanprodan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Thanks @darkowlzz

@darkowlzz darkowlzz force-pushed the oci-auth-aws-fix branch 2 times, most recently from 8856b2f to 3bb4cd4 Compare December 14, 2022 10:49
Copy link
Copy Markdown
Member

@pjbgf pjbgf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Thanks for the thread safety improvements @darkowlzz! 🙇

As per aws-sdk-go-v2 docs, new config for creating a session should use
config.LoadDefaultConfig() and account ID is not needed for ECR
authorization token.

In order to maintain the auth API which is shared with other provider,
return an empty client for NewClient(). The login implementation loads
the default config if the client config is nil. A test can stub the
client config before calling login.

Signed-off-by: Sunny <darkowlzz@protonmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/oci OCI related issues and pull requests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants