-
Notifications
You must be signed in to change notification settings - Fork 212
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Subnets evaluation during terraform plan phase. #935
Comments
Hi, |
Hi @hyder what do you mean? |
I mean are you using terraform targets? e.g. terraform apply --target=module.network .. Or just a straightforward terraform apply? |
Ah got it. This issue involves a straightforward single Terraform run where the subnet resources have yet to be created. The module then uses the ID attributes of these resources. This results in errors during the terraform plan/apply phases since Terraform cannot fully evaluate the mentioned variables until terraform apply is run for the subnets only. Using |
I've tested both of your scenarios and they work. When you are providing the values:
are you providing actual ocids, or just like the above? The ids have to be actual ocids strings within "" |
I am having the same issue too, specifying the ids generates:
Note that I am creating the subnet through a standard terraform module, then I am creating the OKE cluster. |
I'm in the same situation. For resource "null_resource" "validate_subnets" {
count = anytrue([for k, v in local.subnet_cidrs_new : contains(["netnum", "newbits", "cidr"], v.type)
if lookup(v, "create", "auto") != "never" So solution is to avoid using v.type like such: resource "null_resource" "validate_subnets" {
count = anytrue([for k, v in local.subnet_cidrs_new : (lookup(v, "netnum", null) == null && lookup(v, "newbits", null) != null) || # netbits
(lookup(v, "netnum", null) != null && lookup(v, "newbits", null) != null) || # netnum
lookup(v, "cidr", null) != null # cidr
]) ? 1 : 0
# The rest [...]
} I also had the same error from scenario #2 mentioned by @VioletCranberry. It stopped whining in my case when I defined subnets by using create = never on all objects: subnets = {
bastion = { create = "never" }
operator = { create = "never" }
fss = { create = "never" }
cp = { create = "never", id = oci_core_subnet.oke["cp"].id }
int_lb = { create = "never", id = oci_core_subnet.oke["int_lb"].id }
pub_lb = { create = "never", id = oci_core_subnet.oke["pub_lb"].id }
workers = { create = "never", id = oci_core_subnet.oke["workers"].id }
pods = { create = "never", id = oci_core_subnet.oke["pods"].id }
} |
It looks like parsing of
locals
variablesterraform-oci-oke/modules/network/subnets.tf
Line 53 in 02aeaeb
terraform-oci-oke/modules/network/subnets.tf
Line 82 in 02aeaeb
terraform-oci-oke/modules/network/subnets.tf
Line 102 in 02aeaeb
terraform-oci-oke/modules/network/subnets.tf
Line 123 in 02aeaeb
is not working as expected.
I am planning to run the cluster on my own subnets and VPC, expecting the resources to be provisioned within these subnets.
Terraform cannot fully evaluate mentioned variables during the plan phase, leading to errors.
Module settings:
Terraform Version and Provider Version
Terraform Configuration Files
Subnets are to be created as a separate cloud resources during
terraform apply
run.Expected Behaviour
Second scenario:
First scenario:
Actual Behaviour
terraform plan
errors, creating cluster is blocked. VCN and subnets are about to be created successfully.Steps to Reproduce
Start from scratch, define own VCN and subnets resources, consume IDs with the module.
The text was updated successfully, but these errors were encountered: