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.
This commit is contained in:
Matt Rogers 2020-10-14 09:01:17 -05:00
parent c7ba5c9a14
commit 15f97421e2
No known key found for this signature in database
GPG Key ID: 6BAA7911427E1F68
2 changed files with 21 additions and 2 deletions

View File

@ -134,8 +134,8 @@ func (blockDevice BlockDevice) BuildEC2BlockDeviceMapping() *ec2.BlockDeviceMapp
ebsBlockDevice.VolumeSize = aws.Int64(blockDevice.VolumeSize) ebsBlockDevice.VolumeSize = aws.Int64(blockDevice.VolumeSize)
} }
// IOPS is only valid for io1 type // IOPS is only valid for io1 and io2 types
if blockDevice.VolumeType == "io1" { if blockDevice.VolumeType == "io1" || blockDevice.VolumeType == "io2" {
ebsBlockDevice.Iops = aws.Int64(blockDevice.IOPS) ebsBlockDevice.Iops = aws.Int64(blockDevice.IOPS)
} }

View File

@ -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{ Config: &BlockDevice{
DeviceName: "/dev/sdb", DeviceName: "/dev/sdb",