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

hashicorp/hil panic when file() used without quotes #5672

Closed
matthughes opened this issue Mar 16, 2016 · 6 comments
Closed

hashicorp/hil panic when file() used without quotes #5672

matthughes opened this issue Mar 16, 2016 · 6 comments
Assignees

Comments

@matthughes
Copy link

Terraform was running fine; now crashes on every command.

terraform version
Terraform v0.6.12

2016/03/16 17:40:08 [INFO] Terraform version: 0.6.12  
2016/03/16 17:40:08 [DEBUG] Detected home directory from env var: /Users/mhughes
2016/03/16 17:40:08 [DEBUG] Discovered plugin: atlas = /usr/local/Cellar/terraform/0.6.12/bin/terraform-provider-atlas
2016/03/16 17:40:08 [DEBUG] Discovered plugin: aws = /usr/local/Cellar/terraform/0.6.12/bin/terraform-provider-aws
2016/03/16 17:40:08 [DEBUG] Discovered plugin: azure = /usr/local/Cellar/terraform/0.6.12/bin/terraform-provider-azure
2016/03/16 17:40:08 [DEBUG] Discovered plugin: azurerm = /usr/local/Cellar/terraform/0.6.12/bin/terraform-provider-azurerm
2016/03/16 17:40:08 [DEBUG] Discovered plugin: chef = /usr/local/Cellar/terraform/0.6.12/bin/terraform-provider-chef
2016/03/16 17:40:08 [DEBUG] Discovered plugin: cloudflare = /usr/local/Cellar/terraform/0.6.12/bin/terraform-provider-cloudflare
2016/03/16 17:40:08 [DEBUG] Discovered plugin: cloudstack = /usr/local/Cellar/terraform/0.6.12/bin/terraform-provider-cloudstack
2016/03/16 17:40:08 [DEBUG] Discovered plugin: consul = /usr/local/Cellar/terraform/0.6.12/bin/terraform-provider-consul
2016/03/16 17:40:08 [DEBUG] Discovered plugin: datadog = /usr/local/Cellar/terraform/0.6.12/bin/terraform-provider-datadog
2016/03/16 17:40:08 [DEBUG] Discovered plugin: digitalocean = /usr/local/Cellar/terraform/0.6.12/bin/terraform-provider-digitalocean
2016/03/16 17:40:08 [DEBUG] Discovered plugin: dme = /usr/local/Cellar/terraform/0.6.12/bin/terraform-provider-dme
2016/03/16 17:40:08 [DEBUG] Discovered plugin: dnsimple = /usr/local/Cellar/terraform/0.6.12/bin/terraform-provider-dnsimple
2016/03/16 17:40:08 [DEBUG] Discovered plugin: docker = /usr/local/Cellar/terraform/0.6.12/bin/terraform-provider-docker
2016/03/16 17:40:08 [DEBUG] Discovered plugin: dyn = /usr/local/Cellar/terraform/0.6.12/bin/terraform-provider-dyn
2016/03/16 17:40:08 [DEBUG] Discovered plugin: google = /usr/local/Cellar/terraform/0.6.12/bin/terraform-provider-google
2016/03/16 17:40:08 [DEBUG] Discovered plugin: heroku = /usr/local/Cellar/terraform/0.6.12/bin/terraform-provider-heroku
2016/03/16 17:40:08 [DEBUG] Discovered plugin: mailgun = /usr/local/Cellar/terraform/0.6.12/bin/terraform-provider-mailgun
2016/03/16 17:40:08 [DEBUG] Discovered plugin: mysql = /usr/local/Cellar/terraform/0.6.12/bin/terraform-provider-mysql
2016/03/16 17:40:08 [DEBUG] Discovered plugin: null = /usr/local/Cellar/terraform/0.6.12/bin/terraform-provider-null
2016/03/16 17:40:08 [DEBUG] Discovered plugin: openstack = /usr/local/Cellar/terraform/0.6.12/bin/terraform-provider-openstack
2016/03/16 17:40:08 [DEBUG] Discovered plugin: packet = /usr/local/Cellar/terraform/0.6.12/bin/terraform-provider-packet
2016/03/16 17:40:08 [DEBUG] Discovered plugin: postgresql = /usr/local/Cellar/terraform/0.6.12/bin/terraform-provider-postgresql
2016/03/16 17:40:08 [DEBUG] Discovered plugin: powerdns = /usr/local/Cellar/terraform/0.6.12/bin/terraform-provider-powerdns
2016/03/16 17:40:08 [DEBUG] Discovered plugin: rundeck = /usr/local/Cellar/terraform/0.6.12/bin/terraform-provider-rundeck
2016/03/16 17:40:08 [DEBUG] Discovered plugin: statuscake = /usr/local/Cellar/terraform/0.6.12/bin/terraform-provider-statuscake
2016/03/16 17:40:08 [DEBUG] Discovered plugin: template = /usr/local/Cellar/terraform/0.6.12/bin/terraform-provider-template
2016/03/16 17:40:08 [DEBUG] Discovered plugin: terraform = /usr/local/Cellar/terraform/0.6.12/bin/terraform-provider-terraform
2016/03/16 17:40:08 [DEBUG] Discovered plugin: tls = /usr/local/Cellar/terraform/0.6.12/bin/terraform-provider-tls
2016/03/16 17:40:08 [DEBUG] Discovered plugin: vcd = /usr/local/Cellar/terraform/0.6.12/bin/terraform-provider-vcd
2016/03/16 17:40:08 [DEBUG] Discovered plugin: vsphere = /usr/local/Cellar/terraform/0.6.12/bin/terraform-provider-vsphere
2016/03/16 17:40:08 [DEBUG] Discovered plugin: chef = /usr/local/Cellar/terraform/0.6.12/bin/terraform-provisioner-chef
2016/03/16 17:40:08 [DEBUG] Discovered plugin: file = /usr/local/Cellar/terraform/0.6.12/bin/terraform-provisioner-file
2016/03/16 17:40:08 [DEBUG] Discovered plugin: local-exec = /usr/local/Cellar/terraform/0.6.12/bin/terraform-provisioner-local-exec
2016/03/16 17:40:08 [DEBUG] Discovered plugin: remote-exec = /usr/local/Cellar/terraform/0.6.12/bin/terraform-provisioner-remote-exec
2016/03/16 17:40:08 [DEBUG] Detected home directory from env var: /Users/mhughes
2016/03/16 17:40:08 [DEBUG] Attempting to open CLI config file: /Users/mhughes/.terraformrc
2016/03/16 17:40:08 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2016/03/16 17:40:08 [DEBUG] Detected home directory from env var: /Users/mhughes
2016/03/16 17:40:08 [DEBUG] waiting for all plugin processes to complete...
panic: Unary - is only allowed

goroutine 1 [running]:
panic(0x820340, 0xc8203f65a0)
    /usr/local/Cellar/go/1.6/libexec/src/runtime/panic.go:464 +0x3e6
github.com/hashicorp/terraform/vendor/github.com/hashicorp/hil.(*parserParserImpl).Parse(0xc8204ca088, 0x135a9d8, 0xc820362420, 0x0)
    lang.y:132 +0x2202
github.com/hashicorp/terraform/vendor/github.com/hashicorp/hil.parserParse(0x135a9d8, 0xc820362420, 0x1150d30)
    yaccpar:154 +0x49
github.com/hashicorp/terraform/vendor/github.com/hashicorp/hil.Parse(0xc820300480, 0x2e, 0x0, 0x0, 0x0, 0x0)
    /private/tmp/terraform20160227-37732-w3ykp1/terraform-0.6.12/src/github.com/hashicorp/terraform/vendor/github.com/hashicorp/hil/parse.go:27 +0x103
github.com/hashicorp/terraform/config.(*interpolationWalker).Primitive(0xc8200fa160, 0x820340, 0xc8203f63d0, 0x98, 0x0, 0x0)
    /private/tmp/terraform20160227-37732-w3ykp1/terraform-0.6.12/src/github.com/hashicorp/terraform/config/interpolate_walk.go:116 +0x155
github.com/hashicorp/terraform/vendor/github.com/mitchellh/reflectwalk.walkPrimitive(0x810a00, 0xc8203f6440, 0x94, 0xb154a0, 0xc8200fa160, 0x0, 0x0)
    /private/tmp/terraform20160227-37732-w3ykp1/terraform-0.6.12/src/github.com/hashicorp/terraform/vendor/github.com/mitchellh/reflectwalk/reflectwalk.go:186 +0xa9
github.com/hashicorp/terraform/vendor/github.com/mitchellh/reflectwalk.walk(0x820340, 0xc8203f63d0, 0x98, 0xb154a0, 0xc8200fa160, 0x0, 0x0)
    /private/tmp/terraform20160227-37732-w3ykp1/terraform-0.6.12/src/github.com/hashicorp/terraform/vendor/github.com/mitchellh/reflectwalk/reflectwalk.go:117 +0x312
github.com/hashicorp/terraform/vendor/github.com/mitchellh/reflectwalk.walkMap(0x81bbc0, 0xc820300450, 0x15, 0xb154a0, 0xc8200fa160, 0x0, 0x0)
    /private/tmp/terraform20160227-37732-w3ykp1/terraform-0.6.12/src/github.com/hashicorp/terraform/vendor/github.com/mitchellh/reflectwalk/reflectwalk.go:168 +0x599
github.com/hashicorp/terraform/vendor/github.com/mitchellh/reflectwalk.walk(0x81bbc0, 0xc820300450, 0x15, 0xb154a0, 0xc8200fa160, 0x0, 0x0)
    /private/tmp/terraform20160227-37732-w3ykp1/terraform-0.6.12/src/github.com/hashicorp/terraform/vendor/github.com/mitchellh/reflectwalk/reflectwalk.go:120 +0x42c
github.com/hashicorp/terraform/vendor/github.com/mitchellh/reflectwalk.Walk(0x81bbc0, 0xc820300450, 0xb154a0, 0xc8200fa160, 0x0, 0x0)
    /private/tmp/terraform20160227-37732-w3ykp1/terraform-0.6.12/src/github.com/hashicorp/terraform/vendor/github.com/mitchellh/reflectwalk/reflectwalk.go:70 +0x14c
github.com/hashicorp/terraform/config.(*RawConfig).init(0xc8203622a0, 0x0, 0x0)
    /private/tmp/terraform20160227-37732-w3ykp1/terraform-0.6.12/src/github.com/hashicorp/terraform/config/raw_config.go:216 +0x11a
github.com/hashicorp/terraform/config.NewRawConfig(0xc820300450, 0xc8204ca070, 0x0, 0x0)
    /private/tmp/terraform20160227-37732-w3ykp1/terraform-0.6.12/src/github.com/hashicorp/terraform/config/raw_config.go:44 +0x76
github.com/hashicorp/terraform/config.loadProvisionersHcl(0xc8204c2240, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
    /private/tmp/terraform20160227-37732-w3ykp1/terraform-0.6.12/src/github.com/hashicorp/terraform/config/loader_hcl.go:637 +0x704
github.com/hashicorp/terraform/config.loadResourcesHcl(0xc820262b40, 0x0, 0x0, 0x0, 0x0, 0x0)
    /private/tmp/terraform20160227-37732-w3ykp1/terraform-0.6.12/src/github.com/hashicorp/terraform/config/loader_hcl.go:516 +0x1db5
github.com/hashicorp/terraform/config.(*hclConfigurable).Config(0xc820262a00, 0xb7ca90, 0x0, 0x0)
    /private/tmp/terraform20160227-37732-w3ykp1/terraform-0.6.12/src/github.com/hashicorp/terraform/config/loader_hcl.go:118 +0xd66
github.com/hashicorp/terraform/config.(*importTree).ConfigTree(0xc820270240, 0x5b, 0x0, 0x0)
    /private/tmp/terraform20160227-37732-w3ykp1/terraform-0.6.12/src/github.com/hashicorp/terraform/config/import_tree.go:87 +0x68
github.com/hashicorp/terraform/config.LoadFile(0xc820018f00, 0x5b, 0x0, 0x0, 0x0)
    /private/tmp/terraform20160227-37732-w3ykp1/terraform-0.6.12/src/github.com/hashicorp/terraform/config/loader.go:44 +0x80
github.com/hashicorp/terraform/config.LoadDir(0xc820018004, 0x4e, 0x0, 0x0, 0x0)
    /private/tmp/terraform20160227-37732-w3ykp1/terraform-0.6.12/src/github.com/hashicorp/terraform/config/loader.go:91 +0x38c
github.com/hashicorp/terraform/config/module.NewTreeModule(0x0, 0x0, 0xc820018004, 0x4e, 0x0, 0x0, 0x0)
    /private/tmp/terraform20160227-37732-w3ykp1/terraform-0.6.12/src/github.com/hashicorp/terraform/config/module/tree.go:40 +0x41
github.com/hashicorp/terraform/command.(*Meta).Context(0xc8201dc0f0, 0xc820018004, 0x4e, 0xc4e930, 0x11, 0x0, 0x0, 0x4, 0xb3c7d0, 0x0, ...)
    /private/tmp/terraform20160227-37732-w3ykp1/terraform-0.6.12/src/github.com/hashicorp/terraform/command/meta.go:148 +0x509
github.com/hashicorp/terraform/command.(*RefreshCommand).Run(0xc8201dc0f0, 0xc82000a350, 0x0, 0x0, 0xc8200148b0)
    /private/tmp/terraform20160227-37732-w3ykp1/terraform-0.6.12/src/github.com/hashicorp/terraform/command/refresh.go:85 +0xb02
github.com/hashicorp/terraform/vendor/github.com/mitchellh/cli.(*CLI).Run(0xc8201d60c0, 0xc82001b110, 0x0, 0x0)
    /private/tmp/terraform20160227-37732-w3ykp1/terraform-0.6.12/src/github.com/hashicorp/terraform/vendor/github.com/mitchellh/cli/cli.go:153 +0x5ee
main.wrappedMain(0x0)
    /private/tmp/terraform20160227-37732-w3ykp1/terraform-0.6.12/src/github.com/hashicorp/terraform/main.go:140 +0xb05
main.realMain(0x0)
    /private/tmp/terraform20160227-37732-w3ykp1/terraform-0.6.12/src/github.com/hashicorp/terraform/main.go:76 +0xa10
main.main()
    /private/tmp/terraform20160227-37732-w3ykp1/terraform-0.6.12/src/github.com/hashicorp/terraform/main.go:19 +0x18
@matthughes
Copy link
Author

Apparently using file without quotes is what blew it up:

  provisioner "file" {
      source = "foo"
      destination = "bar"
      connection {
        user = "core"
        agent = false
        private_key = "${file(/Users/mhughes/my_key.pem)}"
      }
  }

@phinze
Copy link
Contributor

phinze commented Mar 16, 2016

Thanks for the report, @matthughes, and sorry for the confusing error condition here! We'll get this fixed up soon.

@phinze
Copy link
Contributor

phinze commented Mar 16, 2016

Minimal repro config:

resource "aws_instance" "foo" {
  ami = "${file(/tmp/somefile)}"
}

@phinze phinze changed the title Terraform Crash hashicorp/hil panic when file() used without quotes Mar 16, 2016
@wallies
Copy link

wallies commented Apr 20, 2016

I recently got this exact same crash.log, on the same version of terraform. Here is my resource.

resource "template_file" "etcd_discovery_url" {
  template = "${file(/dev/null)}"
  provisioner "local-exec" {
    command = "curl https://discovery.etcd.io/new?size=${var.masters} > ${var.etcd_discovery_url_file}"
  }
  # This will regenerate the discovery URL if the cluster size changes
  vars {
    size = "${var.masters}"
  }
}

@mitchellh
Copy link
Contributor

Have a fix queued up, just need to update deps once it is merged.

@ghost
Copy link

ghost commented Apr 23, 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 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.

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

No branches or pull requests

4 participants