Skip to content

Commit

Permalink
feat: add module
Browse files Browse the repository at this point in the history
  • Loading branch information
owlleg6 committed Oct 17, 2022
1 parent 26ce7d3 commit 6b8e9c9
Show file tree
Hide file tree
Showing 5 changed files with 133 additions and 0 deletions.
45 changes: 45 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,51 @@ Terraform module for creation Azure <>
## Usage

<!-- BEGIN_TF_DOCS -->
## Requirements

| Name | Version |
|---------------------------------------------------------------------------|-----------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0.0 |
| <a name="requirement_azurerm"></a> [azurerm](#requirement\_azurerm) | >= 3.23.0 |

## Providers

| Name | Version |
|---------------------------------------------------------------|---------|
| <a name="provider_azurerm"></a> [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 |
|------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------|---------------|-------------------------------------|:--------:|
| <a name="input_create_private_zone"></a> [create\_private\_zone](#input\_create\_private\_zone) | Condition for Private DNS Zone creation | `bool` | n/a | yes |
| <a name="input_env"></a> [env](#input\_env) | The prefix which should be used for all resources in this environment | `string` | n/a | yes |
| <a name="input_location"></a> [location](#input\_location) | The Azure Region in which all resources in this example should be created. | `string` | n/a | yes |
| <a name="input_project"></a> [project](#input\_project) | Project/stream name (e.g. datalake) | `string` | n/a | yes |
| <a name="input_resource_group"></a> [resource\_group](#input\_resource\_group) | The Azure Region in which all resources in this example should be created. | `string` | n/a | yes |
| <a name="input_tags"></a> [tags](#input\_tags) | list of tags | `map(string)` | n/a | yes |
| <a name="input_dns_zone_name"></a> [dns\_zone\_name](#input\_dns\_zone\_name) | Name of Private DNS Zone | `string` | `"privatelink.azuredatabricks.net"` | no |
| <a name="input_vnet_map"></a> [vnet_map](#input\_vnet\_map) | Map of Virtual Network Name to Id, used to create VNet Link to Private DNS | `map(string)` | `{}` | no |
| <a name="input_external_dns_zone_name"></a> [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 |
|-------------------------------------------------------|----------------------------------|
| <a name="output_id"></a> [id](#output\_id) | Private DNS Zone Id |
| <a name="output_name"></a> [id](#output\_name) | Private DNS Zone Name |
| <a name="output_link_id"></a> [id](#output\_link\_id) | List of Virtual Network Link Ids |

<!-- END_TF_DOCS -->

Expand Down
17 changes: 17 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
@@ -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
}
14 changes: 14 additions & 0 deletions outputs.tf
Original file line number Diff line number Diff line change
@@ -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"
}
47 changes: 47 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
@@ -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 = ""
}
10 changes: 10 additions & 0 deletions versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
terraform {
required_version = ">= 1.0.0"

required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = ">= 3.23.0"
}
}
}

0 comments on commit 6b8e9c9

Please sign in to comment.