From 15f97421e2d8739631da9b0c396f5822423ff9ff Mon Sep 17 00:00:00 2001 From: Matt Rogers Date: Wed, 14 Oct 2020 09:01:17 -0500 Subject: [PATCH] builder/amazon: Add io2 as a supported volume type io2 volumes are new as of 2020-08-24. This adds support for specifying them in a packer template and having the iops value specified take effect. --- builder/amazon/common/block_device.go | 4 ++-- builder/amazon/common/block_device_test.go | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/builder/amazon/common/block_device.go b/builder/amazon/common/block_device.go index fc0ce28a3..6dc35d719 100644 --- a/builder/amazon/common/block_device.go +++ b/builder/amazon/common/block_device.go @@ -134,8 +134,8 @@ func (blockDevice BlockDevice) BuildEC2BlockDeviceMapping() *ec2.BlockDeviceMapp ebsBlockDevice.VolumeSize = aws.Int64(blockDevice.VolumeSize) } - // IOPS is only valid for io1 type - if blockDevice.VolumeType == "io1" { + // IOPS is only valid for io1 and io2 types + if blockDevice.VolumeType == "io1" || blockDevice.VolumeType == "io2" { ebsBlockDevice.Iops = aws.Int64(blockDevice.IOPS) } diff --git a/builder/amazon/common/block_device_test.go b/builder/amazon/common/block_device_test.go index 2362d4698..b434ca02b 100644 --- a/builder/amazon/common/block_device_test.go +++ b/builder/amazon/common/block_device_test.go @@ -66,6 +66,25 @@ func TestBlockDevice(t *testing.T) { }, }, }, + { + Config: &BlockDevice{ + DeviceName: "/dev/sdb", + VolumeType: "io2", + VolumeSize: 8, + DeleteOnTermination: true, + IOPS: 1000, + }, + + Result: &ec2.BlockDeviceMapping{ + DeviceName: aws.String("/dev/sdb"), + Ebs: &ec2.EbsBlockDevice{ + VolumeType: aws.String("io2"), + VolumeSize: aws.Int64(8), + DeleteOnTermination: aws.Bool(true), + Iops: aws.Int64(1000), + }, + }, + }, { Config: &BlockDevice{ DeviceName: "/dev/sdb",