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 keeps computing network_interface attributes. #582

Closed
anas-aso opened this issue Oct 13, 2017 · 7 comments
Closed
Assignees

Comments

@anas-aso
Copy link

anas-aso commented Oct 13, 2017

Terraform Version

v0.10.6

Affected Resource(s)

  • google_compute_instance

Terraform Configuration Files

resource "google_compute_instance" "instance" {
  name         = "server"
  machine_type = "sometype"
  zone         = "somezone"

  boot_disk {
    auto_delete = true
    initialize_params {
      image = "some_image"
      size  = "100"
    }
  }

  network_interface {
    network = "default"
    access_config {
         nat_ip = "A.B.C.D"
    }
  }
}

Expected Behavior

After upgrading the plugin to 1.1.0, terraform plan showed this changes:

  ~ google_compute_instance.instance
      network_interface.#:                                 "1" => "1"
      network_interface.0.access_config.#:                 "1" => "1"
      network_interface.0.access_config.0.assigned_nat_ip: "A.B.C.D" => <computed>
      network_interface.0.access_config.0.nat_ip:          "A.B.C.D" => "A.B.C.D"
      network_interface.0.address:                         "a.b.c.d" => <computed>
      network_interface.0.name:                            "nic0" => <computed>
      network_interface.0.network:                         "https://www.googleapis.com/compute/v1/projects/MY_GCP_PROJECT/global/networks/default" => "default"
      network_interface.0.subnetwork_project:              "MY_GCP_PROJECT" => <computed>

Run terraform apply to apply "pending" changes (due to provider plugin upgrade).

Actual Behavior

But even after terraform apply, terraform plan keeps showing the same changes over and over.

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraform plan => will shows the output posted in Expected Behavior
  2. terraform apply
  3. terraform plan => will shows the same output as on step 1.

References

@rosbo rosbo self-assigned this Oct 13, 2017
@rosbo
Copy link
Contributor

rosbo commented Oct 13, 2017

Hi Anas,

I am trying to reproduce this with the following Terraform config but I don't get a perpetual diff like you are describing:

resource "google_compute_address" "default" {
  name = "test-address"
}

resource "google_compute_instance" "instance" {
  name         = "server"
  machine_type = "g1-small"
  zone         = "us-central1-b"

  boot_disk {
    auto_delete = true
    initialize_params {
      image = "debian-cloud/debian-8"
    }
  }

  network_interface {
    network = "default"
    access_config {
        nat_ip = "${google_compute_address.default.address}"
    }
  }
}

Can you post the full diff for google_compute_instance.instance, in the diff you posted there is no fields with changes.

Thank you

@anas-aso
Copy link
Author

@rosbo thanks for checking. The diff I posted is the whole diff.
Next to the computed attributes, I can only see line which will be changed

      network_interface.0.network:                         "https://www.googleapis.com/compute/v1/projects/MY_GCP_PROJECT/global/networks/default" => "default"

I would like to mention that this issue happens with instance created before. Not sure if it affects newly created ones as well.

@anas-aso
Copy link
Author

@rosbo I changed my terraform code to use the full URI of the network instead of just its name, and I don't see any pending changes. I am not sure on which version of terraform this was changed as the same code was working fine.

@rosbo
Copy link
Contributor

rosbo commented Oct 13, 2017

Hum...

The network_interface.0.network field has a DiffSuppressFunc that suppress the diff if when the self_link refers to the same network by name...

Note: I tested with 1.0.1 and 1.1.0 and I tested with creating an instance with 1.0.1 and then upgrading to 1.1.0 and couldn't reproduce...

@rosbo
Copy link
Contributor

rosbo commented Oct 13, 2017

Also, the network field is ForceNew which means it forces the creation of a new resources if it is changed. That also means that the diff output includes a special mention (forces new resource) if there is a diff for that field like you can see below:

network_interface.0.network:                         "https://www.googleapis.com/compute/v1/projects/MY_GCP_PROJECT/global/networks/default" => "default2" (forces new resource)

@anas-aso
Copy link
Author

@rosbo weird! well I wouldn't waste my time on it, I will keep the changes I did for terraform files. Thanks for checking. I will close this issue.

luis-silva pushed a commit to luis-silva/terraform-provider-google that referenced this issue May 21, 2019
@ghost
Copy link

ghost commented Mar 30, 2020

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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!

@ghost ghost locked and limited conversation to collaborators Mar 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants