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

google_compute_instance infinite diff if min_cpu_platform is set to AUTOMATIC #10659

Closed
jcanseco opened this issue Dec 1, 2021 · 2 comments
Closed
Assignees
Labels
bug forward/review In review; remove label to forward service/compute-instances

Comments

@jcanseco
Copy link
Contributor

jcanseco commented Dec 1, 2021

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 the modular-magician user, it is either in the process of being autogenerated, or is planned to be autogenerated soon. If an issue is assigned to a user, that user is claiming responsibility for the issue. If an issue is assigned to hashibot, a community member has claimed the issue already.

Terraform Version

Terraform v1.0.2
on linux_amd64
+ provider registry.terraform.io/hashicorp/google v4.1.0

Affected Resource(s)

  • google_compute_instance

Terraform Configuration Files

resource "google_compute_instance" "instance" {
  name          = "my-instance"
  machine_type  = "n1-standard-1"
  zone          = "us-west1-a"
  boot_disk {
    initialize_params {
      image = "debian-cloud/debian-9"
    }
  }
  network_interface {
    network = "default"
  }
  min_cpu_platform = "AUTOMATIC"
}

Expected Behavior

terraform apply-ing this resource and then terraform plan-ing right after should produce no diffs.

Actual Behavior

A diff was produced:

Terraform will perform the following actions:

  # google_compute_instance.instance will be updated in-place
  ~ resource "google_compute_instance" "instance" {
        id                   = "projects/cnrm-jcanseco-2/zones/us-west1-a/instances/my-instance"
      + min_cpu_platform     = "AUTOMATIC"
        name                 = "my-instance"
        tags                 = []
        # (17 unchanged attributes hidden)



        # (3 unchanged blocks hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.

Steps to Reproduce

  1. terraform apply
  2. terraform plan

Notice how there is a diff for min_cpu_platform. Same issue happens if min_cpu_platform is set to Automatic.

I believe the reason behind this behavior is that according to the documentation for minCpuPlatform, you set the field to AUTOMATIC when you want to clear it in the underlying API.

Therefore, when the user applies a google_compute_instance with min_cpu_platform = "AUTOMATIC", the API clears the field as expected, but now Terraform believes there is a diff since the underlying value is empty whereas the user has a specified value.

I believe the fix here is to supress diffs for min_cpu_platform if the user sets it to AUTOMATIC (or Automatic) and the underlying value is empty string since these should actually be treated as equivalent.

References

  • b/208316260
@jcanseco jcanseco added the bug label Dec 1, 2021
@c2thorn c2thorn self-assigned this Dec 1, 2021
@github-actions github-actions bot added forward/review In review; remove label to forward service/compute-instances labels Oct 25, 2023
@roaks3
Copy link
Collaborator

roaks3 commented Nov 22, 2023

Appears to be fixed by GoogleCloudPlatform/magic-modules#8249

@roaks3 roaks3 closed this as completed Nov 22, 2023
Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug forward/review In review; remove label to forward service/compute-instances
Projects
None yet
Development

No branches or pull requests

3 participants