Loading...
Loading...
### Terraform Version ```shell Terraform v1.13.3 on windows_amd64 + provider registry.terraform.io/hashicorp/google v6.49.2 ``` ### Terraform Configuration Files The check on for_each is need when there is no entries on yaml file. The problem is that this check produces the error ahead when I have two cloud runs with different specs. ```terraform locals { runjob = yamldecode(file("./yaml/runjob.yaml")) } module "runjob" { source = "git::https://github.com/danilomnds/terraform-gcp-cloud-run-job?ref=v1.1.0" # check for_each = (local.runjob.runjob) == null ? {} : local.runjob.runjob name = lookup(each.value, "name", null) == null ? each.key : lookup(each.value, "name", null) template = each.value.template location = each.value.location labels = each.value.labels annotations = lookup(each.value, "annotations", null) client = lookup(each.value, "client", null) client_version = lookup(each.value, "client_version", null) launch_stage = lookup(each.value, "launch_stage", null) binary_authorization = lookup(each.value, "binary_authorization", null) start_execution_token = lookup(each.value, "start_execution_token", null) run_execution_token = lookup(each.value, "run_execution_token", null) project = var.project members = lookup(each.value, "run_execution_token", []) scheduler_jobs_admin = lookup(each.value, "scheduler_jobs_admin", false) deletion_protection = lookup(each.value, "deletion_protection", null) } output "runjob" { value = { for name, id in module.runjob : name => id.id } } ...terraform config... ``` Trying to create two cloud runs. One does integrate with a VPC while the other one no. ```yaml runjob: runjob-bigdata-dev-1: name: "runjob-bigdata-dev-1" location: "us-east1" template: template: containers: name: "democontainer" image: "us-docker.pkg.dev/cloudrun/container/job:latest" resources: limits: cpu: 1000m memory: "1Gi" vpc_access: network_interfaces: network: "tim-cloud-hdev" subnetwork: "us-east1" labels: system: "your system" runjob-bigdata-dev-2: name: "runjob-bigdata-dev-2" location: "us-east1" template: template: containers: name: "democontainer" image: "us-docker.pkg.dev/cloudrun/container/job:latest" resources: limits: cpu: 1000m memory: "1Gi" labels: system: "your system" ``` ### Debug Output ``` 2025-10-02T12:38:03.396-0300 [TRACE] dag/walk: upstream of "module.runjob.output.id (expand)" errored, so skipping 2025-10-02T12:38:03.396-0300 [TRACE] dag/walk: upstream of "module.runjob.google_project_iam_member.CustomCloudRunDeveloper" errored, so skipping 2025-10-02T12:38:03.396-0300 [TRACE] dag/walk: upstream of "module.runjob.google_project_iam_member.CloudSchedulerAdmin" errored, so skipping 2025-10-02T12:38:03.396-0300 [TRACE] dag/walk: upstream of "provider[\"registry.terraform.io/hashicorp/google\"] (close)" errored, so skipping 2025-10-02T12:38:03.396-0300 [TRACE] dag/walk: upstream of "module.runjob (close)" errored, so skipping 2025-10-02T12:38:03.396-0300 [TRACE] dag/walk: upstream of "output.runjob (expand)" errored, so skipping 2025-10-02T12:38:03.396-0300 [TRACE] dag/walk: upstream of "root" errored, so skipping Releasing state lock. This may take a few moments... ╷ │ Error: Inconsistent conditional result types │ │ on runjob.tf line 7, in module "runjob": │ 7: for_each = (local.runjob.runjob) == null ? {} : local.runjob.runjob │ ├──────────────── │ │ local.runjob.runjob is object with 2 attributes │ │ The true and false result expressions must have consistent types. The 'false' value includes object attribute "runjob-bigdata-dev-1", which is absent in the 'true' value. ╵ 2025-10-02T12:38:04.182-0300 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF" 2025-10-02T12:38:04.192-0300 [INFO] provider: plugin process exited: plugin=.terraform/providers/registry.terraform.io/hashicorp/google/6.49.2/windows_amd64/terraform-provider-google_v6.49.2_x5.exe id=31192 2025-10-02T12:38:04.192-0300 [DEBUG] provider: plugin exited [terraform.log](https://github.com/user-attachments/files/22663276/terraform.log) ``` ### Expected Behavior I want to check whether the runjob.yaml file is empty. If it's empty, the system should either: - Do nothing, if no resources were previously created. - Delete the last remaining resource, if this is the final cleanup step. if yaml is like this ```yaml runjob: ``` On terraform "do nothing" ```terraform for_each = (local.runjob.runjob) == null ? {} : local.runjob.runjob ``` If yaml is like this ```yaml runjob: runjob-bigdata-dev-1: name: "runjob-bigdata-dev-1" runjob-bigdata-dev-2: name: "runjob-bigdata-dev-2" ``` On terraform "go ahead" on resource creation/deletion/update ```terraform for_each = (local.runjob.runjob) == null ? {} : local.runjob.runjob ``` ### Actual Behavior ```PS PS C:\Users\F8082011\OneDrive - TIM\TIM\Cloud\Azure\Azure Devops\gcp-fasttrack-bigdata\environments\fqa\runjob> terraform plan ╷ │ Error: Inconsistent conditional result types │ │ on runjob.tf line 7, in module "runjob": │ 7: for_each = (local.runjob.runjob) == null ? {} : local.runjob.runjob │ ├──────────────── │ │ local.runjob.runjob is object with 2 attributes │ │ The true and false result expressions must have consistent types. The 'false' value includes object attribute "runjob-bigdata-dev-1", which is absent in the 'true' value. ``` ### Steps to Reproduce 1. terraform init 2. terraform apply ### Additional Context _No response_ ### References _No response_ ### Generative AI / LLM assisted development? _No response_
Click on a version to see all relevant bugs
Terraform Integration
Learn more about where this data comes from
Bug Scrub Advisor
Streamline upgrades with automated vendor bug scrubs
BugZero Enterprise
Wish you caught this bug sooner? Get proactive today.