Skip to content

fix get aws creds from environment#3617

Merged
yaron2 merged 2 commits into
dapr:mainfrom
famarting:fix-aws-creds-from-env
Nov 28, 2024
Merged

fix get aws creds from environment#3617
yaron2 merged 2 commits into
dapr:mainfrom
famarting:fix-aws-creds-from-env

Conversation

@famarting

Copy link
Copy Markdown
Contributor

Description

fixes a bug introduced here https://github.com/dapr/components-contrib/pull/3591/files#diff-017233cbc5865ed02ab3eacc4bc99b36ced96fcaf3420176e41d414444e41bc9

previously it was possible to get an aws session without providing access key and secret key, and we would pick the credentials from the environment. But since that PR, specifically because of this

func newStaticIAM(_ context.Context, opts Options, cfg *aws.Config) (*StaticAuth, error) {
	auth := &StaticAuth{
		logger:        opts.Logger,
		region:        &opts.Region,
		endpoint:      &opts.Endpoint,
		accessKey:     &opts.AccessKey,
		secretKey:     &opts.SecretKey,
		sessionToken:  &opts.SessionToken,
		assumeRoleARN: &opts.AssumeRoleARN,
		sessionName:   &opts.SessionName,

and the later check

if a.accessKey != nil && a.secretKey != nil {
		// session token is an option field
		awsConfig = awsConfig.WithCredentials(credentials.NewStaticCredentials(*a.accessKey, *a.secretKey, *a.sessionToken))
	}

that would always think that access key and secret key are available, despite of them having a value or not

this can cause this error from aws

EmptyStaticCreds: static credentials are empty 0xc0003f8600

Issue reference

We strive to have all PR being opened based on an issue, where the problem or feature have been discussed prior to implementation.

Please reference the issue this PR will close: #[issue number]

Checklist

Please make sure you've completed the relevant tasks for this PR, out of the following list:

Signed-off-by: Fabian Martinez <[email protected]>
@famarting
famarting requested review from a team as code owners November 28, 2024 12:57
elena-kolevska
elena-kolevska previously approved these changes Nov 28, 2024
Signed-off-by: Fabian Martinez <[email protected]>
@famarting

Copy link
Copy Markdown
Contributor Author

ready again @elena-kolevska

@yaron2
yaron2 merged commit 1e095ed into dapr:main Nov 28, 2024
@famarting
famarting deleted the fix-aws-creds-from-env branch November 28, 2024 15:58
@marcduiker

Copy link
Copy Markdown
Contributor

@holopin-bot @famarting Thank you Fabian!

@holopin-bot

holopin-bot Bot commented Dec 3, 2024

Copy link
Copy Markdown

Congratulations @famarting, the maintainer of this repository has issued you a badge! Here it is: https://holopin.io/claim/cm4879nr021760cjm9hpdz0b1

This badge can only be claimed by you, so make sure that your GitHub account is linked to your Holopin account. You can manage those preferences here: https://holopin.io/account.
Or if you're new to Holopin, you can simply sign up with GitHub, which will do the trick!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants