diff --git a/README.md b/README.md index 00f2066..fd2e2a5 100644 --- a/README.md +++ b/README.md @@ -1955,4 +1955,5 @@ Version: ## Data Collection The software may collect information about you and your use of the software and send it to Microsoft. Microsoft may use this information to provide services and improve our products and services. You may turn off the telemetry as described in the repository. There are also some features in the software that may enable you and Microsoft to collect data from users of your applications. If you use these features, you must comply with applicable law, including providing appropriate notices to users of your applications together with a copy of Microsoft’s privacy statement. Our privacy statement is located at . You can learn more about data collection and use in the help documentation and our privacy statement. Your use of the software operates as your consent to these practices. - \ No newline at end of file +## Note: resource_group_name normalization +The module normalizes var.resource_group_name to lowercase internally (local.normalized_resource_group_name) to ensure consistent casing across resources created by the module. Callers may continue to provide resource_group_name in any case; the module will use the lowercase form for resource_group_name references. diff --git a/locals.tf b/locals.tf index 74eae13..66bcc5b 100644 --- a/locals.tf +++ b/locals.tf @@ -1,4 +1,5 @@ locals { + normalized_resource_group_name = lower(var.resource_group_name) #flatten the role assignments for the disks disks_role_assignments = { for ra in flatten([ for dk, dv in var.data_disk_managed_disks : [ diff --git a/main.backup.tf b/main.backup.tf index d774c18..fc5b776 100644 --- a/main.backup.tf +++ b/main.backup.tf @@ -38,7 +38,7 @@ locals { protectedItemType = "Microsoft.Compute/virtualMachines" sourceResourceId = local.virtualmachine_resource_id policyId = value.backup_policy_resource_id - containerName = "iaasvmcontainerv2;${var.resource_group_name};${var.name}" + containerName = "iaasvmcontainerv2;${local.normalized_resource_group_name};${var.name}" policyName = basename(value.backup_policy_resource_id) } } @@ -48,8 +48,8 @@ locals { resource "azapi_resource" "this_backup_intent" { for_each = var.azure_backup_configurations - name = "VM;iaasvmcontainerv2;${coalesce(var.resource_group_name, each.value.resource_group_name, local.rsv_resource_group[each.key])};${var.name}" - parent_id = "${each.value.recovery_vault_resource_id}/backupFabrics/Azure/protectionContainers/iaasvmcontainer;iaasvmcontainerv2;${var.resource_group_name};${var.name}" + name = "VM;iaasvmcontainerv2;${coalesce(local.normalized_resource_group_name, each.value.resource_group_name, local.rsv_resource_group[each.key])};${var.name}" + parent_id = "${each.value.recovery_vault_resource_id}/backupFabrics/Azure/protectionContainers/iaasvmcontainer;iaasvmcontainerv2;${local.normalized_resource_group_name};${var.name}" type = "Microsoft.RecoveryServices/vaults/backupFabrics/protectionContainers/protectedItems@2024-10-01" body = { properties = local.backup_body_properties[each.key] diff --git a/main.disks.tf b/main.disks.tf index 3b4b951..d0337b1 100644 --- a/main.disks.tf +++ b/main.disks.tf @@ -4,7 +4,7 @@ resource "azurerm_managed_disk" "this" { create_option = each.value.create_option location = var.location name = each.value.name - resource_group_name = coalesce(each.value.resource_group_name, var.resource_group_name) + resource_group_name = coalesce(each.value.resource_group_name, local.normalized_resource_group_name) storage_account_type = each.value.storage_account_type disk_access_id = each.value.disk_access_resource_id disk_encryption_set_id = each.value.disk_encryption_set_resource_id #preview feature to be activated at a later date diff --git a/main.linux_vm.tf b/main.linux_vm.tf index a412496..5ccb848 100644 --- a/main.linux_vm.tf +++ b/main.linux_vm.tf @@ -7,7 +7,7 @@ resource "azurerm_linux_virtual_machine" "this" { name = var.name #network_interface_ids = [for interface in azurerm_network_interface.virtualmachine_network_interfaces : interface.id] network_interface_ids = [for interface in local.ordered_network_interface_keys : azurerm_network_interface.virtualmachine_network_interfaces[interface].id] - resource_group_name = var.resource_group_name + resource_group_name = local.normalized_resource_group_name size = var.sku_size #optional properties admin_password = (local.password_authentication_disabled ? null : local.admin_password_linux) diff --git a/main.networking.tf b/main.networking.tf index 337bae9..6405318 100644 --- a/main.networking.tf +++ b/main.networking.tf @@ -5,7 +5,7 @@ resource "azurerm_public_ip" "virtualmachine_public_ips" { allocation_method = var.public_ip_configuration_details.allocation_method location = var.location name = each.value.ipconfig.public_ip_address_name - resource_group_name = var.resource_group_name + resource_group_name = local.normalized_resource_group_name ddos_protection_mode = var.public_ip_configuration_details.ddos_protection_mode ddos_protection_plan_id = var.public_ip_configuration_details.ddos_protection_plan_id domain_name_label = var.public_ip_configuration_details.domain_name_label @@ -25,7 +25,7 @@ resource "azurerm_network_interface" "virtualmachine_network_interfaces" { location = var.location name = each.value.name - resource_group_name = coalesce(each.value.resource_group_name, var.resource_group_name) + resource_group_name = coalesce(each.value.resource_group_name, local.normalized_resource_group_name) accelerated_networking_enabled = each.value.accelerated_networking_enabled dns_servers = each.value.dns_servers edge_zone = var.edge_zone #each.value.edge_zone diff --git a/main.windows_vm.tf b/main.windows_vm.tf index 4208144..b97e586 100644 --- a/main.windows_vm.tf +++ b/main.windows_vm.tf @@ -8,7 +8,7 @@ resource "azurerm_windows_virtual_machine" "this" { name = var.name #network_interface_ids = [for interface in azurerm_network_interface.virtualmachine_network_interfaces : interface.id] network_interface_ids = [for interface in local.ordered_network_interface_keys : azurerm_network_interface.virtualmachine_network_interfaces[interface].id] - resource_group_name = var.resource_group_name + resource_group_name = local.normalized_resource_group_name size = var.sku_size #optional properties allow_extension_operations = var.allow_extension_operations