From 0141903592448ba7ab1466c4c5575eae2d2282af Mon Sep 17 00:00:00 2001 From: Michaela Mattes Date: Fri, 15 Sep 2023 08:51:13 +0200 Subject: [PATCH] https://github.com/telekom-mms/terraform-azurerm-dns/issues/3 --- .github/settings.json | 3 ++- examples/apply_main.tf | 18 ++++++++++++++++++ examples/full_main.tf | 23 +++++++++++++++++++++++ examples/min_main.tf | 18 ++++++++++++++++++ main.tf | 11 +++++++++++ outputs.tf | 15 +++++++++++++++ variables.tf | 14 ++++++++++++++ 7 files changed, 101 insertions(+), 1 deletion(-) diff --git a/.github/settings.json b/.github/settings.json index 529e95f..943ff2f 100644 --- a/.github/settings.json +++ b/.github/settings.json @@ -12,7 +12,8 @@ "azurerm-dns-a-record", "azurerm-dns-cname-record", "azurerm-dns-txt-record", - "azurerm-dns-mx-record" + "azurerm-dns-mx-record", + "azurerm-private-dns-zone-virtual-network-link" ] } } diff --git a/examples/apply_main.tf b/examples/apply_main.tf index b195218..c8b4d8e 100644 --- a/examples/apply_main.tf +++ b/examples/apply_main.tf @@ -1,3 +1,14 @@ +module "network" { + source = "registry.terraform.io/telekom-mms/network/azurerm" + virtual_network = { + vn-app-mms = { + location = "westeurope" + resource_group_name = "rg-mms-github" + address_space = ["173.0.0.0/23"] + } + } +} + module "dns" { source = "registry.terraform.io/telekom-mms/dns/azurerm" dns_zone = { @@ -47,4 +58,11 @@ module "dns" { } } } + private_dns_zone_virtual_network_link = { + pl-mms-github = { + resource_group_name = "rg-mms-github" + private_dns_zone_name = module.dns.private_dns_zone["mms-github-privat-plattform.com"].name + virtual_network_id = module.network.virtual_network["vn-app-mms"].id + } + } } diff --git a/examples/full_main.tf b/examples/full_main.tf index c4e0b78..441590e 100644 --- a/examples/full_main.tf +++ b/examples/full_main.tf @@ -1,3 +1,14 @@ +module "network" { + source = "registry.terraform.io/telekom-mms/network/azurerm" + virtual_network = { + vn-app-mms = { + location = "westeurope" + resource_group_name = "rg-mms-github" + address_space = ["173.0.0.0/23"] + } + } +} + module "dns" { source = "registry.terraform.io/telekom-mms/dns/azurerm" dns_zone = { @@ -87,4 +98,16 @@ module "dns" { } } } + private_dns_zone_virtual_network_link = { + pl-mms-github = { + resource_group_name = "rg-mms-github" + private_dns_zone_name = module.dns.private_dns_zone["mms-github-privat-plattform.com"].name + virtual_network_id = module.network.virtual_network["vn-app-mms"].id + tags = { + project = "mms-github" + environment = terraform.workspace + managed-by = "terraform" + } + } + } } diff --git a/examples/min_main.tf b/examples/min_main.tf index b195218..c8b4d8e 100644 --- a/examples/min_main.tf +++ b/examples/min_main.tf @@ -1,3 +1,14 @@ +module "network" { + source = "registry.terraform.io/telekom-mms/network/azurerm" + virtual_network = { + vn-app-mms = { + location = "westeurope" + resource_group_name = "rg-mms-github" + address_space = ["173.0.0.0/23"] + } + } +} + module "dns" { source = "registry.terraform.io/telekom-mms/dns/azurerm" dns_zone = { @@ -47,4 +58,11 @@ module "dns" { } } } + private_dns_zone_virtual_network_link = { + pl-mms-github = { + resource_group_name = "rg-mms-github" + private_dns_zone_name = module.dns.private_dns_zone["mms-github-privat-plattform.com"].name + virtual_network_id = module.network.virtual_network["vn-app-mms"].id + } + } } diff --git a/main.tf b/main.tf index 0c63ec8..3d6071c 100644 --- a/main.tf +++ b/main.tf @@ -120,3 +120,14 @@ resource "azurerm_dns_mx_record" "dns_mx_record" { tags = local.dns_mx_record[each.key].tags } + +resource "azurerm_private_dns_zone_virtual_network_link" "private_dns_zone_virtual_network_link" { + for_each = var.private_dns_zone_virtual_network_link + + name = local.private_dns_zone_virtual_network_link[each.key].name == "" ? each.key : local.private_dns_zone_virtual_network_link[each.key].name + resource_group_name = local.private_dns_zone_virtual_network_link[each.key].resource_group_name + private_dns_zone_name = local.private_dns_zone_virtual_network_link[each.key].private_dns_zone_name + virtual_network_id = local.private_dns_zone_virtual_network_link[each.key].virtual_network_id + registration_enabled = local.private_dns_zone_virtual_network_link[each.key].registration_enabled + tags = local.private_dns_zone_virtual_network_link[each.key].tags +} diff --git a/outputs.tf b/outputs.tf index aa77990..0f7f2cd 100644 --- a/outputs.tf +++ b/outputs.tf @@ -64,6 +64,17 @@ output "dns_mx_record" { } } +output "private_dns_zone_virtual_network_link" { + description = "Outputs all attributes of resource_type." + value = { + for private_dns_zone_virtual_network_link in keys(azurerm_private_dns_zone_virtual_network_link.private_dns_zone_virtual_network_link) : + private_dns_zone_virtual_network_link => { + for key, value in azurerm_private_dns_zone_virtual_network_link.private_dns_zone_virtual_network_link[private_dns_zone_virtual_network_link] : + key => value + } + } +} + output "variables" { description = "Displays all configurable variables passed by the module. __default__ = predefined values per module. __merged__ = result of merging the default values and custom values passed to the module" value = { @@ -96,6 +107,10 @@ output "variables" { for key in keys(var.dns_mx_record) : key => local.dns_mx_record[key] } + private_dns_zone_virtual_network_link = { + for key in keys(var.private_dns_zone_virtual_network_link) : + key => local.private_dns_zone_virtual_network_link[key] + } } } } diff --git a/variables.tf b/variables.tf index 8b031db..68c39dc 100644 --- a/variables.tf +++ b/variables.tf @@ -28,6 +28,11 @@ variable "dns_mx_record" { default = {} description = "resource definition, default settings are defined within locals and merged with var settings" } +variable "private_dns_zone_virtual_network_link" { + type = any + default = {} + description = "resource definition, default settings are defined within locals and merged with var settings" +} locals { default = { @@ -84,6 +89,11 @@ locals { ttl = 3600 // define default tags = {} } + private_dns_zone_virtual_network_link = { + name = "" + registration_enabled = null + tags = {} + } } // compare and merge custom and default values @@ -133,4 +143,8 @@ locals { for dns_mx_record in keys(var.dns_mx_record) : dns_mx_record => merge(local.default.dns_mx_record, var.dns_mx_record[dns_mx_record]) } + private_dns_zone_virtual_network_link = { + for private_dns_zone_virtual_network_link in keys(var.private_dns_zone_virtual_network_link) : + private_dns_zone_virtual_network_link => merge(local.default.private_dns_zone_virtual_network_link, var.private_dns_zone_virtual_network_link[private_dns_zone_virtual_network_link]) + } }