-
Notifications
You must be signed in to change notification settings - Fork 10k
Closed
Labels
Milestone
Description
I found a case that I would have expected to be fixed by #1497 but that still gives me the same sort of error. It's this below (using the terraform-community-modules tf_aws_vpc and (my fork) of the tf_aws_nat modules):
Thinking a bit more about this I can see why its coming up as computed. The flow is as follows:
- use data source to get current AZs
- this is variable is used in a
${slice()}
interpolation as the input variable to a module - this gets fed into
count = "${length(var.public_subnets)}"
inside the module - The
aws_subnet
resource with this count uses a splat in the outputoutput "public_subnets" { value = ["${aws_subnet.public.*.id}"] }
- I then try using the the calling
${length(mod.vpc.public_subnets)}
So I can make the inference between the count
and aws_subnet.public.*.id
but it's probably one level of indirection too much
Terraform v0.9.5, running terraform plan
I get:
data.aws_availability_zones.available: Refreshing state...
data.aws_region.current: Refreshing state...
data.aws_ami.ami: Refreshing state...
Error refreshing state: 1 error(s) occurred:
* module.nat.data.aws_subnet.subnets: data.aws_subnet.subnets: value of 'count' cannot be computed
The terraform code I'm using is:
data "aws_availability_zones" "available" {}
variable "cidr" { default = "10.123.0.0/16" }
module "vpc" {
source = "github.com/terraform-community-modules/tf_aws_vpc?ref=v1.0.4"
name = "my-vpc"
enable_dns_hostnames = true
enable_dns_support = true
azs = "${data.aws_availability_zones.available.names}"
cidr = "${var.cidr}"
private_subnets = [ "${
slice(list(
cidrsubnet(var.cidr, 8, 0),
cidrsubnet(var.cidr, 8, 1),
cidrsubnet(var.cidr, 8, 2),
cidrsubnet(var.cidr, 8, 3),
cidrsubnet(var.cidr, 8, 4),
), 0, length(data.aws_availability_zones.available.names))
}" ]
public_subnets = [ "${
slice(list(
cidrsubnet(var.cidr, 8, 100),
cidrsubnet(var.cidr, 8, 101),
cidrsubnet(var.cidr, 8, 102),
cidrsubnet(var.cidr, 8, 103),
cidrsubnet(var.cidr, 8, 104),
), 0, length(data.aws_availability_zones.available.names))
}" ]
}
module "nat" {
source = "github.com/ashb/tf_aws_nat?ref=43f7249"
name = "my-nat"
instance_count = 1
instance_type = "t2.micro"
subnet_ids = ["${module.vpc.public_subnets}"]
az_list = ["${module.vpc.public_subnets}"]
vpc_security_group_ids = []
aws_key_name = ""
}
dcousens, eschwartz, mrcrch, danihodovic, jpotma and 4 more