Closed vlantier closed 4 years ago
Sorry for the issue, looks like the issue is with:
shared_vpc_subnets = [
google_compute_subnetwork.env.self_link,
]
As a workaround, could you try commenting out the project and creating the subnet first then creating the project?
As a long term fix, we should add a shared_vpc_subnets_length
variable to the shared-vpc
module and the core project factory modules. Then:
shared_vpc
module to pass it through directlylength(shared_vpc_subnets)
).The workaround worked. Thanks! We'll be waiting for the fix
@morgante I've encountered this problem today for the second time. Last time I've worked around it by doing a targeted apply (as you suggested here), but this time this looked into the code and got it working by removing compact
from all occurrences of compact(var.shared_vpc_subnets)
and commenting out subnet name validation. It's a bit of a bummer that trying to make sure people don't make mistakes when typing in subnet names makes it more difficult to use the module in the way terraform is intended to be used. Would you consider removing the validation hack?
Hi @adrian-gierakowski - I am currently looking at a fix for this now and have discussed the validation with @morgante . At this point in time we are looking to remove that code as it complicates the module and only really has the benefit of surfacing a failure that would occur anyway a little earlier
+1
I have the same problem when setting shared_vpc from another project:
module "project_hmt_prod_cluster_service" { source = "terraform-google-modules/project-factory/google" version = "~> 7.0.0" .... snip ...
shared_vpc = module.project_hmt_prod_cluster_host_prod.project_id }
I guess count
and for_each
are just very limiting in terraform.
@mattcary Your use case can be solved by using the shared_vpc submodule:
module "project_hmt_prod_cluster_service" {
source = "terraform-google-modules/project-factory/google//modules/shared_vpc"
version = "~> 7.0.0"
}
Can you give that a try?
That works!
Thanks for the tip.
My code:
As we can see I'm using the
shared_vpc
submodule as mentioned in other issues but the erros are way more enormous.