From 5b6393aa5d82ceb91cfdfe9e7a2fefb9bcc03b7b Mon Sep 17 00:00:00 2001 From: vinay-gopalan <86625824+vinay-gopalan@users.noreply.github.com> Date: Thu, 23 Sep 2021 04:53:39 -0700 Subject: [PATCH] Read `AWS_PROFILE` to enable Shared Credentials provider (#11) --- awsutil/generate_credentials.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/awsutil/generate_credentials.go b/awsutil/generate_credentials.go index 612f08b..ac0fb00 100644 --- a/awsutil/generate_credentials.go +++ b/awsutil/generate_credentials.go @@ -186,6 +186,13 @@ func (c *CredentialsConfig) GenerateCredentialChain(opt ...Option) (*credentials } if opts.withSharedCredentials { + profile := os.Getenv("AWS_PROFILE") + if profile != "" { + c.Profile = profile + } + if c.Profile == "" { + c.Profile = "default" + } // Add the shared credentials provider providers = append(providers, &credentials.SharedCredentialsProvider{ Filename: c.Filename,