Terraform – Mount EBS volume as part of user_data on an linux EC2 machine

by Sanjeev on February 19, 2017

Assumptions : You have an EC2 machine running with an attached EBS volume.
Goal : To learn how to manually/automatically mount the volume

Below is the terraform excerpt to add an ebs volume

ec2.tf

  • Manual: Login to EC2 machine and mount the EBS Volume

  • Automatic: Mount the disk as part of user data

files/attach_ebs.sh

ec2.tf

{ 3 comments… read them below or add one }

Sheifali July 17, 2017 at 9:45 AM

Really helpful

Reply

John Markston July 23, 2017 at 4:45 PM

Good work Sanjay, this really saved me a bunch of time after I ran into an Ansible bug that prevented me from doing this.

Reply

imrickysingh November 3, 2017 at 2:00 PM

How do you know that the attached volume name would be xvdg
It could be anything and that depends on AMI in aws.

Reply

Leave a Comment

Previous post:

Next post: