diff --git a/README.md b/README.md index ea6ca31..6cccffd 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,51 @@ Terraform module for creation Azure <> ## Usage +## Requirements + +| Name | Version | +|---------------------------------------------------------------------------|-----------| +| [terraform](#requirement\_terraform) | >= 1.0.0 | +| [azurerm](#requirement\_azurerm) | >= 3.23.0 | + +## Providers + +| Name | Version | +|---------------------------------------------------------------|---------| +| [azurerm](#provider\_azurerm) | 3.24.0 | + +## Modules + +No modules. + +## Resources + +| Name | Type | +|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------| +| [azurerm_private_dns_zone.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/private_dns_zone) | resource | +| [azurerm_private_dns_zone_virtual_network_link.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/private_dns_zone_virtual_network_link) | resource | + +## Inputs + +| Name | Description | Type | Default | Required | +|------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------|---------------|-------------------------------------|:--------:| +| [create\_private\_zone](#input\_create\_private\_zone) | Condition for Private DNS Zone creation | `bool` | n/a | yes | +| [env](#input\_env) | The prefix which should be used for all resources in this environment | `string` | n/a | yes | +| [location](#input\_location) | The Azure Region in which all resources in this example should be created. | `string` | n/a | yes | +| [project](#input\_project) | Project/stream name (e.g. datalake) | `string` | n/a | yes | +| [resource\_group](#input\_resource\_group) | The Azure Region in which all resources in this example should be created. | `string` | n/a | yes | +| [tags](#input\_tags) | list of tags | `map(string)` | n/a | yes | +| [dns\_zone\_name](#input\_dns\_zone\_name) | Name of Private DNS Zone | `string` | `"privatelink.azuredatabricks.net"` | no | +| [vnet_map](#input\_vnet\_map) | Map of Virtual Network Name to Id, used to create VNet Link to Private DNS | `map(string)` | `{}` | no | +| [external\_dns\_zone\_name](#input\_external\_dns\_zone\_name) | Name of Imported Private DNS Zone. Provide value in case creation of new Private DNS Zone is disabled | `string` | `""` | no | + +## Outputs + +| Name | Description | +|-------------------------------------------------------|----------------------------------| +| [id](#output\_id) | Private DNS Zone Id | +| [id](#output\_name) | Private DNS Zone Name | +| [id](#output\_link\_id) | List of Virtual Network Link Ids | diff --git a/main.tf b/main.tf new file mode 100644 index 0000000..cdb21ef --- /dev/null +++ b/main.tf @@ -0,0 +1,17 @@ +resource "azurerm_private_dns_zone" "this" { + count = var.create_private_zone == true ? 1 : 0 + + name = var.dns_zone_name + resource_group_name = var.resource_group + tags = var.tags +} + +resource "azurerm_private_dns_zone_virtual_network_link" "this" { + for_each = var.vnet_map == {} ? {} : { for k, v in var.vnet_map : k => v } + + name = "link-${each.key}" + private_dns_zone_name = var.create_private_zone == true ? azurerm_private_dns_zone.this[0].name : var.external_dns_zone_name + resource_group_name = var.resource_group + virtual_network_id = each.value + tags = var.tags +} diff --git a/outputs.tf b/outputs.tf new file mode 100644 index 0000000..d3ae0f5 --- /dev/null +++ b/outputs.tf @@ -0,0 +1,14 @@ +output "id" { + value = var.create_private_zone == true ? azurerm_private_dns_zone.this[0].id : "" + description = "Private DNS Zone Id" +} + +output "name" { + value = var.create_private_zone == true ? azurerm_private_dns_zone.this[0].name : "" + description = "Private DNS Zone Name" +} + +output "link_id" { + value = var.vnet_map == {} ? [] : [for vnet_link in azurerm_private_dns_zone_virtual_network_link.this : vnet_link.id] + description = "List of Virtual Network Link Ids" +} diff --git a/variables.tf b/variables.tf new file mode 100644 index 0000000..717c2ad --- /dev/null +++ b/variables.tf @@ -0,0 +1,47 @@ +variable "create_private_zone" { + type = bool + description = "Condition for Private DNS Zone creation" +} + +variable "project" { + type = string + description = "Project name" +} + +variable "env" { + type = string + description = "Environment name" +} + +variable "location" { + type = string + description = "Azure location" +} + +variable "resource_group" { + type = string + description = "Azure location" +} + +variable "tags" { + type = map(string) + description = "Resource tags" +} + +variable "dns_zone_name" { + type = string + description = "Name of Private DNS Zone" + default = "privatelink.azuredatabricks.net" +} + +variable "vnet_map" { + type = map(string) + description = "Map of Virtual Network Name to Id, used to create VNet Link to Private DNS" + default = {} +} + +variable "external_dns_zone_name" { + type = string + description = "Name of Imported Private DNS Zone. Provide value in case creation of new Private DNS Zone is disabled" + default = "" +} diff --git a/versions.tf b/versions.tf new file mode 100644 index 0000000..da436cf --- /dev/null +++ b/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0.0" + + required_providers { + azurerm = { + source = "hashicorp/azurerm" + version = ">= 3.23.0" + } + } +}