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

Using a google_compute_per_instance_config with google_compute_instance_group_manager causes the target_size to change #20662

Open
gigaSproule opened this issue Dec 11, 2024 · 0 comments
Assignees
Labels
bug forward/review In review; remove label to forward service/compute-managed

Comments

@gigaSproule
Copy link

gigaSproule commented Dec 11, 2024

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request.
  • Please do not leave +1 or me too comments, they generate extra noise for issue followers and do not help prioritize the request.
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment.
  • If an issue is assigned to a user, that user is claiming responsibility for the issue.
  • Customers working with a Google Technical Account Manager or Customer Engineer can ask them to reach out internally to expedite investigation and resolution of this issue.

Terraform Version & Provider Version(s)

Terraform v1.4.5
on

  • provider registry.terraform.io/hashicorp/google v5.37.0
  • provider registry.terraform.io/hashicorp/google-beta v5.37.0

Affected Resource(s)

google_compute_per_instance_config
google_compute_instance_group_manager

Terraform Configuration

resource "google_compute_instance_group_manager" "instance_group_manager" {
  project = var.project_id
  name    = "${local.name_prefix}-igm"

  base_instance_name = local.name_prefix
  zone               = var.zone

  version {
    instance_template = google_compute_instance_template.instance_template.self_link
  }

  target_size = 1

  named_port {
    name = "sftp"
    port = 22
  }

  update_policy {
    type                  = "PROACTIVE"
    replacement_method    = "RECREATE"
    minimal_action        = "REPLACE"
    max_surge_fixed       = 0
    max_unavailable_fixed = 1
  }
}

resource "google_compute_per_instance_config" "instance_config" {
  zone                   = google_compute_instance_group_manager.instance_group_manager.zone
  instance_group_manager = google_compute_instance_group_manager.instance_group_manager.name
  name                   = local.name_prefix
  preserved_state {
    metadata = {
      instance_template = google_compute_instance_template.instance_template.self_link
    }
    internal_ip {
      interface_name = "nic0"
      auto_delete    = "NEVER"
      ip_address {
        address = google_compute_address.sftp_vm_static_internal_ip.self_link
      }
    }
  }

Debug Output

No response

Expected Behavior

Only the 1 VM is created, which is the instance config VM

Actual Behavior

The instance group manager target_size is incremented to 2 and there are now 2 VMs running, with no way to make it only run with 1.

Steps to reproduce

  1. Setup a google_compute_instance_group_manager with a target_size of 1
  2. Setup a google_compute_per_instance_config for the above instance group manager
  3. terraform apply

Important Factoids

When setting the target_size to 0, it will only create the 1 VM, which is the instance config VM, however, on subsequent runs, it will either remove the instance config VM as the target_size is updated to be 0 again or it will create the instance config VM as it no longer exists and set the target_size to 1, meaning that two runs need to be done to get it into a "correct" state.

When setting the target_size to 1, it will create the 2 VMs and then if the instance group manager target_size is manually changed to 1, only the instance config VM will exist and subsequent runs won't change anything, but this defeats the point of using an automated approach if it requires manual work afterwards.

References

No response

@github-actions github-actions bot added forward/review In review; remove label to forward service/compute-managed labels Dec 11, 2024
@c2thorn c2thorn self-assigned this Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug forward/review In review; remove label to forward service/compute-managed
Projects
None yet
Development

No branches or pull requests

2 participants