title: How to attach and mount volumes to an EC2 instance using CloudFormation
body: <p>I can't find a way to attach and mount volumes using cloudformation.</p>
  
  <p>I can attach a volume using VolumeAttachment; however, when I do <code>lsblk</code> after my EC2 instance is in running state, I see this attached instances as being unmounted.</p>
  
  <p>Is there a way to mount this instance from Cloudformation file?  I can mount this using linux commands but would be much better to handle everything from cloudformation instead.</p>
  
  <p>Here is what I've so far:</p>
  
  <pre><code>"MyEc2Instance" : {
     "Type" : "AWS::EC2::Instance",
     "Properties" : {
        "KeyName" : { "Ref" : "KeyName" }
     }
  },
      "MyVolume" : {
        "Type" : "AWS::EC2::Volume",
        "Properties" : {
          "Size" : "50",
          "AvailabilityZone" : "xyz"
        }
      },
      "attachment" : {
        "Type" : "AWS::EC2::VolumeAttachment",
        "Properties" : {
          "InstanceId" : { "Ref" : "MyEc2Instance" },
          "VolumeId"  : { "Ref" : "MyVolume" },
          "Device" : "/dev/sdh"
        }
      }
  </code></pre>
  
  <p>And when I do <code>lsblk</code> on the instance, this is the result i see:</p>
  
  <pre><code>xvda    202:0    0   8G  0 disk
  └─xvda1 202:1    0   8G  0 part /
  xvdh    202:112  0  50G  0 disk
  </code></pre>
  
  <p>Notice even though I specified device name to be 'sdh' it shows attached as 'xvdh'.  Why is that?  And as you can see this is unmounted.  How do I mount this?</p>