2018-05-23 12:39:36 -05:00
|
|
|
variable "num" {
|
2018-01-17 17:27:17 -06:00
|
|
|
default = 3
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "aws_instance" "a" {
|
2018-09-26 13:45:35 -05:00
|
|
|
count = var.num
|
2018-01-17 17:27:17 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
resource "aws_instance" "b" {
|
|
|
|
provisioner "local-exec" {
|
2018-09-26 13:45:35 -05:00
|
|
|
# Since we're in a provisioner block here, this expression is
|
2018-01-17 17:27:17 -06:00
|
|
|
# resolved during the apply walk and so the resource count must
|
2018-09-26 13:45:35 -05:00
|
|
|
# be known during that walk, even though apply walk doesn't
|
2018-01-17 17:27:17 -06:00
|
|
|
# do DynamicExpand.
|
2018-09-26 13:45:35 -05:00
|
|
|
command = "echo ${length(aws_instance.a)}"
|
2018-01-17 17:27:17 -06:00
|
|
|
}
|
|
|
|
}
|