【发布时间】:2019-05-21 23:46:02
【问题描述】:
我想为我的 aws ec2 实例使用 terraform 模块中的 count.index 来按递增顺序命名实例
file: ec2/main.tf
resource "aws_instance" "instance"{
ami = "ami-xxx"
tags {
Name = "var.instance"
}
count = "var.count"
}
file: ec2instance.tf
module "ec2"{
source = "./ec2"
count = 3
instance_name = "firsttypeinstance-${count.index+1}"
}
module "ec20"{
source = "./ec2"
count = 2
instance_name = "secondtype-${count.index+1}"
}
我希望将实例名称填充为
firsttypeinstance-1 第一种实例-2 firsttypeinstance-3
secondtype-1 secondtype-2
但我得到了无法在模块中使用计数索引的错误
【问题讨论】:
标签: terraform terraform-provider-aws