Hi all,
I have a route53 module which has a record creating resource as part of it (of course):
resource "aws_route53_record" "record" {
for_each = var.module_enabled ? local.records : {}
zone_id = each.value.zone_id
type = each.value.type
name = each.value.name
allow_overwrite = each.value.allow_overwrite
health_check_id = each.value.health_check_id
set_identifier = each.value.set_identifier
# set default TTL when ttl missing and is not ALIAS record
ttl = each.value.ttl == null && each.value.alias.name == null ? var.default_ttl : each.value.ttl
[...]
}
where the local.records
in the for_each
loop looks like this:
+ local_records = {
+ "a-subdomain.domain.tld" = {
+ alias = {
+ evaluate_target_health = true
+ name = (known after apply)
+ zone_id = (known after apply)
}
}
+ "cname-subdomain-api.domain.tld" = {
+ alias = {
+ evaluate_target_health = null
+ name = null
+ zone_id = null
}
}
[ more CNAMEs here ]
+ }
and the module call example:
module "dns_records" {
source = "./modules/route53"
count = length(module.gla) == 1 ? 1 : 0
zone_id = try(data.aws_route53_zone.selected.id, null)
allow_overwrite = true
records = flatten(concat([
{
name = "${lower(var.vpc["tag"])}.${var.my_domain["name"]}"
type = "A"
alias = {
name = module.gla[count.index].dns_name #<== another module dependency
zone_id = module.gla[count.index].zone_id #<== another module dependency
evaluate_target_health = true
}
},
{
name = "${lower(var.vpc["tag"])}-api.${var.my_domain["name"]}"
type = "CNAME"
ttl = 60
records = ["${lower(var.vpc["tag"])}.${var.my_domain["name"]}"]
},
],
[ for i, v in var.my_subdomain : [{
name = "${split("-", lower(var.vpc["tag"]))[0]}-${lower(v)}.${var.my_domain["name"]}"
type = "CNAME"
ttl = 60
records = ["${lower(var.vpc["tag"])}.${var.my_domain["name"]}"]
},
{
name = "${split("-", lower(var.vpc["tag"]))[0]}-${lower(v)}-api.${var.my_domain["name"]}"
type = "CNAME"
ttl = 60
records = ["${lower(var.vpc["tag"])}.${var.my_domain["name"]}"]
}
]]
))
}
Now, this worked fine in 1.5.7
but not in latest 1.6
and 1.7
where I get the error:
╷
│ Error: Missing required argument
│
│ with module.dns_records[0].aws_route53_record.record["a-subdomain.domain.tld"],
│ on ./modules/route53/main.tf line 130, in resource "aws_route53_record" "record":
│ 130: ttl = each.value.ttl == null && each.value.alias.name == null ? var.default_ttl : each.value.ttl
│
│ "ttl": all of `records,ttl` must be specified
╵
during the plan
run. The AWS provider
version is 5.38
and 5.39.1
tried both and no difference. BTW it is failing with 4.67
too so doubt it is provider related.
Anyone has any idea why? @apparentlymart maybe you can explain best what has changed to cause this? I looked through the change log of 1.6
and 1.7
and nothing obvious stood up to me – actually I saw some improvements in terms how the unknown values are being handled in terraform-core but that should not cause this I guess?
Thanks in advance for any help/guidance.