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: Subnetwork name expanded with wrong region #926

Closed
waldiTM opened this issue Jan 6, 2018 · 3 comments · Fixed by #938
Closed

google_compute_instance: Subnetwork name expanded with wrong region #926

waldiTM opened this issue Jan 6, 2018 · 3 comments · Fixed by #938
Assignees
Labels

Comments

@waldiTM
Copy link

waldiTM commented Jan 6, 2018

Terraform Version

Terraform v0.11.1
+ provider.google v1.4.0

Affected Resource(s)

  • google_compute_instance

Terraform Configuration Files

resource "google_compute_instance" "default" {
  name = "test"
  zone = "asia-northeast1-b"
  machine_type = "g1-small"

  boot_disk {
    initialize_params {
      image = "${var.instance_image}"
      type = "pd-ssd"
    }
  }

  network_interface {
    subnetwork = "mirror"
  }

  lifecycle {
    ignore_changes = [ "machine_type" ]
  }
}

provider "google" {
  project = "${var.provider_project}"
  region = "us-central1"
}

Debug Output

https://gist.github.com/waldiTM/3ef518510d7514b18f0e78405ee813ba

Expected Behavior

Subnetwork is used in the correct region. It worked in the past, not sure when.

Actual Behavior

According to the error, Terraform provides the full subnetwork URL in the wrong region, in the default region of the provider.

Steps to Reproduce

  1. terraform apply
@rosbo
Copy link
Contributor

rosbo commented Jan 8, 2018

Hi Bastian,

To solve your issue, you can provide the self_link of the network in the subnetwork field of network_interface.

If the network is created in the same config you can do:
subnetwork = "${google_compute_network.mirror.self_link}"

If the network is NOT created in the same terraform config file, you can use the google_compute_network datasource and then set it in the following way:
subnetwork = "${data. google_compute_network.mirror.self_link}"

I will investigate what changes caused this change of behavior.

@rosbo
Copy link
Contributor

rosbo commented Jan 9, 2018

We changed the behavior to infers region from the zone in schema instead of the provider-level region.

modular-magician added a commit to modular-magician/terraform-provider-google that referenced this issue Sep 27, 2019
…#926)

Signed-off-by: Modular Magician <magic-modules@google.com>
@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 👉 hashibot-feedback@hashicorp.com. 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
Projects
None yet
2 participants