Skip to content

Commit

Permalink
Merge pull request #20 from telekom-mms/issue_3
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelamattes authored Sep 15, 2023
2 parents 12beccc + 0141903 commit eb070dd
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .github/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
}
}
18 changes: 18 additions & 0 deletions examples/apply_main.tf
Original file line number Diff line number Diff line change
@@ -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 = {
Expand Down Expand Up @@ -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
}
}
}
23 changes: 23 additions & 0 deletions examples/full_main.tf
Original file line number Diff line number Diff line change
@@ -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 = {
Expand Down Expand Up @@ -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"
}
}
}
}
18 changes: 18 additions & 0 deletions examples/min_main.tf
Original file line number Diff line number Diff line change
@@ -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 = {
Expand Down Expand Up @@ -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
}
}
}
11 changes: 11 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
15 changes: 15 additions & 0 deletions outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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]
}
}
}
}
14 changes: 14 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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])
}
}

0 comments on commit eb070dd

Please sign in to comment.