Make dns module resilient to dynamic values (#317)
* refactor module and fix tests * account for wildcard records * account for empty recordset names * align tests * align networking end to end examples * fix behaviour with wildcard and empty names * Update main.tf * fix dumb online edit :)
This commit is contained in:
committed by
GitHub
parent
b481d9baff
commit
5001eb49a4
@@ -15,9 +15,10 @@
|
||||
*/
|
||||
|
||||
locals {
|
||||
recordsets = var.recordsets == null ? {} : {
|
||||
for record in var.recordsets :
|
||||
join("/", [record.name, record.type]) => record
|
||||
_recordsets = var.recordsets == null ? {} : var.recordsets
|
||||
recordsets = {
|
||||
for key, attrs in local._recordsets :
|
||||
key => merge(attrs, zipmap(["type", "name"], split(" ", key)))
|
||||
}
|
||||
zone = (
|
||||
var.zone_create
|
||||
@@ -152,10 +153,18 @@ resource "google_dns_record_set" "cloud-static-records" {
|
||||
)
|
||||
project = var.project_id
|
||||
managed_zone = var.name
|
||||
name = each.value.name != "" ? "${each.value.name}.${var.domain}" : var.domain
|
||||
type = each.value.type
|
||||
ttl = each.value.ttl
|
||||
rrdatas = each.value.records
|
||||
name = (
|
||||
each.value.name == ""
|
||||
? var.domain
|
||||
: (
|
||||
substr(each.value.name, -1, 1) == "."
|
||||
? each.value.name
|
||||
: "${each.value.name}.${var.domain}"
|
||||
)
|
||||
)
|
||||
type = each.value.type
|
||||
ttl = each.value.ttl
|
||||
rrdatas = each.value.records
|
||||
depends_on = [
|
||||
google_dns_managed_zone.non-public, google_dns_managed_zone.public
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user