From 30e73805571b03df1c8da36b68cd2508b0519793 Mon Sep 17 00:00:00 2001 From: azban Date: Thu, 6 Jun 2024 21:25:28 -0600 Subject: [PATCH] provider: set aws_rds_iam_region even if aws_rds_iam_profile is set --- postgresql/provider.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/postgresql/provider.go b/postgresql/provider.go index 7f15c92e..62d550e6 100644 --- a/postgresql/provider.go +++ b/postgresql/provider.go @@ -226,13 +226,14 @@ func getRDSAuthToken(region string, profile string, username string, host string var awscfg aws.Config var err error + loadOptions := []func(*awsConfig.LoadOptions) error{} if profile != "" { - awscfg, err = awsConfig.LoadDefaultConfig(ctx, awsConfig.WithSharedConfigProfile(profile)) - } else if region != "" { - awscfg, err = awsConfig.LoadDefaultConfig(ctx, awsConfig.WithRegion(region)) - } else { - awscfg, err = awsConfig.LoadDefaultConfig(ctx) + loadOptions = append(loadOptions, awsConfig.WithSharedConfigProfile(profile)) + } + if region != "" { + loadOptions = append(loadOptions, awsConfig.WithRegion(region)) } + awscfg, err = awsConfig.LoadDefaultConfig(ctx, loadOptions...) if err != nil { return "", err }