diff --git a/builder/amazon/common/step_modify_ebs_instance.go b/builder/amazon/common/step_modify_ebs_instance.go index 1902c1645..6b2492b7a 100644 --- a/builder/amazon/common/step_modify_ebs_instance.go +++ b/builder/amazon/common/step_modify_ebs_instance.go @@ -13,6 +13,7 @@ import ( ) type StepModifyEBSBackedInstance struct { + Skip bool EnableAMIENASupport confighelper.Trilean EnableAMISriovNetSupport bool } @@ -22,6 +23,11 @@ func (s *StepModifyEBSBackedInstance) Run(ctx context.Context, state multistep.S instance := state.Get("instance").(*ec2.Instance) ui := state.Get("ui").(packer.Ui) + // Skip when it is a spot instance + if s.Skip { + return multistep.ActionContinue + } + // Set SriovNetSupport to "simple". See http://goo.gl/icuXh5 // As of February 2017, this applies to C3, C4, D2, I2, R3, and M4 (excluding m4.16xlarge) if s.EnableAMISriovNetSupport { diff --git a/builder/amazon/ebssurrogate/builder.go b/builder/amazon/ebssurrogate/builder.go index 2e93d19bc..24af4534f 100644 --- a/builder/amazon/ebssurrogate/builder.go +++ b/builder/amazon/ebssurrogate/builder.go @@ -123,13 +123,6 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) { errs = packer.MultiErrorAppend(errs, fmt.Errorf("no volume with name '%s' is found", b.config.RootDevice.SourceDeviceName)) } - if b.config.IsSpotInstance() && (b.config.AMIENASupport.True() || b.config.AMISriovNetSupport) { - errs = packer.MultiErrorAppend(errs, - fmt.Errorf("Spot instances do not support modification, which is required "+ - "when either `ena_support` or `sriov_support` are set. Please ensure "+ - "you use an AMI that already has either SR-IOV or ENA enabled.")) - } - if b.config.RunConfig.SpotPriceAutoProduct != "" { warns = append(warns, "spot_price_auto_product is deprecated and no "+ "longer necessary for Packer builds. In future versions of "+ @@ -294,6 +287,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack DisableStopInstance: b.config.DisableStopInstance, }, &awscommon.StepModifyEBSBackedInstance{ + Skip: b.config.IsSpotInstance(), EnableAMISriovNetSupport: b.config.AMISriovNetSupport, EnableAMIENASupport: b.config.AMIENASupport, },