title: Terraform - creating multiple EBS volumes
body: <p>How would I go about creating and attaching more than one EBS volume to an instance? </p>
  
  <p>The code below works when attaching a single EBS volume.  My main concern is creating a map between the size of the EBS volume and the device name.  I've tried a variant of things, creating a list, etc. But no luck.</p>
  
  <pre><code># Create EBS volume
  resource "aws_ebs_volume" "ebs_volume" {
    count                 = "${var.ec2_create_volume == true ? var.ec2_instance_count : 0 }"
    availability_zone     = "${aws_instance.ec2.*.availability_zone[count.index]}"
    size                  = "${var.ec2_ebs_volume_size}"
    type                  = "${var.ec2_ebs_volume_type}"
  }
  
  # Attach EBS Volume
  resource "aws_volume_attachment" "volume_attachment" {
    count                 = "${var.ec2_create_volume == true ? var.ec2_instance_count : 0 }"
    device_name           = "${var.ec2_device_name}"
    volume_id             = "${aws_ebs_volume.ebs_volume.*.id[count.index]}"
    instance_id           = "${aws_instance.ec2.*.id[count.index]}"
  }
  </code></pre>