hashicorp / terraform

Terraform enables you to safely and predictably create, change, and improve infrastructure. It is a source-available tool that codifies APIs into declarative configuration files that can be shared amongst team members, treated as code, edited, reviewed, and versioned.
https://www.terraform.io
Other
42.78k stars 9.56k forks source link

terraform crashes while creating google compute instance #25637

Closed grewasc closed 4 years ago

grewasc commented 4 years ago

Terraform Version

v0.12.28

Terraform Configuration Files

provider "google" {
  project     = "xxxx"
  region      = "us-west1"
  zone        = "us-central1-a"
}

// Terraform plugin for creating random ids
resource "random_id" "instance_id" {
 byte_length = 8
}

// A single Compute Engine instance
resource "google_compute_instance" "default" {
 name         = "flask-vm-${random_id.instance_id.hex}"
 machine_type = "f1-micro"
 zone         = "us-west1-a"
 tags = ["allow-ping"]
 boot_disk {
   initialize_params {
     image = "debian-cloud/debian-9"
   }
 }

// Make sure flask is installed on all new instances for later steps
 metadata_startup_script = "sudo apt-get update; sudo apt-get install -yq build-essential python-pip rsync; pip install flask"

 network_interface {
   network = "default"

   access_config {
     // Include this section to give the VM an external ip address
   }
 }
}

# Allow traffic to the VM
resource "google_compute_firewall" "allow-ping" {
  name    = "default-ping"
  network = "default"
  project = "xxxxx"

  allow {
    protocol = "icmp"
  }

  # Allow traffic from everywhere to instances with an http-server tag
  source_ranges = ["0.0.0.0/0"]
  target_tags   = ["allow-ping"]
}

output "ip" {
  value = "${google_compute_instance.default.network_interface.0.access_config.0.nat_ip}"
}

Debug Output

Crash Output

google_compute_instance.default: Creating...

Error: rpc error: code = Unavailable desc = transport is closing

Error: rpc error: code = Unavailable desc = transport is closing

panic: nil context 2020-07-22T08:23:48.696Z [DEBUG] plugin.terraform-provider-google_v3.31.0_x5: 2020-07-22T08:23:48.696Z [DEBUG] plugin.terraform-provider-google_v3.31.0_x5: goroutine 36 [running]: 2020-07-22T08:23:48.696Z [DEBUG] plugin.terraform-provider-google_v3.31.0_x5: net/http.(Request).WithContext(...) 2020-07-22T08:23:48.696Z [DEBUG] plugin.terraform-provider-google_v3.31.0_x5: /opt/goenv/versions/1.14.3/src/net/http/request.go:358 2020-07-22T08:23:48.696Z [DEBUG] plugin.terraform-provider-google_v3.31.0_x5: golang.org/x/net/context/ctxhttp.Do(0x0, 0x0, 0x3b5a800, 0xc000189700, 0x3c8f260a585272a7, 0x10, 0x214a100) 2020-07-22T08:23:48.696Z [DEBUG] plugin.terraform-provider-google_v3.31.0_x5: /opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/golang.org/x/net@v0.0.0-20200324143707-d3edc9973b7e/context/ctxhttp/ctxhttp.go:27 +0x324 2020-07-22T08:23:48.696Z [DEBUG] plugin.terraform-provider-google_v3.31.0_x5: golang.org/x/oauth2/internal.doTokenRoundTrip(0x0, 0x0, 0xc000189700, 0x48, 0xc000035080, 0x18) 2020-07-22T08:23:48.696Z [DEBUG] plugin.terraform-provider-google_v3.31.0_x5: /opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/golang.org/x/oauth2@v0.0.0-20200107190931-bf48bf16ab8d/internal/token.go:232 +0x7b 2020-07-22T08:23:48.696Z [DEBUG] plugin.terraform-provider-google_v3.31.0_x5: golang.org/x/oauth2/internal.RetrieveToken(0x0, 0x0, 0xc000040230, 0x48, 0xc000035080, 0x18, 0x2771c0f, 0x23, 0xc0008c1380, 0x1, ...) 2020-07-22T08:23:48.696Z [DEBUG] plugin.terraform-provider-google_v3.31.0_x5: /opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/golang.org/x/oauth2@v0.0.0-20200107190931-bf48bf16ab8d/internal/token.go:202 +0xdf 2020-07-22T08:23:48.696Z [DEBUG] plugin.terraform-provider-google_v3.31.0_x5: golang.org/x/oauth2.retrieveToken(0x0, 0x0, 0xc000be00e0, 0xc0008c1380, 0xc0008c1450, 0xc0006af0eb, 0x1) 2020-07-22T08:23:48.696Z [DEBUG] plugin.terraform-provider-google_v3.31.0_x5: /opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/golang.org/x/oauth2@v0.0.0-20200107190931-bf48bf16ab8d/token.go:157 +0x92 2020-07-22T08:23:48.696Z [DEBUG] plugin.terraform-provider-google_v3.31.0_x5: golang.org/x/oauth2.(tokenRefresher).Token(0xc000bdf020, 0x49a8fd, 0x2733bcb, 0x6) 2020-07-22T08:23:48.696Z [DEBUG] plugin.terraform-provider-google_v3.31.0_x5: /opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/golang.org/x/oauth2@v0.0.0-20200107190931-bf48bf16ab8d/oauth2.go:270 +0x1de 2020-07-22T08:23:48.697Z [DEBUG] plugin.terraform-provider-google_v3.31.0_x5: golang.org/x/oauth2.(reuseTokenSource).Token(0xc000b9f420, 0x0, 0x0, 0x0) 2020-07-22T08:23:48.697Z [DEBUG] plugin.terraform-provider-google_v3.31.0_x5: /opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/golang.org/x/oauth2@v0.0.0-20200107190931-bf48bf16ab8d/oauth2.go:304 +0xa8 2020-07-22T08:23:48.697Z [DEBUG] plugin.terraform-provider-google_v3.31.0_x5: golang.org/x/oauth2.(Transport).RoundTrip(0xc000b9f460, 0xc000189500, 0x0, 0x0, 0x0) 2020-07-22T08:23:48.697Z [DEBUG] plugin.terraform-provider-google_v3.31.0_x5: /opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/golang.org/x/oauth2@v0.0.0-20200107190931-bf48bf16ab8d/transport.go:45 +0x9e 2020-07-22T08:23:48.697Z [DEBUG] plugin.terraform-provider-google_v3.31.0_x5: github.com/hashicorp/terraform-plugin-sdk/helper/logging.(transport).RoundTrip(0xc000b9f480, 0xc000189500, 0xc0008c16f0, 0x1, 0x1) 2020-07-22T08:23:48.697Z [DEBUG] plugin.terraform-provider-google_v3.31.0_x5: /opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/github.com/hashicorp/terraform-plugin-sdk@v1.11.0/helper/logging/transport.go:27 +0x164 2020-07-22T08:23:48.697Z [DEBUG] plugin.terraform-provider-google_v3.31.0_x5: github.com/terraform-providers/terraform-provider-google/google.(retryTransport).RoundTrip(0xc000bdf0e0, 0xc000188f00, 0x0, 0x0, 0x0) 2020-07-22T08:23:48.697Z [DEBUG] plugin.terraform-provider-google_v3.31.0_x5: /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-google/google/retry_transport.go:125 +0x2c5 2020-07-22T08:23:48.697Z [DEBUG] plugin.terraform-provider-google_v3.31.0_x5: net/http.send(0xc000188e00, 0x2be0800, 0xc000bdf0e0, 0xbfbe1bcca95e4dd1, 0x708919e2d, 0x3b5ab60, 0xc00000e7b8, 0xbfbe1bcca95e4dd1, 0x1, 0x0) 2020-07-22T08:23:48.697Z [DEBUG] plugin.terraform-provider-google_v3.31.0_x5: /opt/goenv/versions/1.14.3/src/net/http/client.go:252 +0x43e 2020-07-22T08:23:48.697Z [DEBUG] plugin.terraform-provider-google_v3.31.0_x5: net/http.(Client).send(0xc000bdf0b0, 0xc000188e00, 0xbfbe1bcca95e4dd1, 0x708919e2d, 0x3b5ab60, 0xc00000e7b8, 0x0, 0x1, 0xc0008748c0) 2020-07-22T08:23:48.697Z [DEBUG] plugin.terraform-provider-google_v3.31.0_x5: /opt/goenv/versions/1.14.3/src/net/http/client.go:176 +0xfa 2020-07-22T08:23:48.697Z [DEBUG] plugin.terraform-provider-google_v3.31.0_x5: net/http.(Client).do(0xc000bdf0b0, 0xc000188e00, 0x0, 0x0, 0x0) 2020-07-22T08:23:48.697Z [DEBUG] plugin.terraform-provider-google_v3.31.0_x5: /opt/goenv/versions/1.14.3/src/net/http/client.go:699 +0x44a 2020-07-22T08:23:48.697Z [DEBUG] plugin.terraform-provider-google_v3.31.0_x5: net/http.(Client).Do(...) 2020-07-22T08:23:48.697Z [DEBUG] plugin.terraform-provider-google_v3.31.0_x5: /opt/goenv/versions/1.14.3/src/net/http/client.go:567 2020-07-22T08:23:48.697Z [DEBUG] plugin.terraform-provider-google_v3.31.0_x5: github.com/terraform-providers/terraform-provider-google/google.sendRequestWithTimeout.func1(0xc00009fea8, 0xc0009e8ea4) 2020-07-22T08:23:48.697Z [DEBUG] plugin.terraform-provider-google_v3.31.0_x5: /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-google/google/transport.go:82 +0x249 2020-07-22T08:23:48.697Z [DEBUG] plugin.terraform-provider-google_v3.31.0_x5: github.com/terraform-providers/terraform-provider-google/google.retryTimeDuration.func1(0x489210) 2020-07-22T08:23:48.697Z [DEBUG] plugin.terraform-provider-google_v3.31.0_x5: /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-google/google/retry_utils.go:21 +0x32 2020-07-22T08:23:48.697Z [DEBUG] plugin.terraform-provider-google_v3.31.0_x5: github.com/hashicorp/terraform-plugin-sdk/helper/resource.Retry.func1(0x0, 0x0, 0x0, 0x0, 0x0, 0x0) 2020-07-22T08:23:48.697Z [DEBUG] plugin.terraform-provider-google_v3.31.0_x5: /opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/github.com/hashicorp/terraform-plugin-sdk@v1.11.0/helper/resource/wait.go:22 +0x5e 2020-07-22T08:23:48.697Z [DEBUG] plugin.terraform-provider-google_v3.31.0_x5: github.com/hashicorp/terraform-plugin-sdk/helper/resource.(StateChangeConf).WaitForState.func1(0xc00009fce0, 0xc0001bf730, 0xc000611d40, 0xc00003a5a0, 0xc0001f8e40, 0xc0001f8e38) 2020-07-22T08:23:48.697Z [DEBUG] plugin.terraform-provider-google_v3.31.0_x5: /opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/github.com/hashicorp/terraform-plugin-sdk@v1.11.0/helper/resource/state.go:103 +0x298 2020-07-22T08:23:48.697Z [DEBUG] plugin.terraform-provider-google_v3.31.0_x5: created by github.com/hashicorp/terraform-plugin-sdk/helper/resource.(StateChangeConf).WaitForState 2020-07-22T08:23:48.697Z [DEBUG] plugin.terraform-provider-google_v3.31.0_x5: /opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/github.com/hashicorp/terraform-plugin-sdk@v1.11.0/helper/resource/state.go:80 +0x1bf 2020-07-22T08:23:48.698Z [DEBUG] plugin: plugin process exited: path=/terraform/.terraform/plugins/linux_amd64/terraform-provider-google_v3.31.0_x5 pid=1554 error="exit status 2" 2020/07/22 08:23:48 [DEBUG] google_compute_instance.default: apply errored, but we're indicating that via the Error pointer rather than returning it: rpc error: code = Unavailable desc = transport is closing 2020/07/22 08:23:48 [TRACE] : eval: terraform.EvalMaybeTainted 2020/07/22 08:23:48 [TRACE] EvalMaybeTainted: google_compute_instance.default encountered an error during creation, so it is now marked as tainted 2020/07/22 08:23:48 [TRACE] : eval: terraform.EvalWriteState 2020/07/22 08:23:48 [DEBUG] google_compute_firewall.allow-ping: apply errored, but we're indicating that via the Error pointer rather than returning it: rpc error: code = Unavailable desc = transport is closing 2020/07/22 08:23:48 [TRACE] : eval: terraform.EvalMaybeTainted 2020/07/22 08:23:48 [TRACE] EvalWriteState: removing state object for google_compute_instance.default 2020/07/22 08:23:48 [TRACE] EvalMaybeTainted: google_compute_firewall.allow-ping encountered an error during creation, so it is now marked as tainted 2020/07/22 08:23:48 [TRACE] : eval: terraform.EvalApplyProvisioners 2020/07/22 08:23:48 [TRACE] : eval: terraform.EvalWriteState 2020/07/22 08:23:48 [TRACE] EvalApplyProvisioners: google_compute_instance.default has no state, so skipping provisioners 2020/07/22 08:23:48 [TRACE] : eval: terraform.EvalMaybeTainted 2020/07/22 08:23:48 [TRACE] EvalWriteState: removing state object for google_compute_firewall.allow-ping 2020/07/22 08:23:48 [TRACE] EvalMaybeTainted: google_compute_instance.default encountered an error during creation, so it is now marked as tainted 2020/07/22 08:23:48 [TRACE] : eval: terraform.EvalApplyProvisioners 2020/07/22 08:23:48 [TRACE] : eval: terraform.EvalWriteState 2020/07/22 08:23:48 [TRACE] EvalApplyProvisioners: google_compute_firewall.allow-ping has no state, so skipping provisioners 2020/07/22 08:23:48 [TRACE] : eval: terraform.EvalMaybeTainted 2020/07/22 08:23:48 [TRACE] EvalWriteState: removing state object for google_compute_instance.default 2020/07/22 08:23:48 [TRACE] EvalMaybeTainted: google_compute_firewall.allow-ping encountered an error during creation, so it is now marked as tainted 2020/07/22 08:23:48 [TRACE] : eval: terraform.EvalIf 2020/07/22 08:23:48 [TRACE] : eval: terraform.EvalWriteState 2020/07/22 08:23:48 [TRACE] : eval: terraform.EvalIf 2020/07/22 08:23:48 [TRACE] EvalWriteState: removing state object for google_compute_firewall.allow-ping 2020/07/22 08:23:48 [TRACE] : eval: terraform.EvalWriteDiff 2020/07/22 08:23:48 [TRACE] : eval: terraform.EvalIf 2020/07/22 08:23:48 [TRACE] : eval: terraform.EvalIf 2020/07/22 08:23:48 [TRACE] : eval: terraform.EvalWriteDiff 2020/07/22 08:23:48 [TRACE] : eval: terraform.EvalApplyPost 2020/07/22 08:23:48 [TRACE] : eval: terraform.EvalApplyPost 2020/07/22 08:23:48 [ERROR] : eval: terraform.EvalApplyPost, err: rpc error: code = Unavailable desc = transport is closing 2020/07/22 08:23:48 [ERROR] : eval: terraform.EvalSequence, err: rpc error: code = Unavailable desc = transport is closing 2020/07/22 08:23:48 [TRACE] [walkApply] Exiting eval tree: google_compute_instance.default 2020/07/22 08:23:48 [TRACE] vertex "google_compute_instance.default": visit complete 2020/07/22 08:23:48 [TRACE] dag/walk: upstream of "output.ip" errored, so skipping 2020/07/22 08:23:48 [ERROR] : eval: terraform.EvalApplyPost, err: rpc error: code = Unavailable desc = transport is closing 2020/07/22 08:23:48 [ERROR] : eval: *terraform.EvalSequence, err: rpc error: code = Unavailable desc = transport is closing 2020/07/22 08:23:48 [TRACE] [walkApply] Exiting eval tree: google_compute_firewall.allow-ping 2020/07/22 08:23:48 [TRACE] vertex "google_compute_firewall.allow-ping": visit complete 2020/07/22 08:23:48 [TRACE] dag/walk: upstream of "provider.google (close)" errored, so skipping 2020/07/22 08:23:48 [TRACE] dag/walk: upstream of "meta.count-boundary (EachMode fixup)" errored, so skipping 2020/07/22 08:23:48 [TRACE] dag/walk: upstream of "root" errored, so skipping 2020-07-22T08:23:48.939Z [DEBUG] plugin: plugin exited

Expected Behavior

a vm should have been created in default network

Actual Behavior

terraform crahsed while creating compute instance

Steps to Reproduce

terraform apply with mentioned config

Additional Context

I am using terraform cloud

References

grewasc commented 4 years ago

IT was an authentication issue. I created a new service account and used that and problem went away

ghost commented 4 years ago

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.