Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

source_profile in credentials file not used #3660

Closed
udf2457 opened this issue Nov 28, 2020 · 2 comments
Closed

source_profile in credentials file not used #3660

udf2457 opened this issue Nov 28, 2020 · 2 comments
Assignees
Labels
bug This issue is a bug.

Comments

@udf2457
Copy link

udf2457 commented Nov 28, 2020

Confirm by changing [ ] to [x] below to ensure that it's a bug:

Describe the bug

Given the following credentials file (~/.aws/credentials):

[default]
aws_access_key_id = foo
aws_secret_access_key = bar

[foobar]
role_arn = arn:aws:iam::12345:role/foobar
external_id = barfoo
source_profile = default

And the following code:

creds := &credentials.SharedCredentialsProvider{Profile:config.CredentialsProfile }
	awsConfig := &aws.Config{Region: aws.String(config.Region),
		UseDualStack:                  aws.Bool(config.UseDualStack),
		CredentialsChainVerboseErrors: aws.Bool(config.Debug),
		LogLevel:                      aws.LogLevel(logLevel),
		Credentials: credentials.NewCredentials(creds)}
	awsOptions := &session.Options{Config: *awsConfig}
	sess, err := session.NewSessionWithOptions(*awsOptions)
	if err != nil {
		log.Fatal().Err(err)
	}

The following is reported in SDK Debug:
error SharedCredsAccessKey: shared credentials foobar in /Users/foo/.aws/credentials did not contain aws_access_key_id

Version of AWS SDK for Go?
1.35.35

Version of Go (go version)?

go version go1.15.5 darwin/amd64

To Reproduce (observed behavior)
See description

Expected behavior
source_profile should be honoured

Additional context

@skotambkar
Copy link
Contributor

Thanks for reaching out. The issue here seems to be incorrect usage of SharedCredentialProvider.

Please take a look at https://pkg.go.dev/github.com/aws/aws-sdk-go/aws/session#hdr-Creating_Sessions to see how to build session when working with ~/.aws/credentials

@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

@vudh1 vudh1 removed the needs-triage This issue or PR still needs to be triaged. label Jul 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug.
Projects
None yet
Development

No branches or pull requests

4 participants