From 63d784023f4f1de530b5bbd60be51c0b32a3ddde Mon Sep 17 00:00:00 2001 From: Sargun Dhillon Date: Thu, 6 Sep 2018 13:20:26 -0700 Subject: [PATCH] Add support to support non-gp2 volume types for building from_scratch --- builder/amazon/chroot/step_create_volume.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/builder/amazon/chroot/step_create_volume.go b/builder/amazon/chroot/step_create_volume.go index 34468ff7e..72f1c270f 100644 --- a/builder/amazon/chroot/step_create_volume.go +++ b/builder/amazon/chroot/step_create_volume.go @@ -2,6 +2,7 @@ package chroot import ( "context" + "errors" "fmt" "log" @@ -54,11 +55,21 @@ func (s *StepCreateVolume) Run(ctx context.Context, state multistep.StateBag) mu var createVolume *ec2.CreateVolumeInput if config.FromScratch { + rootVolumeType := ec2.VolumeTypeGp2 + if s.RootVolumeType == "io1" { + err := errors.New("Cannot use io1 volume when building from scratch") + state.Put("error", err) + ui.Error(err.Error()) + return multistep.ActionHalt + } else if s.RootVolumeType != "" { + rootVolumeType = s.RootVolumeType + } createVolume = &ec2.CreateVolumeInput{ AvailabilityZone: instance.Placement.AvailabilityZone, Size: aws.Int64(s.RootVolumeSize), - VolumeType: aws.String(ec2.VolumeTypeGp2), + VolumeType: aws.String(rootVolumeType), } + } else { // Determine the root device snapshot image := state.Get("source_image").(*ec2.Image)