-
Notifications
You must be signed in to change notification settings - Fork 10k
Description
I've been trying to extend my Terraform examples to support multiple AZs by default.
As such, I have an az_count variable output by my module to detect the AZs you have available:
https://github.com/terraform-community-modules/tf_aws_availability_zones#outputs
And I then want to reuse it for instances, for example here:
https://github.com/bobtfish/terraform-vpc/blob/master/main.tf#L37
My example (https://github.com/bobtfish/terraform-example-vpc/tree/master/eucentral1-demo) crashes out with the error:
- aws_instance.nat: resource count can't reference module variable: module.vpc.az_count
and if I remove this error from the source (hope springs eternal!), I run into:
- strconv.ParseInt: parsing "${module.azs.az_count}": invalid syntax
This inability to interpolate count variables is a blocker for me being able to write region independent modules - as (for example) I want to be able to allocate one subnet per AZ, writing code like:
module "azs" {
source = "github.com/terraform-community-modules/tf_aws_availability_zones"
account = "${var.account}"
region = "${var.region}"
}
resource "aws_subnet" "front" {
count = "${module.vpcs.az_count}"
...
}
Even better, I'd like to be able to interpolate variables out of one module, and into the user variables of another, for example:
module "azs" {
source = "github.com/terraform-community-modules/tf_aws_availability_zones"
account = "${var.account}"
region = "${var.region}"
}
variable "az_count" {
default = "${module.azs.az_count}"
}
resource "aws_subnet" "front" {
count = "${var.az_count}"
...
}