Skip to content
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

time_delay resource is ignored when for_each loop is used in the calling code. #224

Open
1 task done
jeffling-google opened this issue Jul 31, 2023 · 0 comments
Open
1 task done
Labels
bug Something isn't working

Comments

@jeffling-google
Copy link

Terraform CLI and Provider Versions

Terraform v1.4.5
on linux_amd64
hashicorp/google v4.63.0

Terraform Configuration

resource "google_access_context_manager_service_perimeter_resource" "service-perimeter-resource" {
  perimeter_name = local.vpc_sc_perimeter
  ...
}

resource "time_sleep" "wait_for_vpc_sc" {
  create_duration = "30s"
  depends_on      = [google_access_context_manager_service_perimeter_resource.service-perimeter-resource]
}

# Adding to Shared VPC as service projects
resource "google_compute_shared_vpc_service_project" "service_projects" {
  for_each        = { for project in local.projects : project.id => project }
  host_project    = each.value.shared_vpc_host
  service_project = each.value.id
  depends_on = [time_sleep.wait_for_vpc_sc]
}

Expected Behavior

The intention is to wait for 30 seconds and then start attaching projects to a Shared VPC host project.

Actual Behavior

The time_sleep resource does not take effect - TF tried to create resources right after the VPC-SC call. The time_sleep doesn't not even show up in terraform plan output. Once I removed the for_each statement so there is only one project is attached, the time_sleep resource shows up in the plan and works properly

Steps to Reproduce

Terraform plan will show you the differences between having for_each or no for_each.
Turn on TF_LOG=DEBUG, you will see that the time_sleep is not called.

How much impact is this issue causing?

High

Logs

No response

Additional Information

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@jeffling-google jeffling-google added the bug Something isn't working label Jul 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant