Terraform: Getting volume_id from aws_instance resource

Viewed 757

Is it possible with terraform to get the volume ID from the aws_instance ebs_block_device resource, or would we need to explicitly call the aws_ebs_volume/aws_volume_attachment resources?

What I currently have is:

resource "aws_instance" "ec2_app" {
...
  ebs_block_device {
    device_name           = "${var.app_ebs_device_name}"
    volume_type           = "${var.app_ebs_vol_type}"
    volume_size           = "${var.app_ebs_vol_size}"
    delete_on_termination = "${var.app_ebs_delete_on_termination}"
    encrypted             = "${var.app_ebs_encrypted}"
  }
...
}

I know I can change to aws_ebs_volume/aws_volume_attachment resources, but I believe that would destroy and recreate the volume (which I am trying to avoid).

2 Answers
Related