Skip to content

Azure/terraform-azurerm-avm-ptn-network-private-link-private-dns-zones

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

terraform-azurerm-avm-ptn-network-private-link-private-dns-zones

This module deploys all known Azure Private DNS Zones for Azure Services that support Private Link as documented and detailed here in Azure Private Endpoint private DNS zone values.

The module also has logic built in to it to handle the replacements of the following strings in the Private DNS Zone Names to the appropriate Azure Region name, short name or geo-code as required:

  • ...{regionName}...
  • ...{regionCode}...

Note

This module only supports Azure Public/Commercial today and NOT Azure US Government Cloud (a.k.a. Fairfax) or Azure China Cloud (a.k.a. Mooncake). If you would like to see support added for these clouds please raise an issue/feature request on this repo/module.

Migrating from versions v0.17.0 and prior to v0.18.0 and later

Versions v0.17.0 and prior of this module used azurerm as its primary provider as the version of the Azure/avm-res-network-privatednszone/azurerm module it leveraged was built using azurerm as its primary provider also.

As of version v0.18.0 and later of this module, the module has been re-architected to use azapi as its primary provider as the version of the Azure/avm-res-network-privatednszone/azurerm module (v0.4.1) it now leverages is built using azapi as its primary provider also.

Version v0.18.0 of this module includes support for the Resolution Policy on the Private DNS Zone Virtual Network Links to allow for NXDomain Redirects to be configured, as documented in Fallback to internet for Azure Private DNS zones; see the new input properties in the private_link_private_dns_zones (private_dns_zone_supports_private_link), private_link_private_dns_zones_additional (private_dns_zone_supports_private_link), and virtual_network_resource_ids_to_link_to (resolution_policy) input variables.

This means that if you are using version v0.17.0 or prior of this module and wish to upgrade to version v0.18.0 or later, you will need to make some changes to your code to complete a successful upgrade.

Whilst we have used moved blocks in the module itself, see moved.tf, to help with the migration, we have only been able to do this for the resources that are default created by the module. These are:

  • The Private Link Private DNS Zones declared in the default value of the private_link_private_dns_zones input variable.
  • The Resource Group created by the module if you are not using an existing Resource Group, as controlled by the resource_group_creation_enabled input variable.

For other resources that can be created by this module, you will need to declare your own moved blocks in your code (root module) to help with the migration. These resources are:

  • Private DNS Zones declared in the private_link_private_dns_zones_additional input variable.
  • Private DNS Zones Virtual Network Links declared in the virtual_network_resource_ids_to_link_to input variable.
  • Role Assignments created on the Resource Group declared in the resource_group_role_assignments input variable.
  • Locks created on the Resource Group declared in the lock input variable.

You may decide it is not worth migrating some of these resources and instead allow Terraform to delete and recreate them. Such as the Role Assignments and Locks on the Resource Group. However, you should consider the impact of this before doing so based on your understanding of your environment and code.

To help with this we have provided some example moved blocks that you can copy, paste, and amend/edit into your code (root module) to help with the migration. You can find these example moved blocks in the following example's main.tf files:

You will also note that there are a number of new resources to be created relating to telemetry and the modtm provider, these do not need any moved blocks and are expected to be created as new resources to improve our AVM modules telemetry and insights.

If you have any questions or need any help with the migration please raise an issue on this repo/module and we will do our best to help. However, we believe we have provided comprehensive guidance and examples to help with the migration to prevent the deletion of critical resources.


Important

As the overall AVM framework is not GA (generally available) yet - the CI framework and test automation is not fully functional and implemented across all supported languages yet - breaking changes are expected, and additional customer feedback is yet to be gathered and incorporated. Hence, modules MUST NOT be published at version 1.0.0 or higher at this time.

All module MUST be published as a pre-release version (e.g., 0.1.0, 0.1.1, 0.2.0, etc.) until the AVM framework becomes GA.

However, it is important to note that this DOES NOT mean that the modules cannot be consumed and utilized. They CAN be leveraged in all types of environments (dev, test, prod etc.). Consumers can treat them just like any other IaC module and raise issues or feature requests against them as they learn from the usage of the module. Consumers should also read the release notes for each version, if considering updating to a more recent version of a module to see if there are any considerations or breaking changes etc.

Requirements

The following requirements are needed by this module:

Resources

The following resources are used by this module:

Required Inputs

The following input variables are required:

Description: Azure region where the each of the Private Link Private DNS Zones created and Resource Group, if created, will be deployed.

Type: string

Description: The resource group where the resources will be deployed. Either the name of the new resource group to create or the name of an existing resource group.

Type: string

Optional Inputs

The following input variables are optional (have default values):

Description: This variable controls whether or not telemetry is enabled for the module.
For more information see https://aka.ms/avm/telemetryinfo.
If it is set to false, then no telemetry will be collected.

Type: bool

Default: true

Description: Controls the Resource Lock configuration for the Resource Group that hosts the Private DNS Zones. The following properties can be specified:

  • kind - (Required) The type of lock. Possible values are \"CanNotDelete\" and \"ReadOnly\".
  • name - (Optional) The name of the lock. If not specified, a name will be generated based on the kind value. Changing this forces the creation of a new resource.

Type:

object({
    kind = string
    name = optional(string, null)
  })

Default: null

Description: A set of Private Link Private DNS Zones to exclude. Either DNS zone names or the private_link_private_dns_zones map key name (e.g. 'azure_ml') must match what is provided as the default values or any input to the private_link_private_dns_zones parameter e.g. privatelink.api.azureml.ms or privatelink.{regionCode}.backup.windowsazure.com or azure_ml.

Type: set(string)

Default: []

Description: A set of Private Link Private DNS Zones to create. Each element must be a valid DNS zone name.

  • zone_name - The name of the Private Link Private DNS Zone to create. This can include placeholders for the region code and region name, which will be replaced with the appropriate values based on the location variable.
  • private_dns_zone_supports_private_link - (Optional) Whether the Private Link Private DNS Zone supports Private Link. Defaults to true.
  • custom_iterator - (Optional) An object that defines a custom iterator for the Private Link Private DNS Zone. This is used to create multiple Private Link Private DNS Zones with the same base name but different replacements. The object must contain:
    • replacement_placeholder - The placeholder to replace in the zone_name with the custom replacement value.
    • replacement_values - A map of values to use for the custom iterator, where the value is the value to replace in the zone_name.

NOTE:

  • Private Link Private DNS Zones that have {{regionCode}} in the name will be replaced with the Geo Code of the Region you specified in the location variable, if available, as documented here.
    • e.g. If UK South or uksouth was specified as the region in the location variable, {{regionCode}} would be replaced with uks in the Private DNS Zone name.
  • Private Link Private DNS Zones that have {{regionName}} in the name will be replaced with the short name of the Region you specified in the location variable, if available, as documented here.
    • e.g. If UK South or uksouth was specified as the region in the location variable, {{regionName}} would be replaced with uksouth in the Private DNS Zone name.

IMPORTANT:

The folowing Private Link Private DNS Zones have been removed from the default value for this variable as they require additional placeholders to be replaced that will only be known by the caller of the module at runtime and cannot be determined by the module itself. If you have a requirement to create these Private Link Private DNS Zones, you must provide the full list of Private Link Private DNS Zones to create as a set in the private_link_private_dns_zones variable, using the default value as a reference. The list of Private Link Private DNS Zones that have been removed are:

  • {subzone}.privatelink.{regionName}.azmk8s.io
  • privatelink.{dnsPrefix}.database.windows.net

We have also removed the following Private Link Private DNS Zones from the default value for this variable as they should only be created and used with in specific scenarios:

  • privatelink.azure.com

Type:

map(object({
    zone_name                              = optional(string, null)
    private_dns_zone_supports_private_link = optional(bool, true)
    custom_iterator = optional(object({
      replacement_placeholder = string
      replacement_values      = map(string)
    }))
  }))

Default:

{
  "azure_acr_registry": {
    "zone_name": "privatelink.azurecr.io"
  },
  "azure_ai_cog_svcs": {
    "zone_name": "privatelink.cognitiveservices.azure.com"
  },
  "azure_ai_oai": {
    "zone_name": "privatelink.openai.azure.com"
  },
  "azure_ai_services": {
    "zone_name": "privatelink.services.ai.azure.com"
  },
  "azure_aks_mgmt": {
    "zone_name": "privatelink.{regionName}.azmk8s.io"
  },
  "azure_api_management": {
    "zone_name": "privatelink.azure-api.net"
  },
  "azure_app_configuration": {
    "zone_name": "privatelink.azconfig.io"
  },
  "azure_app_service": {
    "zone_name": "privatelink.azurewebsites.net"
  },
  "azure_arc_guest_configuration": {
    "zone_name": "privatelink.guestconfiguration.azure.com"
  },
  "azure_arc_hybrid_compute": {
    "zone_name": "privatelink.his.arc.azure.com"
  },
  "azure_arc_kubernetes": {
    "zone_name": "privatelink.dp.kubernetesconfiguration.azure.com"
  },
  "azure_attestation": {
    "zone_name": "privatelink.attest.azure.net"
  },
  "azure_automation": {
    "zone_name": "privatelink.azure-automation.net"
  },
  "azure_avd_feed_mgmt": {
    "zone_name": "privatelink.wvd.microsoft.com"
  },
  "azure_avd_global": {
    "zone_name": "privatelink-global.wvd.microsoft.com"
  },
  "azure_backup": {
    "zone_name": "privatelink.{regionCode}.backup.windowsazure.com"
  },
  "azure_batch": {
    "zone_name": "privatelink.batch.azure.com"
  },
  "azure_bot_svc_bot": {
    "zone_name": "privatelink.directline.botframework.com"
  },
  "azure_bot_svc_token": {
    "zone_name": "privatelink.token.botframework.com"
  },
  "azure_container_apps": {
    "zone_name": "privatelink.{regionName}.azurecontainerapps.io"
  },
  "azure_cosmos_db_analytical": {
    "zone_name": "privatelink.analytics.cosmos.azure.com"
  },
  "azure_cosmos_db_cassandra": {
    "zone_name": "privatelink.cassandra.cosmos.azure.com"
  },
  "azure_cosmos_db_gremlin": {
    "zone_name": "privatelink.gremlin.cosmos.azure.com"
  },
  "azure_cosmos_db_mongo": {
    "zone_name": "privatelink.mongo.cosmos.azure.com"
  },
  "azure_cosmos_db_mongo_vcore": {
    "zone_name": "privatelink.mongocluster.cosmos.azure.com"
  },
  "azure_cosmos_db_postgres": {
    "zone_name": "privatelink.postgres.cosmos.azure.com"
  },
  "azure_cosmos_db_sql": {
    "zone_name": "privatelink.documents.azure.com"
  },
  "azure_cosmos_db_table": {
    "zone_name": "privatelink.table.cosmos.azure.com"
  },
  "azure_data_explorer": {
    "zone_name": "privatelink.{regionName}.kusto.windows.net"
  },
  "azure_data_factory": {
    "zone_name": "privatelink.datafactory.azure.net"
  },
  "azure_data_factory_portal": {
    "zone_name": "privatelink.adf.azure.com"
  },
  "azure_data_lake_gen2": {
    "zone_name": "privatelink.dfs.core.windows.net"
  },
  "azure_databricks_ui_api": {
    "zone_name": "privatelink.azuredatabricks.net"
  },
  "azure_digital_twins": {
    "zone_name": "privatelink.digitaltwins.azure.net"
  },
  "azure_event_grid": {
    "zone_name": "privatelink.eventgrid.azure.net"
  },
  "azure_file_sync": {
    "zone_name": "privatelink.afs.azure.net"
  },
  "azure_grafana": {
    "zone_name": "privatelink.grafana.azure.com"
  },
  "azure_hdinsight": {
    "zone_name": "privatelink.azurehdinsight.net"
  },
  "azure_healthcare": {
    "zone_name": "privatelink.azurehealthcareapis.com"
  },
  "azure_healthcare_dicom": {
    "zone_name": "privatelink.dicom.azurehealthcareapis.com"
  },
  "azure_healthcare_fhir": {
    "zone_name": "privatelink.fhir.azurehealthcareapis.com"
  },
  "azure_healthcare_workspaces": {
    "zone_name": "privatelink.workspace.azurehealthcareapis.com"
  },
  "azure_iot_central": {
    "zone_name": "privatelink.azureiotcentral.com"
  },
  "azure_iot_hub": {
    "zone_name": "privatelink.azure-devices.net"
  },
  "azure_iot_hub_provisioning": {
    "zone_name": "privatelink.azure-devices-provisioning.net"
  },
  "azure_iot_hub_update": {
    "zone_name": "privatelink.api.adu.microsoft.com"
  },
  "azure_key_vault": {
    "zone_name": "privatelink.vaultcore.azure.net"
  },
  "azure_log_analytics": {
    "zone_name": "privatelink.oms.opinsights.azure.com"
  },
  "azure_log_analytics_data": {
    "zone_name": "privatelink.ods.opinsights.azure.com"
  },
  "azure_managed_hsm": {
    "zone_name": "privatelink.managedhsm.azure.net"
  },
  "azure_managed_prometheus": {
    "zone_name": "privatelink.{regionName}.prometheus.monitor.azure.com"
  },
  "azure_maria_db_server": {
    "zone_name": "privatelink.mariadb.database.azure.com"
  },
  "azure_media_services_delivery": {
    "zone_name": "privatelink.media.azure.net"
  },
  "azure_migration_service": {
    "zone_name": "privatelink.prod.migration.windowsazure.com"
  },
  "azure_ml": {
    "zone_name": "privatelink.api.azureml.ms"
  },
  "azure_ml_notebooks": {
    "zone_name": "privatelink.notebooks.azure.net"
  },
  "azure_monitor": {
    "zone_name": "privatelink.monitor.azure.com"
  },
  "azure_monitor_agent": {
    "zone_name": "privatelink.agentsvc.azure-automation.net"
  },
  "azure_mysql_db_server": {
    "zone_name": "privatelink.mysql.database.azure.com"
  },
  "azure_postgres_sql_server": {
    "zone_name": "privatelink.postgres.database.azure.com"
  },
  "azure_power_bi_dedicated": {
    "zone_name": "privatelink.pbidedicated.windows.net"
  },
  "azure_power_bi_power_query": {
    "zone_name": "privatelink.tip1.powerquery.microsoft.com"
  },
  "azure_power_bi_tenant_analysis": {
    "zone_name": "privatelink.analysis.windows.net"
  },
  "azure_purview_account": {
    "zone_name": "privatelink.purview.azure.com"
  },
  "azure_purview_studio": {
    "zone_name": "privatelink.purviewstudio.azure.com"
  },
  "azure_redis_cache": {
    "zone_name": "privatelink.redis.cache.windows.net"
  },
  "azure_redis_enterprise": {
    "zone_name": "privatelink.redisenterprise.cache.azure.net"
  },
  "azure_search": {
    "zone_name": "privatelink.search.windows.net"
  },
  "azure_service_hub": {
    "zone_name": "privatelink.servicebus.windows.net"
  },
  "azure_signalr_service": {
    "zone_name": "privatelink.service.signalr.net"
  },
  "azure_site_recovery": {
    "zone_name": "privatelink.siterecovery.windowsazure.com"
  },
  "azure_sql_server": {
    "zone_name": "privatelink.database.windows.net"
  },
  "azure_static_web_apps": {
    "zone_name": "privatelink.azurestaticapps.net"
  },
  "azure_static_web_apps_partitioned": {
    "custom_iterator": {
      "replacement_placeholder": "partitionId",
      "replacement_values": {
        "1": "1",
        "2": "2",
        "3": "3",
        "4": "4",
        "5": "5"
      }
    },
    "zone_name": "privatelink.{partitionId}.azurestaticapps.net"
  },
  "azure_storage_blob": {
    "zone_name": "privatelink.blob.core.windows.net"
  },
  "azure_storage_file": {
    "zone_name": "privatelink.file.core.windows.net"
  },
  "azure_storage_queue": {
    "zone_name": "privatelink.queue.core.windows.net"
  },
  "azure_storage_table": {
    "zone_name": "privatelink.table.core.windows.net"
  },
  "azure_storage_web": {
    "zone_name": "privatelink.web.core.windows.net"
  },
  "azure_synapse": {
    "zone_name": "privatelink.azuresynapse.net"
  },
  "azure_synapse_dev": {
    "zone_name": "privatelink.dev.azuresynapse.net"
  },
  "azure_synapse_sql": {
    "zone_name": "privatelink.sql.azuresynapse.net"
  },
  "azure_web_pubsub": {
    "zone_name": "privatelink.webpubsub.azure.com"
  }
}

Description: A set of Private Link Private DNS Zones to create in addition to the zones supplied in private_link_private_dns_zones. Each element must be a valid DNS zone name.

The purpose of this variable is to allow the use of our default zones and just add any additional zones without having to redefine the entire set of default zones.

  • zone_name - The name of the Private Link Private DNS Zone to create. This can include placeholders for the region code and region name, which will be replaced with the appropriate values based on the location variable.
  • private_dns_zone_supports_private_link - (Optional) Whether the Private Link Private DNS Zone supports Private Link. Defaults to true.
  • custom_iterator - (Optional) An object that defines a custom iterator for the Private Link Private DNS Zone. This is used to create multiple Private Link Private DNS Zones with the same base name but different replacements. The object must contain:
    • replacement_placeholder - The placeholder to replace in the zone_name with the custom iterator replacement value.
    • replacement_values - A map of values to use for the custom iterator, where the value is the value to replace in the zone_name.

Type:

map(object({
    zone_name                              = optional(string, null)
    private_dns_zone_supports_private_link = optional(bool, true)
    custom_iterator = optional(object({
      replacement_placeholder = string
      replacement_values      = map(string)
    }))
  }))

Default: {}

Description: This variable controls whether or not the Private Link Private DNS Zones should be filtered based on the zone name. If enabled, the regex_filter will be used to filter the Private Link Private DNS Zones based on the zone name.

  • enabled - (Optional) Whether to enable filtering of the Private Link Private DNS Zones. Defaults to false.
  • regex_filter - (Optional) The regular expression filter to apply to the Private Link Private DNS Zones. The default value is {regionName}|{regionCode}, which will filter for regional Private Link Private DNS Zones often needed for secondary regions. You can specify a custom filter to match your requirements.

Type:

object({
    enabled      = optional(bool, false)
    regex_filter = optional(string, "{regionName}|{regionCode}")
  })

Default: {}

Description: This variable controls whether or not the resource group should be created. If set to false, the resource group must be created elsewhere and the resource group name must be provided to the module. If set to true, the resource group will be created by the module using the name provided in resource_group_name.

Type: bool

Default: true

Description: A map of role assignments to create on the Resource Group. The map key is deliberately arbitrary to avoid issues where map keys maybe unknown at plan time.

  • role_definition_id_or_name - The ID or name of the role definition to assign to the principal.
  • principal_id - The ID of the principal to assign the role to.
  • principal_type - (Optional) The type of the principal. Possible values are User, Group, and ServicePrincipal. It is necessary to explicitly set this attribute when creating role assignments if the principal creating the assignment is constrained by ABAC rules that filters on the PrincipalType attribute.
  • description - The description of the role assignment.
  • skip_service_principal_aad_check - If set to true, skips the Entra ID check for the service principal in the tenant. Defaults to false.
  • condition - The condition which will be used to scope the role assignment.
  • condition_version - The version of the condition syntax. Valid values are '2.0'.

Note: only set skip_service_principal_aad_check to true if you are assigning a role to a service principal.

Type:

map(object({
    role_definition_id_or_name             = string
    principal_id                           = string
    principal_type                         = optional(string, null)
    description                            = optional(string, null)
    skip_service_principal_aad_check       = optional(bool, false)
    condition                              = optional(string, null)
    condition_version                      = optional(string, null)
    delegated_managed_identity_resource_id = optional(string, null)
  }))

Default: {}

Description: (Optional) Tags of the resource.

Type: map(string)

Default: null

Description: A map of timeouts objects, per resource type, to apply to the creation and destruction of resources the following resources:

  • dns_zones - (Optional) The timeouts for DNS Zones.
  • vnet_links - (Optional) The timeouts for DNS Zones Virtual Network Links.

Each timeout object has the following optional attributes:

  • create - (Optional) The timeout for creating the resource. Defaults to 5m apart from policy assignments, where this is set to 15m.
  • delete - (Optional) The timeout for deleting the resource. Defaults to 5m.
  • update - (Optional) The timeout for updating the resource. Defaults to 5m.
  • read - (Optional) The timeout for reading the resource. Defaults to 5m.

Type:

object({
    dns_zones = optional(object({
      create = optional(string, "30m")
      delete = optional(string, "30m")
      update = optional(string, "30m")
      read   = optional(string, "5m")
      }), {}
    )
    vnet_links = optional(object({
      create = optional(string, "30m")
      delete = optional(string, "30m")
      update = optional(string, "30m")
      read   = optional(string, "5m")
      }), {}
    )
  })

Default: {}

Description: A prefix to use for the names of the Virtual Network Links created.
The zone_key and vnet_key will be replaced with the keys of the DNS zone and Virtual Network respectively.

Type: string

Default: "vnet_link-${zone_key}-${vnet_key}"

Description: A map of objects of Virtual Network Resource IDs to link to the Private Link Private DNS Zones created. The map key is deliberately arbitrary to avoid issues where map keys maybe unknown at plan time.

  • vnet_resource_id - (Optional) The resource ID of the Virtual Network to link to the Private Link Private DNS Zones created to.
  • virtual_network_link_name_template_override - (Optional) An override for the name of the Virtual Network Link to create. If not specified, the name will be generated based on the virtual_network_link_name_template variable and the dns zone key and virtual network map key. This name will apply to every DNS zone link for that virtual network.
  • resolution_policy - (Optional) The resolution policy for the Virtual Network Link. Possible value are Default and NxDomainRedirect.

Type:

map(object({
    vnet_resource_id                            = optional(string, null)
    virtual_network_link_name_template_override = optional(string, null)
    resolution_policy                           = optional(string, "Default")
  }))

Default: {}

Outputs

The following outputs are exported:

Description: The final map of private link private DNS zones to link to virtual networks including the region name replacements as required.

Description: The map of private DNS zones to resource ids.

Description: The resource ID of the resource group that the Private DNS Zones are deployed into.

Modules

The following Modules are called:

Source: Azure/avm-utl-interfaces/azure

Version: 0.5.0

Source: Azure/avm-res-network-privatednszone/azurerm

Version: 0.4.1

Source: Azure/avm-utl-regions/azurerm

Version: 0.7.0

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 https://go.microsoft.com/fwlink/?LinkID=824704. 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.

About

Terraform Azure Verified Pattern Module for Private Link Private DNS Zones

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors 10