Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
Signed-off-by: nithyatsu <nithyasu@microsoft.com>
  • Loading branch information
nithyatsu committed Jul 19, 2024
1 parent 3db7d16 commit 63089ee
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
6 changes: 3 additions & 3 deletions pkg/recipes/terraform/config/providers/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,9 @@ func fetchAWSCredentials(ctx context.Context, awsCredentialsProvider credentials

func (p *awsProvider) generateProviderConfigMap(credentials *credentials.AWSCredential, region string) map[string]any {
config := make(map[string]any)
//if region != "" {
config[awsRegionParam] = "us-west-2" //region
//}
if region != "" {
config[awsRegionParam] = region
}

if credentials != nil {
switch credentials.Kind {
Expand Down
16 changes: 9 additions & 7 deletions pkg/recipes/terraform/config/providers/aws_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ func TestAWSProvider_generateProviderConfigMap(t *testing.T) {
awsSecretKeyParam: testAWSAccessKeyCredentials.AccessKeyCredential.SecretAccessKey,
},
},

{
desc: "valid IRSA credential config",
region: testRegion,
Expand All @@ -339,7 +340,6 @@ func TestAWSProvider_generateProviderConfigMap(t *testing.T) {
sessionName: "radius-terraform-" + "test-uuid",
tokenFile: tokenFilePath,
},
stsRegion: "us-west-2",
},
},
{
Expand Down Expand Up @@ -389,12 +389,14 @@ func TestAWSProvider_generateProviderConfigMap(t *testing.T) {
require.Equal(t, tt.expectedConfig[awsAccessKeyParam], config[awsAccessKeyParam])
require.Equal(t, tt.expectedConfig[awsSecretKeyParam], config[awsSecretKeyParam])

expectedAWSIRSAProvider := tt.expectedConfig[awsIRSAProvider].(map[string]any)
AWSIRSAProvider := config[awsIRSAProvider].(map[string]any)
require.Equal(t, expectedAWSIRSAProvider[awsRoleARN], AWSIRSAProvider[awsRoleARN])
require.Contains(t, expectedAWSIRSAProvider[sessionName], "radius-terraform-")
require.Equal(t, expectedAWSIRSAProvider[tokenFile], AWSIRSAProvider[tokenFile])
require.Equal(t, tt.expectedConfig[stsRegion], config[stsRegion])
if tt.expectedConfig[awsIRSAProvider] != nil {
expectedAWSIRSAProvider := tt.expectedConfig[awsIRSAProvider].(map[string]any)
AWSIRSAProvider := config[awsIRSAProvider].(map[string]any)
require.Equal(t, expectedAWSIRSAProvider[awsRoleARN], AWSIRSAProvider[awsRoleARN])
require.Contains(t, expectedAWSIRSAProvider[sessionName], "radius-terraform-")
require.Equal(t, expectedAWSIRSAProvider[tokenFile], AWSIRSAProvider[tokenFile])
require.Equal(t, tt.expectedConfig[stsRegion], config[stsRegion])
}
})
}
}

0 comments on commit 63089ee

Please sign in to comment.