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

SharedCredentialProvider problems #341

Closed
masonoise opened this issue Aug 7, 2015 · 5 comments
Closed

SharedCredentialProvider problems #341

masonoise opened this issue Aug 7, 2015 · 5 comments
Labels
guidance Question that needs advice or information.

Comments

@masonoise
Copy link

I'm struggling to try to get a simple test utility working, and am encountering problems trying to use the SharedCredentialsProvider to pull the creds from my ~/.aws/config profile.

To debug, I'm printing out the creds, and it's simply not loading them:

    var creds = credentials.NewSharedCredentials("/Users/mason/.aws/config", "mytest")
    aws_conn := ecs.New(&aws.Config{
        Region:      aws.String("us-west-2"),
        Credentials: creds,
    })

    var credValue, err = creds.Get()
    fmt.Println("Creds: ", credValue)

    resp, err := aws_conn.ListServices(nil) // Just something to trigger a call

And when I run the test, I see:

Creds:  {  }
panic: SharedCredsAccessKey: shared credentials mytest in /Users/mason/.aws/config did not contain aws_access_key_id

And yet in my file, I have (with the creds removed to post here of course):

[default]
region = us-west-2
aws_access_key_id = REMOVED
aws_secret_access_key = REMOVED

[profile mytest]
region = us-west-2
aws_access_key_id = REMOVED
aws_secret_access_key = REMOVED

And this file works with the AWS CLI fine so I know the formatting/etc is all good.

I assume I'm missing something; I pretty new to Go and of course to working with this library, but everything seems like it should be good so any help would be terrific.

@jasdel
Copy link
Contributor

jasdel commented Aug 7, 2015

Hi @masonoise it looks like the issue is caused by profile being included in the section definition. If you change it to mytest the shared credentials should work.

@jasdel jasdel added the guidance Question that needs advice or information. label Aug 7, 2015
@masonoise
Copy link
Author

Good thinking -- I can confirm that it works with that removed. Thank you! I would recommend, though, a change to make it work with profile in there, because that is legal according to the AWS docs and it does work with their CLI tool (who knows why, but it does). It's strange because their docs show it both ways on this page: http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html#cli-multiple-profiles

In any case, I'm unblocked, and again thanks very much. Just the sort of thing I might have stared at for hours without seeing it.

@masonoise
Copy link
Author

Ok, I read more details and I see. It's the difference between the config file -- which is what I've got set up -- and the credentials file, which is what the sdk is looking for. Would be great to have it accept either one, but if not then this is more of a documentation note than anything else, I guess.

@jasdel
Copy link
Contributor

jasdel commented Aug 10, 2015

@masonoise I just updated our wiki documentation to clarify the different between the shared credentials profile file and AWS CLI config file.

@masonoise
Copy link
Author

Terrific, looks great. Thanks!

skotambkar pushed a commit to skotambkar/aws-sdk-go that referenced this issue May 20, 2021
Services
===
* Synced the V2 SDK with latest AWS service API definitions.
* Fixes [aws#341](aws/aws-sdk-go-v2#341)
* Fixes [aws#342](aws/aws-sdk-go-v2#342)

SDK Breaking Changes
===
* `aws`: Add default HTTP client instead of http.DefaultClient/Transport ([aws#315](aws/aws-sdk-go-v2#315))
  * Adds a new BuildableHTTPClient type to the SDK's aws package. The type uses the builder pattern with immutable changes. Modifications to the buildable client create copies of the client.  Adds a HTTPClient interface to the aws package that the SDK will use as an abstraction over the specific HTTP client implementation. The SDK will default to the BuildableHTTPClient, but a *http.Client can be also provided for custom configuration.  When the SDK's aws.Config.HTTPClient value is a BuildableHTTPClient the SDK will be able to use API client specific request timeout options.
  * Fixes [aws#279](aws/aws-sdk-go-v2#279)
  * Fixes [aws#269](aws/aws-sdk-go-v2#269)

SDK Enhancements
===
* `service/s3/s3manager`: Update S3 Upload Multipart location ([aws#324](aws/aws-sdk-go-v2#324))
  * Updates the Location returned value of S3 Upload's Multipart UploadOutput type to be consistent with single part upload URL. This update also brings the multipart upload Location inline with the S3 object URLs created by the SDK.
  * Fixes [aws#323](aws/aws-sdk-go-v2#323)
  * V2 Port [aws#2453](aws#2453)

SDK Bugs
===
* `private/model`: Handles empty map vs unset map behavior in send request ([aws#337](aws/aws-sdk-go-v2#337))
  * Updated shape marshal model to handle the empty map vs nil map behavior. Adding a test case to assert behavior when a user sends an empty map vs nil map.
  * Fix [aws#332](aws/aws-sdk-go-v2#332)
* `service/rds`: Fix presign URL for same region ([aws#331](aws/aws-sdk-go-v2#331))
  * Fixes RDS no-autopresign URL for same region issue for aws-sdk-go-v2. Solves the issue by making sure that the presigned URLs are not created, when the source and destination regions are the same. Added and updated the tests accordingly.
  * Fix [aws#271](aws/aws-sdk-go-v2#271)
* `private/protocola/json/jsonutil`: Fix Unmarshal map[string]bool ([aws#320](aws/aws-sdk-go-v2#320))
  * Fixes the JSON unmarshaling of maps of bools. The unmarshal case was missing the condition for bool value, in addition the bool pointer.
  * Fix [aws#319](aws/aws-sdk-go-v2#319)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
guidance Question that needs advice or information.
Projects
None yet
Development

No branches or pull requests

2 participants