お世話になっております。
terraform内で、count値をloopさせて、実行結果を設定値に入れたいのですが、可能でしょうか?
var.tf
1// dns 2variable "dns" { 3 default = { 4 name = "test-zone" 5 dns_name = "test.localdomain." 6 description = "DNS zone" 7 } 8} 9 10// instance 11variable "test" { 12 default = { 13 hostname = "test" 14 count = "3" 15 } 16} 17
dns.tf
1resource "google_dns_record_set" "test" { 2 depends_on = ["google_compute_instance.test"] 3 count = "${lookup(var.test, "count")}" 4 name = "${format("${lookup(var.test, "hostname")}%02d", count.index + 1)}.${lookup(var.dns, "dns_name")}" 5 type = "A" 6 ttl = 300 7 managed_zone = "${google_dns_managed_zone.zone.name}" 8 rrdatas = [ "${google_compute_instance.test.${count}.network_interface.0.address}" ] 9}
上記のようなtfにおいて、実行結果として以下のようにループしインスタンスのipaddressを取得しDNSに設定したいのですが、構文エラーとなります。
Error reading config for google_dns_record_set[test]: parse error at 1:32: expected "}" but found opening quote
何卒よろしくお願いします。
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。