Skip to content

Commit

Permalink
Merge pull request #13 from T-Systems-MMS/add_mx
Browse files Browse the repository at this point in the history
add mx resource
  • Loading branch information
michaelamattes authored Jul 22, 2022
2 parents f073bed + 73fe554 commit 2f52949
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
17 changes: 17 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,20 @@ resource "azurerm_dns_txt_record" "dns_txt_record" {

tags = local.dns_txt_record[each.key].tags
}

/** MX Records */
resource "azurerm_dns_mx_record" "dns_mx_record" {
for_each = var.dns_mx_record

name = local.dns_mx_record[each.key].name == "" ? each.key : local.dns_mx_record[each.key].name
resource_group_name = local.dns_mx_record[each.key].resource_group_name
zone_name = local.dns_mx_record[each.key].zone_name
ttl = local.dns_mx_record[each.key].ttl

record {
preference = local.dns_mx_record[each.key].record.preference
exchange = local.dns_mx_record[each.key].record.exchange
}

tags = local.dns_mx_record[each.key].tags
}
15 changes: 15 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ variable "dns_txt_record" {
default = {}
description = "resource definition, default settings are defined within locals and merged with var settings"
}
variable "dns_mx_record" {
type = any
default = {}
description = "resource definition, default settings are defined within locals and merged with var settings"
}

locals {
default = {
Expand Down Expand Up @@ -54,6 +59,12 @@ locals {
records = {}
tags = {}
}
dns_mx_record = {
name = ""
ttl = "900"
records = {}
tags = {}
}
}

# compare and merge custom and default values
Expand Down Expand Up @@ -88,4 +99,8 @@ locals {
}
)
}
dns_mx_record = {
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])
}
}

0 comments on commit 2f52949

Please sign in to comment.