add shared config state to session

By adding this flag to the session, we force the AWS Go SDK to read
the ~/.aws/config file. By default, the Go SDK doesn't read this file
which is often not what we or customers expect. Many customers store
their assume role based prfoiles in the .aws/config file rather than
the .aws/credentials file.

(This is what the AWS CLI does, by default - but that's because this
parameter is enabled by default in the python SDK).

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
David Killmon 2020-07-31 11:38:41 -07:00 committed by Nicolas De Loof
parent 55531eb6b4
commit 0df99075cc
No known key found for this signature in database
GPG Key ID: 9858809D6F8F6E7E
1 changed files with 2 additions and 1 deletions

View File

@ -8,7 +8,8 @@ import (
func NewBackend(profile string, region string) (*Backend, error) { func NewBackend(profile string, region string) (*Backend, error) {
sess, err := session.NewSessionWithOptions(session.Options{ sess, err := session.NewSessionWithOptions(session.Options{
Profile: profile, Profile: profile,
SharedConfigState: session.SharedConfigEnable,
Config: aws.Config{ Config: aws.Config{
Region: aws.String(region), Region: aws.String(region),
}, },