Skip to content

Commit 2f52949

Browse files
authored
Merge pull request #13 from T-Systems-MMS/add_mx
add mx resource
2 parents f073bed + 73fe554 commit 2f52949

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

main.tf

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,20 @@ resource "azurerm_dns_txt_record" "dns_txt_record" {
7171

7272
tags = local.dns_txt_record[each.key].tags
7373
}
74+
75+
/** MX Records */
76+
resource "azurerm_dns_mx_record" "dns_mx_record" {
77+
for_each = var.dns_mx_record
78+
79+
name = local.dns_mx_record[each.key].name == "" ? each.key : local.dns_mx_record[each.key].name
80+
resource_group_name = local.dns_mx_record[each.key].resource_group_name
81+
zone_name = local.dns_mx_record[each.key].zone_name
82+
ttl = local.dns_mx_record[each.key].ttl
83+
84+
record {
85+
preference = local.dns_mx_record[each.key].record.preference
86+
exchange = local.dns_mx_record[each.key].record.exchange
87+
}
88+
89+
tags = local.dns_mx_record[each.key].tags
90+
}

variables.tf

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ variable "dns_txt_record" {
2323
default = {}
2424
description = "resource definition, default settings are defined within locals and merged with var settings"
2525
}
26+
variable "dns_mx_record" {
27+
type = any
28+
default = {}
29+
description = "resource definition, default settings are defined within locals and merged with var settings"
30+
}
2631

2732
locals {
2833
default = {
@@ -54,6 +59,12 @@ locals {
5459
records = {}
5560
tags = {}
5661
}
62+
dns_mx_record = {
63+
name = ""
64+
ttl = "900"
65+
records = {}
66+
tags = {}
67+
}
5768
}
5869

5970
# compare and merge custom and default values
@@ -88,4 +99,8 @@ locals {
8899
}
89100
)
90101
}
102+
dns_mx_record = {
103+
for dns_mx_record in keys(var.dns_mx_record) :
104+
dns_mx_record => merge(local.default.dns_mx_record, var.dns_mx_record[dns_mx_record])
105+
}
91106
}

0 commit comments

Comments
 (0)