From 57336e765abfe6c7c44ae9074c952359c2aac5d2 Mon Sep 17 00:00:00 2001 From: Marco Suma Date: Mon, 16 Oct 2023 17:18:04 +0200 Subject: [PATCH] fix region default value. --- mongodbatlas/fw_provider.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mongodbatlas/fw_provider.go b/mongodbatlas/fw_provider.go index 9445de5ead..858b45f6a3 100644 --- a/mongodbatlas/fw_provider.go +++ b/mongodbatlas/fw_provider.go @@ -4,6 +4,7 @@ import ( "context" "log" "regexp" + "strings" "time" "github.com/hashicorp/terraform-plugin-framework-validators/listvalidator" @@ -359,10 +360,12 @@ func setDefaultValuesWithValidations(ctx context.Context, data *tfMongodbAtlasPr } if data.Region.ValueString() == "" { - data.Region = types.StringValue(MultiEnvDefaultFunc([]string{ + // Convert the input string to lowercase and replace all underscores with hyphens. + region := strings.ReplaceAll(strings.ToLower(MultiEnvDefaultFunc([]string{ "AWS_REGION", "TF_VAR_AWS_REGION", - }, "").(string)) + }, "").(string)), "_", "-") + data.Region = types.StringValue(region) } if data.StsEndpoint.ValueString() == "" {