Search code examples
amazon-web-servicesterraformdevopsaws-ebs

How does terraform handle mounting an AWS Elastic Block Store (EBS) with regards to partitioning?


Sample terraform code snippet for mounting an EBS (just for context):

resource "aws_ebs_volume" "ebs-volume-1" {
  availability_zone = "eu-central-1a"
  size              = 20
  type              = "gp2"
  tags = {
    Name = "extra volume data"
  }
}

resource "aws_volume_attachment" "ebs-volume-1-attachment" {
  device_name = "/dev/xvdh"
  volume_id   = aws_ebs_volume.ebs-volume-1.id
  instance_id = aws_instance.example.id
}

I have read through the terraform documentation on attributes it has for mounting EBS here; however, it is not clear to me how does that block device gets partitioned (or if partitioning here is relevant at all.

Explanation of what is EBS: here


Solution

  • The "aws_ebs_volume" resource will create the EBS volume, the "aws_volume_attachment" puts it on an EC2 instance.

    Keep in mind, you can do this in an "aws_instance" resource as well.