【发布时间】:2019-09-15 13:27:34
【问题描述】:
我在 variables.tf 中有一个列表变量“test”。我正在尝试在我的 zone.tf 中使用这个列表变量。
我不想在这里使用列表索引,事实上我想运行一个循环来动态地从列表变量中获取列表的所有值。我怎样才能做到这一点?非常感谢任何帮助。
我尝试在资源资源“aws_route53_record”内的 test.tf 中使用计数,但它创建了多个我不想要的记录集,因为我只需要一个包含多个记录的记录集
resource "aws_route53_record" "test" {
zone_id = "${data.aws_route53_zone.dns.zone_id}"
name = "${lower(var.environment)}xyz"
type = "CAA"
ttl = 300
count = "${length(var.test)}"
records = [
"0 issue \"${element(var.test, count.index)}\"",
]
}
variables.tf :-
variable "test" {
type = "list"
default = ["godaddy.com", "Namecheap.org"]
}
zone.tf :-
resource "aws_route53_record" "test" {
zone_id = "${data.aws_route53_zone.dns.zone_id}"
name = "${lower(var.environment)}xyz"
type = "CAA"
ttl = 300
records = [
"0 issue \"${var.test[0]}\"",
"0 issue \"${var.test[1]}\"",
]
}
期望获得具有两条记录的一条记录集。
实际:- 得到两个记录集和两个记录。
【问题讨论】:
标签: terraform