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.83k stars 9.57k forks source link

Terraform crash when setting root_block_device attribute while launching new instance #2166

Closed ranjitshinde91 closed 9 years ago

ranjitshinde91 commented 9 years ago

Hi, I am wriintig script to launh instance in aws. Below is the template:

resource "aws_instance" "demoInstance" {
    ami = "${lookup(var.amis, "demoInstance")}"
    instance_type = "t2.micro"
    key_name ="my-key"
    subnet_id="${aws_subnet.PublicSubnet1.id}"
    source_dest_check = "false"
    root_block_device = ["default"]
    security_groups = ["${aws_security_group.jumpboxSG.id}"]
    tags {
        Name = "jumpbox"
    }
}

When i run terrrafom plan, it gets crashed. Can you please tell me how to change root block device attributes?

Below are the crash.log file contents:

EDIT by @catsby, formatting and moved crash log to gist: https://gist.github.com/catsby/ac27d20ef561c713f73d

catsby commented 9 years ago

Hello @ranjitshinde91 – root_block_device expects a block of configuration. The details of which are outlined here:

And explained in AWS Documentation ion Block Device Mapping:

An example would be like this:

  root_block_device = {
    device_name = "/dev/xvdj"
    volume_size = "200"
    delete_on_termination = false
    volume_type = "gp2"
  }

All that said, if you're looking for simply the "default", I think it's safe to omit the root_block_device entirely in your example.

Hope that helps!

catsby commented 9 years ago

@phinze Anything we can do here so this kind of thing (string used instead of a map) should error, not crash?

phinze commented 9 years ago

Yeah the fact that it crashes is definitely a bug. We can leave this open until we address.

ranjitshinde91 commented 9 years ago

@catsby : Thanks this works !

catsby commented 9 years ago

@radeksimko great to hear! Let us know if there's anything else. Until then, we'll leave this open until we can address the underlying bug that causes a crash instead of an error.

Thanks for writing in!

radeksimko commented 9 years ago

@catsby you meant @ranjitshinde91 I guess? :smiley:

catsby commented 9 years ago

@radeksimko haha, yes, sorry! :smile:

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.