Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azurerm_app_configuration - normalize location for replica block #24074

Merged
merged 1 commit into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions internal/services/appconfiguration/app_configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/Azure/go-autorest/autorest"
"github.com/hashicorp/go-azure-helpers/lang/pointer"
"github.com/hashicorp/go-azure-helpers/lang/response"
"github.com/hashicorp/go-azure-helpers/resourcemanager/location"
"github.com/hashicorp/go-azure-sdk/resource-manager/appconfiguration/2023-03-01/configurationstores"
"github.com/hashicorp/go-azure-sdk/resource-manager/appconfiguration/2023-03-01/replicas"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
Expand Down Expand Up @@ -44,7 +45,7 @@ func flattenAppConfigurationReplicas(input []replicas.Replica) ([]interface{}, e

result := map[string]interface{}{
"name": pointer.From(v.Name),
"location": pointer.From(v.Location),
"location": location.Normalize(pointer.From(v.Location)),
"endpoint": pointer.From(v.Properties.Endpoint),
"id": replicaId.ID(),
}
Expand All @@ -57,7 +58,7 @@ func resourceConfigurationStoreReplicaHash(input interface{}) int {
var buf bytes.Buffer
if rawData, ok := input.(map[string]interface{}); ok {
buf.WriteString(rawData["name"].(string))
buf.WriteString(rawData["location"].(string))
buf.WriteString(location.Normalize(rawData["location"].(string)))
}
return pluginsdk.HashString(buf.String())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -792,11 +792,11 @@ func expandAppConfigurationReplicas(input []interface{}, configurationStoreName,
replicaName := replica["name"].(string)
replicaLocation := location.Normalize(replica["location"].(string))
if strings.EqualFold(replicaLocation, configurationStoreLocation) {
return nil, fmt.Errorf("location (%q) of replica %q is duplicated with original configuration store %q", replicaName, replicaLocation, configurationStoreName)
return nil, fmt.Errorf("location (%q) of replica %q is duplicated with original configuration store %q", replicaLocation, replicaName, configurationStoreName)
}

if name, ok := locationSet[replicaLocation]; ok {
return nil, fmt.Errorf("location (%q) of replica %q is duplicated with replica %q", replicaName, replicaLocation, name)
return nil, fmt.Errorf("location (%q) of replica %q is duplicated with replica %q", replicaLocation, replicaName, name)
}
locationSet[replicaLocation] = replicaName

Expand All @@ -807,7 +807,7 @@ func expandAppConfigurationReplicas(input []interface{}, configurationStoreName,
replicaNameSet[normalizedReplicaName] = struct{}{}

if len(replicaName)+len(configurationStoreName) > 60 {
return nil, fmt.Errorf("replica name %q is too long, the total length of replica name and configuration store name should be greater than 60", replicaName)
return nil, fmt.Errorf("replica name %q is too long, the total length of replica name and configuration store name should be less or equal than 60", replicaName)
}

result = append(result, replicas.Replica{
Expand Down
Loading