Reputation: 187
I have a module that creates multiple outputs. The value of each output being an account number.
I'd like to use the count parameter on a resource to do iteration using the values from the module mentioned above. However, I'm learning that you cannot do interpolation on a variable default or layered interpolation.
What is the right way to handle this in terraform?
variable "service_node_accounts" {
description = "List of Account IDs"
type = "list"
default = ["${module.accounts.qa}", "${module.accounts.staging}", "${module.accounts.prod}"]
}
data "aws_ami" "service_node_1_0" {
filter {
name = "name"
values = ["service-node-1.0"]
}
owners = ["self"] # Canonical
}
resource "aws_ami_launch_permission" "service_node_1_0" {
count = "${length(var.service_node_accounts)}"
image_id = "${aws_ami.service_node_1_0.id}"
account_id = "${var.service_node_accounts[count.index]}"
}
terraform plan...
default may not contain interpolations
Upvotes: 4
Views: 3881