Specifying SSD or Magnetic EBS volumes using the Vagrant AWS provider

The Vagrant AWS Provider allows you to use Vagrant to provision virtual machines in AWS. When provisioning a machine in AWS, you are able to specify whether to use Magnetic, General Purpose SSD or Provisioned IOPS SSD volumes, depending on where you want to be on the performance/cost curve.

General Purpose SSD is now the AWS default volume type (though when I was provisioning via Vagrant, it was creating Magnetic volumes if no specific parameters were set in the VagrantFile).

You can specify the volume type in your VagrantFile using the block_device_mapping parameter in conjunction with VolumeType. Valid values for VolumeType include:

  • gp2 : General Purpose SSD
  • standard : Magnetic Discs

The below example shows how to specify SSD discs (gp2) for an 8GB volume that will be deleted when the machine terminates:

aws.block_device_mapping = [{
  'DeviceName' => '/dev/sda1',
  'Ebs.VolumeSize' => 8,
  'Ebs.VolumeType' => 'gp2',
  'Ebs.DeleteOnTermination' => 'true' }]

For a Magnetic volume, use the value standard for the VolumeType.

There's more detail on possible parameter values included in the AWS API Docs. A complete example of a VagrantFile using the AWS provider with the VolumeType option can be found at https://github.com/cruskit/vagrant-ghost/blob/master/Vagrantfile.