Skip to content

Fix issue 3748 (Error with stateful_ips iteration in MIG)#3765

Merged
mohitchaurasia91 merged 2 commits into
GoogleCloudPlatform:developfrom
rbekhtaoui:Fix-error-with-stateful_ips-iteration-in-MIG
Mar 7, 2025
Merged

Fix issue 3748 (Error with stateful_ips iteration in MIG)#3765
mohitchaurasia91 merged 2 commits into
GoogleCloudPlatform:developfrom
rbekhtaoui:Fix-error-with-stateful_ips-iteration-in-MIG

Conversation

@rbekhtaoui

Copy link
Copy Markdown
Contributor

After upgrading to the latest release of Cluster Toolkit, an error occurs in the google_compute_region_instance_group_manager resource when enable_public_ips = false.

Issue:

When enable_public_ips = false, the variable stateful_ips is null.
Terraform does not support iterating over null in for_each, leading to an error :

Error: Iteration over null value

on .terraform/modules/htcondor_access.htcondor_ap/modules/mig/main.tf line 83, in resource "google_compute_region_instance_group_manager" "mig":
 83:     for_each = [for static_ip in var.stateful_ips : static_ip if static_ip["is_external"] == true]

 var.stateful_ips is null
A null value cannot be used as the collection in a 'for' expression.

Proposed solution:

  stateful_ips = var.enable_public_ips ? [{
    interface_name = "nic0"
    delete_rule    = "ON_PERMANENT_INSTANCE_DELETION"
    is_external    = true
  }] : null # remplace null with []

@mohitchaurasia91

Copy link
Copy Markdown
Contributor

/gcbrun

@mohitchaurasia91 mohitchaurasia91 added the release-bugfix Added to release notes under the "Bug fixes" heading. label Mar 6, 2025

@abbas1902 abbas1902 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you for your submission!

@mohitchaurasia91 mohitchaurasia91 self-requested a review March 7, 2025 08:59
@mohitchaurasia91

Copy link
Copy Markdown
Contributor

/gcbrun

@mohitchaurasia91 mohitchaurasia91 merged commit 354def8 into GoogleCloudPlatform:develop Mar 7, 2025
@rbekhtaoui rbekhtaoui deleted the Fix-error-with-stateful_ips-iteration-in-MIG branch June 18, 2025 13:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-bugfix Added to release notes under the "Bug fixes" heading.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants