I am trying to configure records on aws by looping instructions from my data source.
the data source looks like this:
data "dns_instructions" "example-dns-instructions" {
id = "123"
instructions {
name = "www.example.com"
type = "A"
value = "1.2.3.4"
}
instructions {
name = "a.example.com"
type = "TXT"
value = "value 1"
}
}
I tried the following:
resource "aws_route53_record" "my-records" {
for_each = {
for inst in data.dns_instructions.example-dns-instructions.instructions :
"${inst.id}" => inst
}
zone_id = "ABCSDSD....."
name = each.value.name
type = each.value.type
ttl = 300
records = each.value.value
}
I do see the data source with all details in the TF state but when trying to apply, getting:
data.dns_instructions.example-dns-instructions.instructions is null
│
│ A null value cannot be used as the collection in a 'for' expression.
I am probably missing something basic in terraform, can someone please assist?