From 999b0874cce88279a3d39dce441a342e7c5f5017 Mon Sep 17 00:00:00 2001 From: Clint Shryock Date: Tue, 9 Jun 2015 11:38:53 -0500 Subject: [PATCH] Update AWS EBS builder to fix invalid params --- builder/amazon/common/block_device.go | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/builder/amazon/common/block_device.go b/builder/amazon/common/block_device.go index 14add3276..c44d03561 100644 --- a/builder/amazon/common/block_device.go +++ b/builder/amazon/common/block_device.go @@ -29,13 +29,23 @@ func buildBlockDevices(b []BlockDevice) []*ec2.BlockDeviceMapping { for _, blockDevice := range b { ebsBlockDevice := &ec2.EBSBlockDevice{ - SnapshotID: &blockDevice.SnapshotId, - Encrypted: &blockDevice.Encrypted, - IOPS: &blockDevice.IOPS, VolumeType: &blockDevice.VolumeType, VolumeSize: &blockDevice.VolumeSize, DeleteOnTermination: &blockDevice.DeleteOnTermination, } + + // IOPS is only valid for SSD Volumes + if blockDevice.VolumeType != "standard" && blockDevice.VolumeType != "gp2" { + ebsBlockDevice.IOPS = &blockDevice.IOPS + } + + // You cannot specify Encrypted if you specify a Snapshot ID + if blockDevice.SnapshotId != "" { + ebsBlockDevice.SnapshotID = &blockDevice.SnapshotId + } else { + ebsBlockDevice.Encrypted = &blockDevice.Encrypted + } + mapping := &ec2.BlockDeviceMapping{ EBS: ebsBlockDevice, DeviceName: &blockDevice.DeviceName,