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.42k stars 9.51k forks source link

Terraform crash when trying to create resources #17318

Closed pixelicous closed 6 years ago

pixelicous commented 6 years ago

Terraform Version

Terraform v0.11.3
+ provider.azurerm v1.1.0
+ provider.random v1.1.0

Terraform Configuration Files


resource "azurerm_resource_group" "rg" {
  name = "${var.name_prefix}-net-rg"
  location            = "${var.location}"
}

data "azurerm_virtual_network" "vnet" {
    name = "${var.name_prefix}-net-vnet"
    resource_group_name = "${azurerm_resource_group.rg.name}"    
}

resource "azurerm_subnet" "subnet_management" {
  name  = "Management01"
  address_prefix = "${cidrsubnet(var.vnet_cidr, 9, 0)}"
  resource_group_name = "${azurerm_resource_group.rg.name}"
  virtual_network_name = "${data.azurerm_virtual_network.vnet.name}"
  #network_security_group_id = "${azurerm_network_security_group.Outbound_RDP.id}"
  #network_security_group_id = "${azurerm_network_security_group.Inbound_RDP.id}"
}

resource "azurerm_subnet" "subnet_deployment" {
  name  = "Deployment01"
  address_prefix = "${cidrsubnet(var.vnet_cidr, 9, 1)}"
  resource_group_name = "${azurerm_resource_group.rg.name}"
  virtual_network_name = "${data.azurerm_virtual_network.vnet.name}"
}

Debug Output

module.EastUS2.azurerm_resource_group.rg: Creation complete after 1s (ID: /subscriptions/7ba01b64-039e-45bb-9288-...664e0/resourceGroups/azeu2-mgmt-net-rg) module.EastUS2.data.azurerm_virtual_network.vnet: Refreshing state...

Error: Error applying plan:

1 error(s) occurred:

Terraform does not automatically rollback in the face of errors. Instead, your Terraform state file has been partially updated with any resources that successfully completed. Please address the error above and apply again to incrementally change your infrastructure. panic: runtime error: invalid memory address or nil pointer dereference 2018-02-12T08:57:00.340+0200 [DEBUG] plugin.terraform-provider-azurerm_v1.1.0_x4.exe: [signal 0xc0000005 code=0x0 addr=0x0 pc=0x13fac22] 2018-02-12T08:57:00.340+0200 [DEBUG] plugin.terraform-provider-azurerm_v1.1.0_x4.exe: 2018-02-12T08:57:00.340+0200 [DEBUG] plugin.terraform-provider-azurerm_v1.1.0_x4.exe: goroutine 90 [running]: 2018-02-12T08:57:00.340+0200 [DEBUG] plugin.terraform-provider-azurerm_v1.1.0_x4.exe: github.com/terraform-providers/terraform-provider-azurerm/azurerm.dataSourceArmVnetRead(0xc04220a230, 0x1898e60, 0xc0424b4000, 0xc04261e160, 0x17) 2018-02-12T08:57:00.340+0200 [DEBUG] plugin.terraform-provider-azurerm_v1.1.0_x4.exe: /opt/teamcity-agent/work/222ea50a1b4f75f4/src/github.com/terraform-providers/terraform-provider-azurerm/azurerm/data_source_virtual_network.go:80 +0x542 2018-02-12T08:57:00.340+0200 [DEBUG] plugin.terraform-provider-azurerm_v1.1.0_x4.exe: github.com/terraform-providers/terraform-provider-azurerm/vendor/github.com/hashicorp/terraform/helper/schema.(Resource).ReadDataApply(0xc0425a11a0, 0xc042616600, 0x1898e60, 0xc0424b4000, 0xc0424a0430, 0xc04215c901, 0x80000000018) 2018-02-12T08:57:00.340+0200 [DEBUG] plugin.terraform-provider-azurerm_v1.1.0_x4.exe: /opt/teamcity-agent/work/222ea50a1b4f75f4/src/github.com/terraform-providers/terraform-provider-azurerm/vendor/github.com/hashicorp/terraform/helper/schema/resource.go:259 +0xb7 2018-02-12T08:57:00.340+0200 [DEBUG] plugin.terraform-provider-azurerm_v1.1.0_x4.exe: github.com/terraform-providers/terraform-provider-azurerm/vendor/github.com/hashicorp/terraform/helper/schema.(Provider).ReadDataApply(0xc0421fcb60, 0xc042160320, 0xc042616600, 0x47406a8, 0x0, 0x18) 2018-02-12T08:57:00.340+0200 [DEBUG] plugin.terraform-provider-azurerm_v1.1.0_x4.exe: /opt/teamcity-agent/work/222ea50a1b4f75f4/src/github.com/terraform-providers/terraform-provider-azurerm/vendor/github.com/hashicorp/terraform/helper/schema/provider.go:398 +0xa1 2018-02-12T08:57:00.340+0200 [DEBUG] plugin.terraform-provider-azurerm_v1.1.0_x4.exe: github.com/terraform-providers/terraform-provider-azurerm/vendor/github.com/hashicorp/terraform/plugin.(ResourceProviderServer).ReadDataApply(0xc0424c1080, 0xc0425b43d0, 0xc0425b4450, 0x0, 0x0) 2018-02-12T08:57:00.340+0200 [DEBUG] plugin.terraform-provider-azurerm_v1.1.0_x4.exe: /opt/teamcity-agent/work/222ea50a1b4f75f4/src/github.com/terraform-providers/terraform-provider-azurerm/vendor/github.com/hashicorp/terraform/plugin/resource_provider.go:565 +0x55 2018-02-12T08:57:00.340+0200 [DEBUG] plugin.terraform-provider-azurerm_v1.1.0_x4.exe: reflect.Value.call(0xc042329080, 0xc0424126b0, 0x13, 0x18da7dc, 0x4, 0xc042819f20, 0x3, 0x3, 0x0, 0x0, ...) 2018-02-12T08:57:00.340+0200 [DEBUG] plugin.terraform-provider-azurerm_v1.1.0_x4.exe: /usr/local/go/src/reflect/value.go:434 +0x90c 2018-02-12T08:57:00.340+0200 [DEBUG] plugin.terraform-provider-azurerm_v1.1.0_x4.exe: reflect.Value.Call(0xc042329080, 0xc0424126b0, 0x13, 0xc042819f20, 0x3, 0x3, 0x0, 0x0, 0x0) 2018-02-12T08:57:00.340+0200 [DEBUG] plugin.terraform-provider-azurerm_v1.1.0_x4.exe: /usr/local/go/src/reflect/value.go:302 +0xab 2018-02-12T08:57:00.340+0200 [DEBUG] plugin.terraform-provider-azurerm_v1.1.0_x4.exe: net/rpc.(service).call(0xc042588ec0, 0xc0425741e0, 0xc042582138, 0xc042364480, 0xc042580a80, 0x16372a0, 0xc0425b43d0, 0x16, 0x16372e0, 0xc0425b4450, ...) 2018-02-12T08:57:00.340+0200 [DEBUG] plugin.terraform-provider-azurerm_v1.1.0_x4.exe: /usr/local/go/src/net/rpc/server.go:381 +0x149 2018-02-12T08:57:00.340+0200 [DEBUG] plugin.terraform-provider-azurerm_v1.1.0_x4.exe: created by net/rpc.(Server).ServeCodec 2018-02-12T08:57:00.340+0200 [DEBUG] plugin.terraform-provider-azurerm_v1.1.0_x4.exe: /usr/local/go/src/net/rpc/server.go:475 +0x372 2018/02/12 08:57:00 [ERROR] root.EastUS2: eval: terraform.EvalReadDataApply, err: data.azurerm_virtual_network.vnet: unexpected EOF 2018/02/12 08:57:00 [ERROR] root.EastUS2: eval: *terraform.EvalSequence, err: data.azurerm_virtual_network.vnet: unexpected EOF 2018/02/12 08:57:00 [TRACE] [walkApply] Exiting eval tree: module.EastUS2.data.azurerm_virtual_network.vnet 2018/02/12 08:57:00 [TRACE] dag/walk: upstream errored, not walking "module.EastUS2.azurerm_subnet.subnet_management" 2018/02/12 08:57:00 [TRACE] dag/walk: upstream errored, not walking "module.EastUS2.azurerm_subnet.subnet_deployment" 2018/02/12 08:57:00 [TRACE] dag/walk: upstream errored, not walking "meta.count-boundary (count boundary fixup)" 2018/02/12 08:57:00 [TRACE] dag/walk: upstream errored, not walking "provider.azurerm (close)" 2018/02/12 08:57:00 [TRACE] dag/walk: upstream errored, not walking "root" 2018/02/12 08:57:00 [TRACE] Preserving existing state lineage "3e996688-5cc5-4da5-83d5-2c07b83abc65" 2018-02-12T08:57:00.354+0200 [DEBUG] plugin: plugin process exited: path=C:\git\Infrastructure\CloudInfrastructure\providers\azure\production-account.terraform\plugins\windows_amd64\terraform-provider-azurerm_v1.1.0_x4.exe 2018/02/12 08:57:00 [DEBUG] plugin: waiting for all plugin processes to complete... 2018-02-12T08:57:00.354+0200 [WARN ] plugin: error closing client during Kill: err="connection is shut down"

!!!!!!!!!!!!!!!!!!!!!!!!!!! TERRAFORM CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!

Terraform crashed! This is always indicative of a bug within Terraform. A crash log has been placed at "crash.log" relative to your current working directory. It would be immensely helpful if you could please report the crash with Terraform1 so that we can fix this.

When reporting bugs, please include your terraform version. That information is available on the first line of crash.log. You can also get it by running 'terraform --version' on the command line.

!!!!!!!!!!!!!!!!!!!!!!!!!!! TERRAFORM CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!

Crash Output

https://gist.github.com/pixelicous/ff1e24e74e9d2afba1d93fee53678f1b

Expected Behavior

Subnets created on VNET

Actual Behavior

Plan shows all green, apply as well, when it starts, after 2 resources i receive a crash, no matter how i try.

Steps to Reproduce

Create a resource group, vnet and a vpn gateway in azure rm

Additional Context

Basically creating more resources that rely on this subnet but not showing here.

I tried a couple of ways to write the HCL VNET and resource group. As data and as a resource, when referencing the resource group name as part of the VNET data object, changing between full interpolation some some text+interpolation made a difference, especially before even execution.

When planning / applying i had to use different state file as each time the state file got corrupted

ghost commented 6 years ago

This issue has been automatically migrated to terraform-providers/terraform-provider-azurerm#823 because it looks like an issue with that provider. If you believe this is not an issue with the provider, please reply to terraform-providers/terraform-provider-azurerm#823.

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.