Skip to content

Commit

Permalink
Honor AWS_PROFILE environment variable
Browse files Browse the repository at this point in the history
This fixes issue number 1767 where terraformer
doesn't respect the AWS_PROFILE environment
variable when it is set.

[1]:#1767

Signed-off-by: Raymond Etornam <[email protected]>
  • Loading branch information
retornam committed Sep 7, 2024
1 parent a5b4b69 commit 8526af1
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions providers/aws/aws_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,13 +201,13 @@ func (p *AWSProvider) Init(args []string) error {
}
}

if p.profile != "default" && p.profile != "" {
if p.profile != "" && p.profile != "default" {
envVar := "AWS_PROFILE"
if enableSharedConfig {
err = os.Setenv("AWS_DEFAULT_PROFILE", p.profile)
} else {
err = os.Setenv("AWS_PROFILE", p.profile)
envVar = "AWS_DEFAULT_PROFILE"
}
if err != nil {

if err := os.Setenv(envVar, p.profile); err != nil {
return err
}
}
Expand Down

0 comments on commit 8526af1

Please sign in to comment.