Closed k11h-de closed 2 years ago
Hi Karsten we have a automated testing for most of our modules. But it just tests simple setups. You can find one here: https://github.com/iits-consulting/terraform-opentelekomcloud-project-factory/blob/master/Terratest/cce/main.tf
@canaykin this goes very deep so i think it is the best you take a look
I have tested this a lot and unfortunately this is a limitation on Terraform's side.
Even in the error message, you can see that it knows the number of elements in set but still complains about not knowing the number of instances to be created:
│ │ var.network_ids is set of string with 4 elements
│ The "for_each" value depends on resource attributes that cannot be
│ determined until apply, so Terraform cannot predict how many instances will
│ be created. To work around this, use the -target argument to first apply
│ only the resources that the for_each depends on.
However, in this use case where you are using the SNAT for the entire VPC, there is a simple solution:
module "snat" {
source = "../../modules/snat"
name_prefix = "${var.context}-${var.stage}"
subnet_id = module.vpc.subnets["subnet-0"].id
network_cidrs = [var.vpc_cidr]
vpc_id = module.vpc.vpc.id
}
I will update the module README.md with this code as well.
Hi iits-Team,
before submitting I want to thank you for sharing and enhancing these modules.
I was using the example VPC and SNAT module usage from the snat readme
this is what my test looks like:
this is my variables.auto.tfvars
While running
tf apply
I get this error (with TF versionv1.2.7
andv1.1.9
):What I tried:
values(module.vpc.subnets)[*].id
in a local variable and reference that in the snat module -> same errorI can work around this problem by:
tf apply
1a. comment in again the snat module &&tf apply
or
Do you see any chance to get this applied together in the same tfstate? Did you every got the example in the snat readme working; if yes, with which version of terraform?
Any hint is very welcome. Thanks Karsten