diff --git a/README.md b/README.md index 5e040be..9f64464 100644 --- a/README.md +++ b/README.md @@ -94,10 +94,10 @@ module "private_dns_resolver" { resource_group_name = module.rg.name ## Bring Your Own VNet - # If set, `vnet_cidr` will not be used - # vnet_id = module.my_vnet.id + # If set, `virtual_network_id` will not be used + # virtual_network_id = module.my_vnet.id - vnet_cidr = local.private_dns_resolver_vnet_cidr + virtual_network_cidr = local.private_dns_resolver_vnet_cidr inbound_endpoints = [ { @@ -123,23 +123,23 @@ module "private_dns_resolver" { }, { name = "bar" - custom_subnet_name = "bar-outbound-endpoint-subnet" + subnet_custom_name = "bar-outbound-endpoint-subnet" cidr = local.private_dns_resolver_subnets_cidrs[3] # cidr = local.my_subnets_cidrs[3] }, ] dns_forwarding_rulesets = [ - # VNets cannot be linked to multiple Forwarding Ruleset - # Therefore, keep in mind that the first Ruleset is the default one because the VNet of the Private DNS Resolver is linked to this Ruleset + # Virtual Networks cannot be linked to multiple forwarding ruleset + # Therefore, keep in mind that the first ruleset is the default one because the Virtual Network of the Private DNS Resolver is linked to this ruleset { name = "foo" custom_name = "forwarding-ruleset" - # Ref to the first Outbound Endpoint + # Ref to the first outbound endpoint target_outbound_endpoints = ["foo"] - vnets_ids = slice(module.vnets_to_be_linked[*].id, 0, 4) + virtual_networks_ids = slice(module.vnets_to_be_linked[*].id, 0, 4) rules = [ { @@ -157,15 +157,15 @@ module "private_dns_resolver" { { name = "bar" - # Ref to all Outbound Endpoints - # Can be an Oubound Endpoint ID, in case you want to use this DNS Forwarding Ruleset with an existing Outbound Endpoint + # Ref to all outbound endpoints + # Can be an outbound endpoint ID, in case you want to use this DNS forwarding ruleset with an existing outbound endpoint target_outbound_endpoints = [ "foo", "bar", # "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup1/providers/Microsoft.Network/dnsResolvers/dnsResolver1/outboundEndpoints/outboundEndpoint1", ] - vnets_ids = slice(module.vnets_to_be_linked[*].id, 4, 8) + virtual_networks_ids = slice(module.vnets_to_be_linked[*].id, 4, 8) rules = [ { @@ -220,41 +220,41 @@ module "private_dns_resolver" { |------|-------------|------|---------|:--------:| | client\_name | Client name/account used in naming. | `string` | n/a | yes | | custom\_name | Custom Private DNS Resolver name, generated if not set. | `string` | `""` | no | -| custom\_vnet\_name | Custom VNet name, generated if not set. | `string` | `""` | no | | default\_tags\_enabled | Option to enable or disable default tags. | `bool` | `true` | no | -| dns\_forwarding\_rulesets | List of DNS Forwarding Ruleset objects. The first DNS Forwarding Ruleset in the list is the default one because the VNet of the Private DNS Resolver is linked to it.
name                      = Short DNS Forwarding Ruleset name, used to generate the DNS Forwarding Ruleset resource name.
custom_name = Custom DNS Forwarding Ruleset name, overrides the DNS Forwarding Ruleset default resource name.
target_outbound_endpoints = List of Outbound Endpoints to link to the DNS Forwarding Ruleset. Can be the short name of the Outbound Endpoint or an Oubound Endpoint ID.
vnets_ids = List of VNets IDs to link to the DNS Forwarding Ruleset.
rules = List of Forwarding Rule objects that the DNS Forwarding Ruleset contains.
name = Short Forwarding Rule name, used to generate the Forwarding Rule resource name.
domain_name = Specifies the target domain name of the Forwarding Rule.
dns_servers_ips = List of target DNS servers IPs for the specified domain name.
custom_name = Custom Forwarding Rule name, overrides the Forwarding Rule default resource name.
enabled = Whether the Forwarding Rule is enabled or not. Default to `true`.
|
list(object({
name = string
custom_name = optional(string)
target_outbound_endpoints = optional(list(string), [])
vnets_ids = optional(list(string), [])
rules = optional(list(object({
name = string
domain_name = string
dns_servers_ips = list(string)
custom_name = optional(string)
enabled = optional(bool, true)
})), [])
}))
| `[]` | no | +| dns\_forwarding\_rulesets | List of DNS forwarding ruleset objects. The first DNS forwarding ruleset in the list is the default one because the Virtual Network of the Private DNS Resolver is linked to it.
name                      = Short DNS forwarding ruleset name, used to generate the DNS forwarding ruleset resource name.
custom_name = Custom DNS forwarding ruleset name, overrides the DNS forwarding ruleset default resource name.
target_outbound_endpoints = List of outbound endpoints to link to the DNS forwarding ruleset. Can be the short name of the outbound endpoint or an outbound endpoint ID.
virtual_networks_ids = List of Virtual Networks IDs to link to the DNS forwarding ruleset.
rules = List of forwarding rule objects that the DNS forwarding ruleset contains.
name = Short forwarding rule name, used to generate the forwarding rule resource name.
domain_name = Specifies the target domain name of the forwarding rule.
dns_servers_ips = List of target DNS servers IPs for the specified domain name.
custom_name = Custom forwarding rule name, overrides the forwarding rule default resource name.
enabled = Whether the forwarding rule is enabled or not. Default to `true`.
|
list(object({
name = string
custom_name = optional(string)
target_outbound_endpoints = optional(list(string), [])
virtual_networks_ids = optional(list(string), [])
rules = optional(list(object({
name = string
domain_name = string
dns_servers_ips = list(string)
custom_name = optional(string)
enabled = optional(bool, true)
})), [])
}))
| `[]` | no | | environment | Project environment. | `string` | n/a | yes | | extra\_tags | Extra tags to add. | `map(string)` | `{}` | no | -| inbound\_endpoints | List of Inbound Endpoint objects.
name                            = Short Inbound Endpoint name, used to generate the Inbound Endpoint resource name.
cidr = CIDR of the Inbound Endpoint Subnet.
custom_name = Custom Inbound Endpoint name, overrides the Inbound Endpoint default resource name.
custom_subnet_name = Custom Subnet name, overrides the Subnet default resource name.
default_outbound_access_enabled = Enable or disable default outbound access in Azure. See [documentation](https://learn.microsoft.com/en-us/azure/virtual-network/ip-services/default-outbound-access).
|
list(object({
name = string
cidr = string
custom_name = optional(string)
custom_subnet_name = optional(string)
default_outbound_access_enabled = optional(bool, false)
}))
| `[]` | no | +| inbound\_endpoints | List of inbound endpoint objects.
name                            = Short inbound endpoint name, used to generate the inbound endpoint resource name.
cidr = CIDR of the inbound endpoint Subnet.
custom_name = Custom inbound endpoint name, overrides the inbound endpoint default resource name.
subnet_custom_name = Custom Subnet name, overrides the Subnet default resource name.
default_outbound_access_enabled = Enable or disable default outbound access in Azure. See [documentation](https://learn.microsoft.com/en-us/azure/virtual-network/ip-services/default-outbound-access).
|
list(object({
name = string
cidr = string
custom_name = optional(string)
subnet_custom_name = optional(string)
default_outbound_access_enabled = optional(bool, false)
}))
| `[]` | no | | location | Azure location. | `string` | n/a | yes | | location\_short | Short string for Azure location. | `string` | n/a | yes | | name\_prefix | Optional prefix for the generated name. | `string` | `""` | no | | name\_suffix | Optional suffix for the generated name. | `string` | `""` | no | -| outbound\_endpoints | List of Outbound Endpoint objects.
name                            = Short Outbound Endpoint name, used to generate the Outbound Endpoint resource name.
cidr = CIDR of the Outbound Endpoint Subnet.
custom_name = Custom Outbound Endpoint name, overrides the Outbound Endpoint default resource name.
custom_subnet_name = Custom Subnet name, overrides the Subnet default resource name.
default_outbound_access_enabled = Enable or disable default outbound access in Azure. See [documentation](https://learn.microsoft.com/en-us/azure/virtual-network/ip-services/default-outbound-access).
|
list(object({
name = string
cidr = string
custom_name = optional(string)
custom_subnet_name = optional(string)
default_outbound_access_enabled = optional(bool, false)
}))
| `[]` | no | +| outbound\_endpoints | List of outbound endpoint objects.
name                            = Short outbound endpoint name, used to generate the outbound endpoint resource name.
cidr = CIDR of the outbound endpoint Subnet.
custom_name = Custom outbound endpoint name, overrides the outbound endpoint default resource name.
subnet_custom_name = Custom Subnet name, overrides the Subnet default resource name.
default_outbound_access_enabled = Enable or disable default outbound access in Azure. See [documentation](https://learn.microsoft.com/en-us/azure/virtual-network/ip-services/default-outbound-access).
|
list(object({
name = string
cidr = string
custom_name = optional(string)
subnet_custom_name = optional(string)
default_outbound_access_enabled = optional(bool, false)
}))
| `[]` | no | | resource\_group\_name | Resource Group name. | `string` | n/a | yes | | stack | Project stack name. | `string` | n/a | yes | -| vnet\_cidr | CIDR of the VNet to create for the Private DNS Resolver. One of `vnet_id` or `vnet_cidr` must be specified. | `string` | `""` | no | -| vnet\_id | ID of the existing VNet in which the Private DNS Resolver will be created. One of `vnet_id` or `vnet_cidr` must be specified. | `string` | `""` | no | +| virtual\_network\_cidr | CIDR of the Virtual Network to create for the Private DNS Resolver. One of `virtual_network_id` or `virtual_network_cidr` must be specified. | `string` | `""` | no | +| virtual\_network\_custom\_name | Custom Virtual Network name, generated if not set. | `string` | `""` | no | +| virtual\_network\_id | ID of the existing Virtual Network in which the Private DNS Resolver will be created. One of `virtual_network_id` or `virtual_network_cidr` must be specified. | `string` | `""` | no | ## Outputs | Name | Description | |------|-------------| -| dns\_forwarding\_rulesets | Maps of Private DNS Resolver DNS Forwarding Rulesets. | +| dns\_forwarding\_rulesets | Maps of Private DNS Resolver DNS forwarding rulesets. | | id | Private DNS Resolver ID. | -| inbound\_endpoints | Maps of Private DNS Resolver Inbound Endpoints. | +| inbound\_endpoints | Maps of Private DNS Resolver inbound endpoints. | | module\_subnets | Subnets module outputs. | -| module\_vnet | Virtual Network module outputs. | +| module\_virtual\_network | Virtual Network module outputs. | | name | Private DNS Resolver name. | -| outbound\_endpoints | Maps of Private DNS Resolver Outbound Endpoints. | +| outbound\_endpoints | Maps of Private DNS Resolver outbound endpoints. | | resource | Private DNS Resolver resource object. | -| resource\_dns\_forwarding\_ruleset | Private DNS Resolver DNS Forwarding Ruleset resource object. | -| resource\_forwarding\_rule | Private DNS Resolver Forwarding Rule resource object. | -| resource\_inbound\_endpoint | Private DNS Resolver Inbound Endpoint resource object. | -| resource\_outbound\_endpoint | Private DNS Resolver Outbound Endpoint resource object. | +| resource\_dns\_forwarding\_ruleset | Private DNS Resolver DNS forwarding ruleset resource object. | +| resource\_forwarding\_rule | Private DNS Resolver forwarding rule resource object. | +| resource\_inbound\_endpoint | Private DNS Resolver inbound endpoint resource object. | +| resource\_outbound\_endpoint | Private DNS Resolver outbound endpoint resource object. | | resource\_virtual\_network\_link | Private DNS Resolver Virtual Network Link resource object. | -| vnet\_id | Private DNS Resolver Virtual Network ID. | -| vnet\_name | Private DNS Resolver Virtual Network name. | +| virtual\_network\_id | Private DNS Resolver Virtual Network ID. | +| virtual\_network\_name | Private DNS Resolver Virtual Network name. | ## Related documentation diff --git a/examples/main/modules.tf b/examples/main/modules.tf index 0a663c9..4aa1d16 100644 --- a/examples/main/modules.tf +++ b/examples/main/modules.tf @@ -57,10 +57,10 @@ module "private_dns_resolver" { resource_group_name = module.rg.name ## Bring Your Own VNet - # If set, `vnet_cidr` will not be used - # vnet_id = module.my_vnet.id + # If set, `virtual_network_id` will not be used + # virtual_network_id = module.my_vnet.id - vnet_cidr = local.private_dns_resolver_vnet_cidr + virtual_network_cidr = local.private_dns_resolver_vnet_cidr inbound_endpoints = [ { @@ -86,23 +86,23 @@ module "private_dns_resolver" { }, { name = "bar" - custom_subnet_name = "bar-outbound-endpoint-subnet" + subnet_custom_name = "bar-outbound-endpoint-subnet" cidr = local.private_dns_resolver_subnets_cidrs[3] # cidr = local.my_subnets_cidrs[3] }, ] dns_forwarding_rulesets = [ - # VNets cannot be linked to multiple Forwarding Ruleset - # Therefore, keep in mind that the first Ruleset is the default one because the VNet of the Private DNS Resolver is linked to this Ruleset + # Virtual Networks cannot be linked to multiple forwarding ruleset + # Therefore, keep in mind that the first ruleset is the default one because the Virtual Network of the Private DNS Resolver is linked to this ruleset { name = "foo" custom_name = "forwarding-ruleset" - # Ref to the first Outbound Endpoint + # Ref to the first outbound endpoint target_outbound_endpoints = ["foo"] - vnets_ids = slice(module.vnets_to_be_linked[*].id, 0, 4) + virtual_networks_ids = slice(module.vnets_to_be_linked[*].id, 0, 4) rules = [ { @@ -120,15 +120,15 @@ module "private_dns_resolver" { { name = "bar" - # Ref to all Outbound Endpoints - # Can be an Oubound Endpoint ID, in case you want to use this DNS Forwarding Ruleset with an existing Outbound Endpoint + # Ref to all outbound endpoints + # Can be an outbound endpoint ID, in case you want to use this DNS forwarding ruleset with an existing outbound endpoint target_outbound_endpoints = [ "foo", "bar", # "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup1/providers/Microsoft.Network/dnsResolvers/dnsResolver1/outboundEndpoints/outboundEndpoint1", ] - vnets_ids = slice(module.vnets_to_be_linked[*].id, 4, 8) + virtual_networks_ids = slice(module.vnets_to_be_linked[*].id, 4, 8) rules = [ { diff --git a/locals-outputs.tf b/locals-outputs.tf index a87f06d..e17f9ee 100644 --- a/locals-outputs.tf +++ b/locals-outputs.tf @@ -20,10 +20,10 @@ locals { dns_forwarding_rulesets_output = { for ruleset_name in keys(local.dns_forwarding_rulesets) : ruleset_name => { - id = azurerm_private_dns_resolver_dns_forwarding_ruleset.main[ruleset_name].id - name = azurerm_private_dns_resolver_dns_forwarding_ruleset.main[ruleset_name].name - rules_ids = [for rule in local.forwarding_rules : azurerm_private_dns_resolver_forwarding_rule.main[rule.name].id if rule.ruleset_name == ruleset_name] - vnet_links_ids = [for index, link in local.vnet_links_flattened : azurerm_private_dns_resolver_virtual_network_link.main[index].id if link.ruleset_name == ruleset_name] + id = azurerm_private_dns_resolver_dns_forwarding_ruleset.main[ruleset_name].id + name = azurerm_private_dns_resolver_dns_forwarding_ruleset.main[ruleset_name].name + rules_ids = [for rule in local.forwarding_rules : azurerm_private_dns_resolver_forwarding_rule.main[rule.name].id if rule.ruleset_name == ruleset_name] + virtual_network_links_ids = [for index, link in local.virtual_network_links_flattened : azurerm_private_dns_resolver_virtual_network_link.main[index].id if link.ruleset_name == ruleset_name] } } } diff --git a/locals.tf b/locals.tf index e92c94e..e1b0b5a 100644 --- a/locals.tf +++ b/locals.tf @@ -6,22 +6,22 @@ locals { endpoints = merge(local.inbound_endpoints, local.outbound_endpoints) - vnet_id = one(compact(concat( - [var.vnet_id], + virtual_network_id = one(compact(concat( + [var.virtual_network_id], module.vnet[*].id, ))) - vnet_name = one(compact(concat( - [element(reverse(split("/", var.vnet_id)), 0)], + virtual_network_name = one(compact(concat( + [element(reverse(split("/", var.virtual_network_id)), 0)], module.vnet[*].name, ))) - vnet_links_flattened = flatten([ + virtual_network_links_flattened = flatten([ for index, ruleset in var.dns_forwarding_rulesets : [ - for id in concat(index == 0 ? [local.vnet_id] : [], ruleset.vnets_ids) : { - name = format("%s-link", element(reverse(split("/", id)), 0)) - vnet_id = id - ruleset_name = ruleset.name + for id in concat(index == 0 ? [local.virtual_network_id] : [], ruleset.virtual_networks_ids) : { + name = format("%s-link", element(reverse(split("/", id)), 0)) + virtual_network_id = id + ruleset_name = ruleset.name } ] ]) diff --git a/m-network.tf b/m-network.tf index 1ccd655..20451fa 100644 --- a/m-network.tf +++ b/m-network.tf @@ -2,7 +2,7 @@ module "vnet" { source = "claranet/vnet/azurerm" version = "~> 8.0.0" - count = var.vnet_id == "" ? 1 : 0 + count = var.virtual_network_id == "" ? 1 : 0 location = var.location location_short = var.location_short @@ -14,9 +14,9 @@ module "vnet" { name_prefix = local.name_prefix name_suffix = local.name_suffix - custom_name = var.custom_vnet_name + custom_name = var.virtual_network_custom_name - cidrs = [var.vnet_cidr] + cidrs = [var.virtual_network_cidr] default_tags_enabled = var.default_tags_enabled @@ -37,10 +37,10 @@ module "subnets" { resource_group_name = var.resource_group_name name_prefix = local.name_prefix - name_suffix = each.value.custom_subnet_name != "" ? local.name_suffix != "" ? format("%s-%s", local.name_suffix, each.key) : each.key : "" - custom_name = each.value.custom_subnet_name + name_suffix = each.value.subnet_custom_name != "" ? local.name_suffix != "" ? format("%s-%s", local.name_suffix, each.key) : each.key : "" + custom_name = each.value.subnet_custom_name - virtual_network_name = local.vnet_name + virtual_network_name = local.virtual_network_name delegations = local.subnets_delegation private_link_service_enabled = true diff --git a/outputs.tf b/outputs.tf index f4c30ac..c83d794 100644 --- a/outputs.tf +++ b/outputs.tf @@ -4,22 +4,22 @@ output "resource" { } output "resource_inbound_endpoint" { - description = "Private DNS Resolver Inbound Endpoint resource object." + description = "Private DNS Resolver inbound endpoint resource object." value = azurerm_private_dns_resolver_inbound_endpoint.main } output "resource_outbound_endpoint" { - description = "Private DNS Resolver Outbound Endpoint resource object." + description = "Private DNS Resolver outbound endpoint resource object." value = azurerm_private_dns_resolver_outbound_endpoint.main } output "resource_dns_forwarding_ruleset" { - description = "Private DNS Resolver DNS Forwarding Ruleset resource object." + description = "Private DNS Resolver DNS forwarding ruleset resource object." value = azurerm_private_dns_resolver_dns_forwarding_ruleset.main } output "resource_forwarding_rule" { - description = "Private DNS Resolver Forwarding Rule resource object." + description = "Private DNS Resolver forwarding rule resource object." value = azurerm_private_dns_resolver_forwarding_rule.main } @@ -28,7 +28,7 @@ output "resource_virtual_network_link" { value = azurerm_private_dns_resolver_virtual_network_link.main } -output "module_vnet" { +output "module_virtual_network" { description = "Virtual Network module outputs." value = module.vnet } @@ -48,27 +48,27 @@ output "name" { value = azurerm_private_dns_resolver.main.name } -output "vnet_id" { +output "virtual_network_id" { description = "Private DNS Resolver Virtual Network ID." - value = local.vnet_id + value = local.virtual_network_id } -output "vnet_name" { +output "virtual_network_name" { description = "Private DNS Resolver Virtual Network name." - value = local.vnet_name + value = local.virtual_network_name } output "inbound_endpoints" { - description = "Maps of Private DNS Resolver Inbound Endpoints." + description = "Maps of Private DNS Resolver inbound endpoints." value = local.inbound_endpoints_output } output "outbound_endpoints" { - description = "Maps of Private DNS Resolver Outbound Endpoints." + description = "Maps of Private DNS Resolver outbound endpoints." value = local.outbound_endpoints_output } output "dns_forwarding_rulesets" { - description = "Maps of Private DNS Resolver DNS Forwarding Rulesets." + description = "Maps of Private DNS Resolver DNS forwarding rulesets." value = local.dns_forwarding_rulesets_output } diff --git a/r-private-dns-resolver.tf b/r-private-dns-resolver.tf index 5ca88e3..e371bd6 100644 --- a/r-private-dns-resolver.tf +++ b/r-private-dns-resolver.tf @@ -4,7 +4,7 @@ resource "azurerm_private_dns_resolver" "main" { resource_group_name = var.resource_group_name - virtual_network_id = local.vnet_id + virtual_network_id = local.virtual_network_id tags = merge(local.default_tags, var.extra_tags) } @@ -99,12 +99,12 @@ moved { } resource "azurerm_private_dns_resolver_virtual_network_link" "main" { - count = length(local.vnet_links_flattened) + count = length(local.virtual_network_links_flattened) - name = local.vnet_links_flattened[count.index].name + name = local.virtual_network_links_flattened[count.index].name - dns_forwarding_ruleset_id = azurerm_private_dns_resolver_dns_forwarding_ruleset.main[local.vnet_links_flattened[count.index].ruleset_name].id - virtual_network_id = local.vnet_links_flattened[count.index].vnet_id + dns_forwarding_ruleset_id = azurerm_private_dns_resolver_dns_forwarding_ruleset.main[local.virtual_network_links_flattened[count.index].ruleset_name].id + virtual_network_id = local.virtual_network_links_flattened[count.index].virtual_network_id } moved { diff --git a/variables-naming.tf b/variables-naming.tf index 5a11b66..add801b 100644 --- a/variables-naming.tf +++ b/variables-naming.tf @@ -18,8 +18,8 @@ variable "custom_name" { default = "" } -variable "custom_vnet_name" { - description = "Custom VNet name, generated if not set." +variable "virtual_network_custom_name" { + description = "Custom Virtual Network name, generated if not set." type = string default = "" } diff --git a/variables.tf b/variables.tf index 299121b..a8ba9f5 100644 --- a/variables.tf +++ b/variables.tf @@ -28,26 +28,26 @@ variable "resource_group_name" { type = string } -variable "vnet_id" { - description = "ID of the existing VNet in which the Private DNS Resolver will be created. One of `vnet_id` or `vnet_cidr` must be specified." +variable "virtual_network_id" { + description = "ID of the existing Virtual Network in which the Private DNS Resolver will be created. One of `virtual_network_id` or `virtual_network_cidr` must be specified." type = string default = "" } -variable "vnet_cidr" { - description = "CIDR of the VNet to create for the Private DNS Resolver. One of `vnet_id` or `vnet_cidr` must be specified." +variable "virtual_network_cidr" { + description = "CIDR of the Virtual Network to create for the Private DNS Resolver. One of `virtual_network_id` or `virtual_network_cidr` must be specified." type = string default = "" } variable "inbound_endpoints" { description = <