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

terraform apply crashes if a variable's default is set to a list #1344

Closed
spenczar opened this issue Mar 31, 2015 · 4 comments · Fixed by #1590
Closed

terraform apply crashes if a variable's default is set to a list #1344

spenczar opened this issue Mar 31, 2015 · 4 comments · Fixed by #1590
Assignees

Comments

@spenczar
Copy link

If you set a variable’s default to a list, then terraform apply exits with an ugly crash.

Here’s my test case:

  1. Make a new directory and cd into it:

    $ cd $(mktemp -d -t terraformtest)
  2. Make a testcase terraform config:

    $ cat > test.tf  << EOF
    variable "testcase" {
    default {
      l = [1, 2, 3]
    }
    }
    EOF
  3. Try running terraform apply:

    $ terraform apply
    panic: Unknown variable type: 0x0
    
    goroutine 1 [running]:
    github.com/hashicorp/terraform/terraform.(*Context).Input(0xc208094b00, 0xc208094b07, 0x0, 0x0)
    /Users/spencer/go/src/github.com/hashicorp/terraform/terraform/context.go:175 +0xc61
    github.com/hashicorp/terraform/command.(*ApplyCommand).Run(0xc2080641c0, 0xc20800a010, 0x0, 0x0, 0xc2080368a8)
    /Users/spencer/go/src/github.com/hashicorp/terraform/command/apply.go:125 +0x11a6
    github.com/mitchellh/cli.(*CLI).Run(0xc20806a500, 0xc2080d8ae0, 0x0, 0x0)
    /Users/spencer/go/src/github.com/mitchellh/cli/cli.go:100 +0x3ce
    main.wrappedMain(0x0)
    /Users/spencer/go/src/github.com/hashicorp/terraform/main.go:150 +0xb76
    main.realMain(0x0)
    /Users/spencer/go/src/github.com/hashicorp/terraform/main.go:82 +0x923
    main.main()
    /Users/spencer/go/src/github.com/hashicorp/terraform/main.go:18 +0x1f
    
    goroutine 5 [syscall]:
    os/signal.loop()
    /usr/local/Cellar/go/1.4.2/libexec/src/os/signal/signal_unix.go:21 +0x1f
    created by os/signal.init·1
    /usr/local/Cellar/go/1.4.2/libexec/src/os/signal/signal_unix.go:27 +0x35
    
    goroutine 8 [chan receive]:
    main.func·014()
    /Users/spencer/go/src/github.com/hashicorp/terraform/commands.go:134 +0x52
    created by main.makeShutdownCh
    /Users/spencer/go/src/github.com/hashicorp/terraform/commands.go:137 +0x1b4
    
    goroutine 9 [semacquire]:
    sync.(*Cond).Wait(0xc2080d4330)
    /usr/local/Cellar/go/1.4.2/libexec/src/sync/cond.go:62 +0x9e
    io.(*pipe).read(0xc2080d4300, 0xc20809f000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
    /usr/local/Cellar/go/1.4.2/libexec/src/io/pipe.go:52 +0x303
    io.(*PipeReader).Read(0xc2080441b0, 0xc20809f000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
    /usr/local/Cellar/go/1.4.2/libexec/src/io/pipe.go:134 +0x5b
    bufio.(*Scanner).Scan(0xc208066300, 0x0)
    /usr/local/Cellar/go/1.4.2/libexec/src/bufio/scan.go:180 +0x688
    github.com/hashicorp/terraform/command.func·006()
    /Users/spencer/go/src/github.com/hashicorp/terraform/command/meta.go:293 +0x3d
    created by github.com/hashicorp/terraform/command.(*Meta).flagSet
    /Users/spencer/go/src/github.com/hashicorp/terraform/command/meta.go:296 +0x51f
    
    
    
    !!!!!!!!!!!!!!!!!!!!!!!!!!! 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.
    
    
    
    !!!!!!!!!!!!!!!!!!!!!!!!!!! TERRAFORM CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!

I stumbled on this while crossing my fingers that I could set a default to a list of CIDR blocks to whitelist in an AWS security group. I’m fine with lists being verboten, but the error should be clearer.

@mitchellh
Copy link
Contributor

Is this with master?

@spenczar
Copy link
Author

It's on 19d6fdf, which is from Mon Mar 30 15:01:04.

I just noticed something got frazzled in writing this issue though - those are unicode quotation marks in my step 2. I had “testcase”, but it should be "testcase" of course. Try again now.

@mitchellh
Copy link
Contributor

Fixed in PR #1590. Thanks.

@mitchellh mitchellh self-assigned this Apr 18, 2015
mitchellh added a commit that referenced this issue Apr 20, 2015
terraform: don't panic on input for bad default type [GH-1344]
marvinpinto added a commit to freshbooks/terraform that referenced this issue Apr 20, 2015
* origin/master:
  update CHANGELOG
  provider/aws: fix vet error, missing fmt param
  update CHANGELOG
  update CHANGELOG
  update CHANGELOG
  terraform: don't panic on input for bad default type [hashicorpGH-1344]
  helper/ssh: add random number to script [hashicorpGH-1545]
  Allow using deprecated security_groups in NI spec
  provider/aws: Fix issue when creating ELB with no tags
  Refresh state for deleted s3 bucket correctly
  Added Docker links support to the docker_container resource.
  providers/aws: check allocationId only if it's vpc, fixes hashicorp#1345
@ghost
Copy link

ghost commented May 3, 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 May 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants