Hi there,
Terraform v0.10.6
https://gist.github.com/matt40k/9086a7e0de6d38a4b7e970b5fdadba81#file-do-basicdroplet-tf
https://gist.github.com/matt40k/9086a7e0de6d38a4b7e970b5fdadba81#file-do-dropletwithfirewall-tf
First config returns:
'''
Error applying plan:
1 error(s) occurred:
digitalocean_droplet.web: 1 error(s) occurred:
digitalocean_droplet.web: Error setting tags: POST https://api.digitalocean.com/v2/tags/web/resources: 404 The resource you were accessing could not be found.
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.
'''
Second config returns
Error applying plan:
2 error(s) occurred:
* digitalocean_firewall.web: 1 error(s) occurred:
* digitalocean_firewall.web: unexpected EOF
* digitalocean_droplet.web: 1 error(s) occurred:
* digitalocean_droplet.web: unexpected EOF
Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resour
panic: interface conversion: interface {} is nil, not string
2017-09-29T14:38:12.414+0100 [DEBUG] plugin.terraform-provider-digitalocean_v0.1.2_x4.exe:
2017-09-29T14:38:12.414+0100 [DEBUG] plugin.terraform-provider-digitalocean_v0.1.2_x4.exe: goroutine 61 [running]:
2017-09-29T14:38:12.414+0100 [DEBUG] plugin.terraform-provider-digitalocean_v0.1.2_x4.exe: github.com/terraform-providers/terraform-provider-digitalocean/digitalocean.expandFirewallInboundRules(0xc042032000, 0x0, 0x0, 0x0)
2017-09-29T14:38:12.414+0100 [DEBUG] plugin.terraform-provider-digitalocean_v0.1.2_x4.exe: /opt/teamcity-agent/work/222ea50a1b4f75f4/src/github.com/terraform-providers/terraform-provider-digitalocean/digitalocean/resource_digitalocean_firewall.go:313 +0xcb7
2017-09-29T14:38:12.414+0100 [DEBUG] plugin.terraform-provider-digitalocean_v0.1.2_x4.exe: github.com/terraform-providers/terraform-provider-digitalocean/digitalocean.firewallRequest(0xc042032000, 0xc042194c00, 0x0, 0x0, 0x0)
2017-09-29T14:38:12.414+0100 [DEBUG] plugin.terraform-provider-digitalocean_v0.1.2_x4.exe: /opt/teamcity-agent/work/222ea50a1b4f75f4/src/github.com/terraform-providers/terraform-provider-digitalocean/digitalocean/resource_digitalocean_firewall.go:296 +0x485
2017-09-29T14:38:12.414+0100 [DEBUG] plugin.terraform-provider-digitalocean_v0.1.2_x4.exe: github.com/terraform-providers/terraform-provider-digitalocean/digitalocean.resourceDigitalOceanFirewallCreate(0xc042032000, 0xa881e0, 0xc042194c00, 0x0, 0x0)
2017-09-29T14:38:12.414+0100 [DEBUG] plugin.terraform-provider-digitalocean_v0.1.2_x4.exe: /opt/teamcity-agent/work/222ea50a1b4f75f4/src/github.com/terraform-providers/terraform-provider-digitalocean/digitalocean/resource_digitalocean_firewall.go:156 +0x6c
2017-09-29T14:38:12.414+0100 [DEBUG] plugin.terraform-provider-digitalocean_v0.1.2_x4.exe: github.com/terraform-providers/terraform-provider-digitalocean/vendor/github.com/hashicorp/terraform/helper/schema.(*Resource).Apply(0xc0423f0360, 0xc0420dc3c0, 0xc0420026a0, 0xa881e0, 0xc042194c00, 0x1, 0x28, 0xc04245f5f0)
2017-09-29T14:38:12.414+0100 [DEBUG] plugin.terraform-provider-digitalocean_v0.1.2_x4.exe: /opt/teamcity-agent/work/222ea50a1b4f75f4/src/github.com/terraform-providers/terraform-provider-digitalocean/vendor
/github.com/hashicorp/terraform/helper/schema/resource.go:186 +0x494
2017-09-29T14:38:12.414+0100 [DEBUG] plugin.terraform-provider-digitalocean_v0.1.2_x4.exe: github.com/terraform-providers/terraform-provider-digitalocean/vendor/github.com/hashicorp/terraform/helper/schema.(*Pro
vider).Apply(0xc042382850, 0xc0420dc280, 0xc0420dc3c0, 0xc0420026a0, 0x220db0, 0x0, 0x0)
2017-09-29T14:38:12.414+0100 [DEBUG] plugin.terraform-provider-digitalocean_v0.1.2_x4.exe: /opt/teamcity-agent/work/222ea50a1b4f75f4/src/github.com/terraform-providers/terraform-provider-digitalocean/vendor
/github.com/hashicorp/terraform/helper/schema/provider.go:242 +0xa2
2017-09-29T14:38:12.414+0100 [DEBUG] plugin.terraform-provider-digitalocean_v0.1.2_x4.exe: github.com/terraform-providers/terraform-provider-digitalocean/vendor/github.com/hashicorp/terraform/plugin.(*ResourcePr
oviderServer).Apply(0xc0423cfd20, 0xc042002320, 0xc04200d490, 0x0, 0x0)
2017-09-29T14:38:12.414+0100 [DEBUG] plugin.terraform-provider-digitalocean_v0.1.2_x4.exe: /opt/teamcity-agent/work/222ea50a1b4f75f4/src/github.com/terraform-providers/terraform-provider-digitalocean/vendor
/github.com/hashicorp/terraform/plugin/resource_provider.go:488 +0x5e
2017-09-29T14:38:12.414+0100 [DEBUG] plugin.terraform-provider-digitalocean_v0.1.2_x4.exe: reflect.Value.call(0xc04223e0c0, 0xc0420e36f0, 0x13, 0xb293e4, 0x4, 0xc0422abf20, 0x3, 0x3, 0x0, 0x0, ...)
2017-09-29T14:38:12.414+0100 [DEBUG] plugin.terraform-provider-digitalocean_v0.1.2_x4.exe: /usr/local/go/src/reflect/value.go:434 +0x926
2017-09-29T14:38:12.414+0100 [DEBUG] plugin.terraform-provider-digitalocean_v0.1.2_x4.exe: reflect.Value.Call(0xc04223e0c0, 0xc0420e36f0, 0x13, 0xc0422abf20, 0x3, 0x3, 0x0, 0x0, 0x0)
2017-09-29T14:38:12.414+0100 [DEBUG] plugin.terraform-provider-digitalocean_v0.1.2_x4.exe: /usr/local/go/src/reflect/value.go:302 +0xab
2017-09-29T14:38:12.414+0100 [DEBUG] plugin.terraform-provider-digitalocean_v0.1.2_x4.exe: net/rpc.(*service).call(0xc0423ddfc0, 0xc0423ddf80, 0xc0423ec5b8, 0xc0420e8d00, 0xc04233b2e0, 0xa116a0, 0xc042002320, 0x
16, 0xa116e0, 0xc04200d490, ...)
2017-09-29T14:38:12.414+0100 [DEBUG] plugin.terraform-provider-digitalocean_v0.1.2_x4.exe: /usr/local/go/src/net/rpc/server.go:387 +0x14b
2017-09-29T14:38:12.414+0100 [DEBUG] plugin.terraform-provider-digitalocean_v0.1.2_x4.exe: created by net/rpc.(*Server).ServeCodec
2017-09-29T14:38:12.414+0100 [DEBUG] plugin.terraform-provider-digitalocean_v0.1.2_x4.exe: /usr/local/go/src/net/rpc/server.go:481 +0x40b
2017/09/29 14:38:12 [TRACE] root: eval: *terraform.EvalWriteState
2017/09/29 14:38:12 [TRACE] root: eval: *terraform.EvalApplyProvisioners
2017/09/29 14:38:12 [TRACE] root: eval: *terraform.EvalIf
2017/09/29 14:38:12 [TRACE] root: eval: *terraform.EvalWriteState
2017/09/29 14:38:12 [TRACE] root: eval: *terraform.EvalWriteDiff
2017/09/29 14:38:12 [TRACE] root: eval: *terraform.EvalApplyPost
2017/09/29 14:38:12 [ERROR] root: eval: *terraform.EvalApplyPost, err: 1 error(s) occurred:
* digitalocean_firewall.web: unexpected EOF
2017/09/29 14:38:12 [ERROR] root: eval: *terraform.EvalSequence, err: 1 error(s) occurred:
* digitalocean_firewall.web: unexpected EOF
2017/09/29 14:38:12 [TRACE] [walkApply] Exiting eval tree: digitalocean_firewall.web
2017/09/29 14:38:12 [TRACE] root: eval: *terraform.EvalWriteState
2017/09/29 14:38:12 [TRACE] root: eval: *terraform.EvalApplyProvisioners
2017/09/29 14:38:12 [TRACE] root: eval: *terraform.EvalIf
2017/09/29 14:38:12 [TRACE] root: eval: *terraform.EvalWriteState
2017/09/29 14:38:12 [TRACE] root: eval: *terraform.EvalWriteDiff
2017/09/29 14:38:12 [TRACE] root: eval: *terraform.EvalApplyPost
2017/09/29 14:38:12 [ERROR] root: eval: *terraform.EvalApplyPost, err: 1 error(s) occurred:
* digitalocean_droplet.web: unexpected EOF
2017/09/29 14:38:12 [ERROR] root: eval: *terraform.EvalSequence, err: 1 error(s) occurred:
* digitalocean_droplet.web: unexpected EOF
2017/09/29 14:38:12 [TRACE] [walkApply] Exiting eval tree: digitalocean_droplet.web
2017/09/29 14:38:12 [TRACE] dag/walk: upstream errored, not walking "meta.count-boundary (count boundary fixup)"
2017/09/29 14:38:12 [TRACE] dag/walk: upstream errored, not walking "provider.digitalocean (close)"
2017/09/29 14:38:12 [TRACE] dag/walk: upstream errored, not walking "root"
2017/09/29 14:38:12 [TRACE] Preserving existing state lineage "1be62308-8623-4224-b15d-9c662ba2697b"
2017-09-29T14:38:12.424+0100 [DEBUG] plugin: plugin process exited: path=C:\git\terraform\.terraform\plugins\windows_amd64\terraform-provider-digitalocean_v0.1.2_x4.exe
2017/09/29 14:38:12 [TRACE] Preserving existing state lineage "1be62308-8623-4224-b15d-9c662ba2697b"
2017/09/29 14:38:12 [TRACE] Preserving existing state lineage "1be62308-8623-4224-b15d-9c662ba2697b"
2017/09/29 14:38:12 [TRACE] Preserving existing state lineage "1be62308-8623-4224-b15d-9c662ba2697b"
2017/09/29 14:38:12 [DEBUG] plugin: waiting for all plugin processes to complete...
2017-09-29T14:38:12.527+0100 [WARN ] plugin: error closing client during Kill: err="connection is shut down"
2017-09-29T14:38:12.549+0100 [DEBUG] plugin: plugin process exited: path=C:\git\terraform\.terraform\plugins\windows_amd64\terraform-provider-http_v1.0.0_x4.exe
ces that successfully compl
e!!!!!!!!!!!!!!!!!!!!!!!!!!! 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 Terraform[1] 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.
[1]: https://github.com/hashicorp/terraform/issues
!!!!!!!!!!!!!!!!!!!!!!!!!!! TERRAFORM CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!
ted. Please address the error
above and apply again to incrementally change your infrastructure.
Seeing the same thing
module.elk-nyc3.digitalocean_droplet.elk[1]: Modifying... (ID: 82998399)
tags.#: "1" => "2"
tags.1: "" => "nyc3"
module.elk-nyc3.digitalocean_droplet.elk[2]: Modifying... (ID: 82998398)
tags.#: "1" => "2"
tags.1: "" => "nyc3"
module.elk-nyc3.digitalocean_droplet.elk[0]: Modifying... (ID: 82998397)
tags.#: "1" => "2"
tags.1: "" => "nyc3"
Error: Error applying plan:
3 error(s) occurred:
* module.elk-nyc3.digitalocean_droplet.elk[0]: 1 error(s) occurred:
* digitalocean_droplet.elk.0: Error updating tags: POST https://api.digitalocean.com/v2/tags/nyc3/resources: 404 The resource you were accessing could not be found.
* module.elk-nyc3.digitalocean_droplet.elk[1]: 1 error(s) occurred:
* digitalocean_droplet.elk.1: Error updating tags: POST https://api.digitalocean.com/v2/tags/nyc3/resources: 404 The resource you were accessing could not be found.
* module.elk-nyc3.digitalocean_droplet.elk[2]: 1 error(s) occurred:
* digitalocean_droplet.elk.2: Error updating tags: POST https://api.digitalocean.com/v2/tags/nyc3/resources: 404 The resource you were accessing could not be found.
Version info
$ terraform version
Terraform v0.11.1
+ provider.digitalocean v0.1.3
To add on.. it seems to only happen with more then one tag
works
tags = ["elk"]
Does not work
tags = ["elk", "${var.region}"]
This seems like a work around
resource "digitalocean_tag" "elk" {
name = "elk"
}
resource "digitalocean_tag" "region" {
name = "${var.region}"
}
resource "digitalocean_droplet" "elk" {
count = "${var.count}"
image = "${var.image}"
region = "${var.region}"
name = "..."
size = "${var.size}"
private_networking = true
ipv6 = true
ssh_keys = ["${split(",", var.ssh_keys)}"]
tags = ["${digitalocean_tag.elk.id}", "${digitalocean_tag.region.id}"]
}
It's actually mentioned in docs that tag has to be created first. But this could crash gracefully by providing same info in the output.
Terraform upstream has closed their side of this issue with:
Prior to Terraform 0.12 there were some missing validation rules in the SDK that were causing these crashes. From 0.12 onwards, the type checking validations are handled by Terraform Core itself and so it's no longer possible to hit these crashing codepaths.
The parts of Terraform that deal with validation were changed significantly in Terraform 0.12, so if you see any similar problems with validation rules in Terraform 0.12.0 or later, please open a new issue so we can capture an updated set of debug information about the new situation. Because the codepath that was crashing here should no longer run in Terraform 0.12, we're going to close this now.
On the DO provider side, I think we can close this out as well. For the first piece about tags, the DigitalOcean API has been updated so that if you specify a tag for a Droplet that doesn't exist it will be created automatically. For the second piece leading to the crash, as upstream mentions there have been significant changes in Terraform 0.12. The config below works with the new Terraform 0.12 syntax.
If you're still running into related issues, please feel free to open a new issue.
variable "environment" {
description = "this environment"
default = "poc1"
}
# Get CloudFlare IPs
data "http" "cf_ip4" {
url = "https://www.cloudflare.com/ips-v4"
}
data "http" "cf_ip6" {
url = "https://www.cloudflare.com/ips-v6"
}
# Get my IP
data "http" "myip" {
url = "https://ident.me/"
}
resource "digitalocean_droplet" "web" {
name = "web-1-${var.environment}"
size = "512mb"
image = "ubuntu-14-04-x64"
region = "lon1"
tags = ["web", var.environment]
ipv6 = false
private_networking = false
}
resource "digitalocean_firewall" "web" {
name = "onlyMeAndCf"
tags = ["web"]
inbound_rule {
protocol = "tcp"
port_range = "443"
source_addresses = split(",",join(",",split("\n", trimspace(data.http.cf_ip4.body)), split("\n", trimspace(data.http.cf_ip6.body))))
}
inbound_rule {
protocol = "tcp"
port_range = "22"
source_addresses = [data.http.myip.body]
}
}
Most helpful comment
This seems like a work around