Private DNS Zone module can deploy these resources:
- azurerm_private_dns_zone (required)
- azurerm_private_dns_zone_virtual_network_link (optional)
Example variables structure is located in variables.md.
Example use case is located in test-case/locals.tf.
You can also see changelog.
Terraform documentation:
https://registry.terraform.io/providers/hashicorp/azurerm/4.14.0/docs/resources/private_dns_zone
WARNING: AzureRM provider had been updated to a new major version. Many breaking changes were implemented. See the providers guide for more information.
There are a few things you need to do to import resources into .tfstate. In the example below there are resources which can be imported within the module. You may need to modify these commands to the OS on which they will be running (Refer to the documentation for additional details).
- terraform import '
<path-to-module>
.azurerm_private_dns_zone.private_dns_zone["<private-dns-zone-name>
"]' '/subscriptions/<subscription-id>
/resourceGroups/<resource-group-name>
/providers/Microsoft.Network/privateDnsZones/<private-dns-zone-name>
'
- terraform import '
<path-to-module>
.azurerm_private_dns_zone_virtual_network_link.private_dns_zone_virtual_network_link["<private-dns-zone-name>
_<private-dns-zone-virtual-network-link-name>
"]' '/subscriptions/<subscription-id>
/resourceGroups/<resource-group-name>
/providers/Microsoft.Network/privateDnsZones/<private-dns-zone-name>
/virtualNetworkLinks/<private-dns-zone-virtual-network-link-name>
'
NOTE:
<path-to-module>
is terraform logical path from root. e.g. module.private_dns_zone
Output Name | Value | Comment |
---|---|---|
outputs | name | |
id | ||
virtual_network_links | Virtual Network Link outputs | |
name | ||
id |
In the example below, outputted id of the deployed Private DNS Zone module is used as a value for the scope variable in Role Assignment resource.
module "dns" {
source = "[email protected]:seyfor-csc/mit.private-dns-zone.git?ref=v1.0.0"
config = [
{
name = "sey.terraform.ne.dns"
resource_group_name = "SEY-TERRAFORM-NE-RG01"
}
]
}
data "azurerm_client_config" "azurerm_client_config" {
}
resource "azurerm_role_assignment" "role_assignment" {
scope = module.dns.outputs.sey-terraform-ne-dns.id # This is how to use output values. Dots are replaced with hyphens.
role_definition_name = "Contributor"
principal_id = data.azurerm_client_config.azurerm_client_config.object_id
}
Private DNS zone has dots in its name. However, dots are not allowed in the output names. Therefore, these dots are replaced with hyphens in the outputs. For example, if you have a private DNS zone named sey.terraform.ne.dns
in your configuration, the output will be sey-terraform-ne-dns
. Reference the Example usage of outputs (section above) to see how to use the private DNS zone output.
We currently log no issues in this module.