Hi , Any help is much appreciated , what i am trying to do is , i have 2 domain for which i try to created hosted zone and with the created hosted zone , i need to take the zone id and try to A record , that is where i have issue passing the zone id in a loop for another resource
my tfvars
facade_hostname = [
"mobiel2.t.bankvanmorgen.nl" , #CHANGE-13925
"portaalapi.testing.knab.nl" #CHANGE-16462
]
dns_config = [
{
name = "mobiel2.t.bankvanmorgen.nl",
ttl = "5",
type = "A",
records = [
"172.29.177.22"]
}
,
{
name = "portaalapi.testing.knab.nl",
ttl = "5",
type = "A",
records = [
"172.29.177.7"]
}
]
my variables.tf
variable "facade_hostname" {
type = list
default = []
}
variable "dns_config"{
type = list
default = []
}
my resource.tf file
resource "aws_route53_zone" "private" {
for_each = var.facade_hostname
name = each.value
force_destroy = true
vpc {
vpc_id = module.vpc_private.vpc_id
}
}
resource "aws_route53_record" "A" {
for_each = aws_route53_zone.private
zone_id = each.value.zone_id
name = each.value.name
ttl = each.value.ttl
type = each.value.type
records = each.value.records
allow_overwrite = true
}
Error i am getting
Error: Invalid "each" attribute
│
│ on route53.tf line 13, in resource "aws_route53_record" "A":
│ 13: name = each.name
│
│ The "each" object does not have an attribute named "name". The supported
│ attributes are each.key and each.value, the current key and value pair of
│ the "for_each" attribute set.
╵
╷
│ Error: Invalid "each" attribute
│
│ on route53.tf line 14, in resource "aws_route53_record" "A":
│ 14: ttl = each.ttl
│
│ The "each" object does not have an attribute named "ttl". The supported
│ attributes are each.key and each.value, the current key and value pair of
│ the "for_each" attribute set.
I am trying as much i can but Any help is much appreciated ,