use ami prefix to make it clear that these variables are amazon specific
add fixer, fixer tests
This commit is contained in:
parent
9e2e467b31
commit
2d4bc70d7b
|
@ -214,8 +214,8 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
|
||||||
steps = append(steps,
|
steps = append(steps,
|
||||||
&awscommon.StepSourceAMIInfo{
|
&awscommon.StepSourceAMIInfo{
|
||||||
SourceAmi: b.config.SourceAmi,
|
SourceAmi: b.config.SourceAmi,
|
||||||
EnableSriovNetSupport: b.config.SriovNetSupport,
|
EnableAMISriovNetSupport: b.config.AMISriovNetSupport,
|
||||||
EnableENASupport: b.config.ENASupport,
|
EnableAMIENASupport: b.config.AMIENASupport,
|
||||||
AmiFilters: b.config.SourceAmiFilter,
|
AmiFilters: b.config.SourceAmiFilter,
|
||||||
},
|
},
|
||||||
&StepCheckRootDevice{},
|
&StepCheckRootDevice{},
|
||||||
|
|
|
@ -13,6 +13,8 @@ import (
|
||||||
// StepRegisterAMI creates the AMI.
|
// StepRegisterAMI creates the AMI.
|
||||||
type StepRegisterAMI struct {
|
type StepRegisterAMI struct {
|
||||||
RootVolumeSize int64
|
RootVolumeSize int64
|
||||||
|
EnableAMIENASupport bool
|
||||||
|
EnableAMISriovNetSupport bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *StepRegisterAMI) Run(state multistep.StateBag) multistep.StepAction {
|
func (s *StepRegisterAMI) Run(state multistep.StateBag) multistep.StepAction {
|
||||||
|
@ -75,11 +77,12 @@ func (s *StepRegisterAMI) Run(state multistep.StateBag) multistep.StepAction {
|
||||||
registerOpts = buildRegisterOpts(config, image, newMappings)
|
registerOpts = buildRegisterOpts(config, image, newMappings)
|
||||||
}
|
}
|
||||||
|
|
||||||
if config.AMIEnhancedNetworking {
|
if s.EnableAMISriovNetSupport {
|
||||||
// Set SriovNetSupport to "simple". See http://goo.gl/icuXh5
|
// 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)
|
// As of February 2017, this applies to C3, C4, D2, I2, R3, and M4 (excluding m4.16xlarge)
|
||||||
registerOpts.SriovNetSupport = aws.String("simple")
|
registerOpts.SriovNetSupport = aws.String("simple")
|
||||||
|
}
|
||||||
|
if s.EnableAMIENASupport {
|
||||||
// Set EnaSupport to true
|
// Set EnaSupport to true
|
||||||
// As of February 2017, this applies to C5, I3, P2, R4, X1, and m4.16xlarge
|
// As of February 2017, this applies to C5, I3, P2, R4, X1, and m4.16xlarge
|
||||||
registerOpts.EnaSupport = aws.Bool(true)
|
registerOpts.EnaSupport = aws.Bool(true)
|
||||||
|
|
|
@ -17,9 +17,8 @@ type AMIConfig struct {
|
||||||
AMIRegions []string `mapstructure:"ami_regions"`
|
AMIRegions []string `mapstructure:"ami_regions"`
|
||||||
AMISkipRegionValidation bool `mapstructure:"skip_region_validation"`
|
AMISkipRegionValidation bool `mapstructure:"skip_region_validation"`
|
||||||
AMITags map[string]string `mapstructure:"tags"`
|
AMITags map[string]string `mapstructure:"tags"`
|
||||||
AMIEnhancedNetworking bool `mapstructure:"enhanced_networking"`
|
AMIENASupport bool `mapstructure:"ena_support"`
|
||||||
ENASupport bool `mapstructure:"ena_support"`
|
AMISriovNetSupport bool `mapstructure:"sriov_support"`
|
||||||
SriovNetSupport bool `mapstructure:"sriov_support"`
|
|
||||||
AMIForceDeregister bool `mapstructure:"force_deregister"`
|
AMIForceDeregister bool `mapstructure:"force_deregister"`
|
||||||
AMIForceDeleteSnapshot bool `mapstructure:"force_delete_snapshot"`
|
AMIForceDeleteSnapshot bool `mapstructure:"force_delete_snapshot"`
|
||||||
AMIEncryptBootVolume bool `mapstructure:"encrypt_boot"`
|
AMIEncryptBootVolume bool `mapstructure:"encrypt_boot"`
|
||||||
|
@ -105,12 +104,6 @@ func (c *AMIConfig) Prepare(ctx *interpolate.Context) []error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Backwards-compatibility hack. Enhanced networking used to be hardcoded to do this.
|
|
||||||
// If users want granular choice on ENA vs SR-IOV they must not set enhanced_networking.
|
|
||||||
if c.AMIEnhancedNetworking {
|
|
||||||
c.ENASupport = true
|
|
||||||
c.SriovNetSupport = true
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(c.AMIName) < 3 || len(c.AMIName) > 128 {
|
if len(c.AMIName) < 3 || len(c.AMIName) > 128 {
|
||||||
errs = append(errs, fmt.Errorf("ami_name must be between 3 and 128 characters long"))
|
errs = append(errs, fmt.Errorf("ami_name must be between 3 and 128 characters long"))
|
||||||
|
|
|
@ -10,8 +10,8 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type StepModifyEBSBackedInstance struct {
|
type StepModifyEBSBackedInstance struct {
|
||||||
EnableENASupport bool
|
EnableAMIENASupport bool
|
||||||
EnableSriovNetSupport bool
|
EnableAMISriovNetSupport bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *StepModifyEBSBackedInstance) Run(state multistep.StateBag) multistep.StepAction {
|
func (s *StepModifyEBSBackedInstance) Run(state multistep.StateBag) multistep.StepAction {
|
||||||
|
@ -21,7 +21,7 @@ func (s *StepModifyEBSBackedInstance) Run(state multistep.StateBag) multistep.St
|
||||||
|
|
||||||
// Set SriovNetSupport to "simple". See http://goo.gl/icuXh5
|
// 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)
|
// As of February 2017, this applies to C3, C4, D2, I2, R3, and M4 (excluding m4.16xlarge)
|
||||||
if s.EnableSriovNetSupport {
|
if s.EnableAMISriovNetSupport {
|
||||||
ui.Say("Enabling Enhanced Networking (SR-IOV)...")
|
ui.Say("Enabling Enhanced Networking (SR-IOV)...")
|
||||||
simple := "simple"
|
simple := "simple"
|
||||||
_, err := ec2conn.ModifyInstanceAttribute(&ec2.ModifyInstanceAttributeInput{
|
_, err := ec2conn.ModifyInstanceAttribute(&ec2.ModifyInstanceAttributeInput{
|
||||||
|
@ -38,7 +38,7 @@ func (s *StepModifyEBSBackedInstance) Run(state multistep.StateBag) multistep.St
|
||||||
|
|
||||||
// Set EnaSupport to true.
|
// Set EnaSupport to true.
|
||||||
// As of February 2017, this applies to C5, I3, P2, R4, X1, and m4.16xlarge
|
// As of February 2017, this applies to C5, I3, P2, R4, X1, and m4.16xlarge
|
||||||
if s.EnableENASupport {
|
if s.EnableAMIENASupport {
|
||||||
ui.Say("Enabling Enhanced Networking (ENA)...")
|
ui.Say("Enabling Enhanced Networking (ENA)...")
|
||||||
_, err := ec2conn.ModifyInstanceAttribute(&ec2.ModifyInstanceAttributeInput{
|
_, err := ec2conn.ModifyInstanceAttribute(&ec2.ModifyInstanceAttributeInput{
|
||||||
InstanceId: instance.InstanceId,
|
InstanceId: instance.InstanceId,
|
||||||
|
|
|
@ -18,8 +18,8 @@ import (
|
||||||
// source_image *ec2.Image - the source AMI info
|
// source_image *ec2.Image - the source AMI info
|
||||||
type StepSourceAMIInfo struct {
|
type StepSourceAMIInfo struct {
|
||||||
SourceAmi string
|
SourceAmi string
|
||||||
EnableSriovNetSupport bool
|
EnableAMISriovNetSupport bool
|
||||||
EnableENASupport bool
|
EnableAMIENASupport bool
|
||||||
AmiFilters AmiFilterOptions
|
AmiFilters AmiFilterOptions
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@ func (s *StepSourceAMIInfo) Run(state multistep.StateBag) multistep.StepAction {
|
||||||
|
|
||||||
// Enhanced Networking can only be enabled on HVM AMIs.
|
// Enhanced Networking can only be enabled on HVM AMIs.
|
||||||
// See http://goo.gl/icuXh5
|
// See http://goo.gl/icuXh5
|
||||||
if (s.EnableENASupport || s.EnableSriovNetSupport) && *image.VirtualizationType != "hvm" {
|
if (s.EnableAMIENASupport || s.EnableAMISriovNetSupport) && *image.VirtualizationType != "hvm" {
|
||||||
err := fmt.Errorf("Cannot enable enhanced networking, source AMI '%s' is not HVM", s.SourceAmi)
|
err := fmt.Errorf("Cannot enable enhanced networking, source AMI '%s' is not HVM", s.SourceAmi)
|
||||||
state.Put("error", err)
|
state.Put("error", err)
|
||||||
ui.Error(err.Error())
|
ui.Error(err.Error())
|
||||||
|
|
|
@ -116,8 +116,8 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
|
||||||
},
|
},
|
||||||
&awscommon.StepSourceAMIInfo{
|
&awscommon.StepSourceAMIInfo{
|
||||||
SourceAmi: b.config.SourceAmi,
|
SourceAmi: b.config.SourceAmi,
|
||||||
EnableSriovNetSupport: b.config.SriovNetSupport,
|
EnableAMISriovNetSupport: b.config.AMISriovNetSupport,
|
||||||
EnableENASupport: b.config.ENASupport,
|
EnableAMIENASupport: b.config.AMIENASupport,
|
||||||
AmiFilters: b.config.SourceAmiFilter,
|
AmiFilters: b.config.SourceAmiFilter,
|
||||||
},
|
},
|
||||||
&awscommon.StepKeyPair{
|
&awscommon.StepKeyPair{
|
||||||
|
@ -180,8 +180,8 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
|
||||||
DisableStopInstance: b.config.DisableStopInstance,
|
DisableStopInstance: b.config.DisableStopInstance,
|
||||||
},
|
},
|
||||||
&awscommon.StepModifyEBSBackedInstance{
|
&awscommon.StepModifyEBSBackedInstance{
|
||||||
EnableSriovNetSupport: b.config.SriovNetSupport,
|
EnableAMISriovNetSupport: b.config.AMISriovNetSupport,
|
||||||
EnableENASupport: b.config.ENASupport,
|
EnableAMIENASupport: b.config.AMIENASupport,
|
||||||
},
|
},
|
||||||
&awscommon.StepDeregisterAMI{
|
&awscommon.StepDeregisterAMI{
|
||||||
AccessConfig: &b.config.AccessConfig,
|
AccessConfig: &b.config.AccessConfig,
|
||||||
|
|
|
@ -130,8 +130,8 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
|
||||||
},
|
},
|
||||||
&awscommon.StepSourceAMIInfo{
|
&awscommon.StepSourceAMIInfo{
|
||||||
SourceAmi: b.config.SourceAmi,
|
SourceAmi: b.config.SourceAmi,
|
||||||
EnableSriovNetSupport: b.config.SriovNetSupport,
|
EnableAMISriovNetSupport: b.config.AMISriovNetSupport,
|
||||||
EnableENASupport: b.config.ENASupport,
|
EnableAMIENASupport: b.config.AMIENASupport,
|
||||||
AmiFilters: b.config.SourceAmiFilter,
|
AmiFilters: b.config.SourceAmiFilter,
|
||||||
},
|
},
|
||||||
&awscommon.StepKeyPair{
|
&awscommon.StepKeyPair{
|
||||||
|
@ -190,8 +190,8 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
|
||||||
DisableStopInstance: b.config.DisableStopInstance,
|
DisableStopInstance: b.config.DisableStopInstance,
|
||||||
},
|
},
|
||||||
&awscommon.StepModifyEBSBackedInstance{
|
&awscommon.StepModifyEBSBackedInstance{
|
||||||
EnableSriovNetSupport: b.config.SriovNetSupport,
|
EnableAMISriovNetSupport: b.config.AMISriovNetSupport,
|
||||||
EnableENASupport: b.config.ENASupport,
|
EnableAMIENASupport: b.config.AMIENASupport,
|
||||||
},
|
},
|
||||||
&StepSnapshotNewRootVolume{
|
&StepSnapshotNewRootVolume{
|
||||||
NewRootMountPoint: b.config.RootDevice.SourceDeviceName,
|
NewRootMountPoint: b.config.RootDevice.SourceDeviceName,
|
||||||
|
@ -206,6 +206,8 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
|
||||||
&StepRegisterAMI{
|
&StepRegisterAMI{
|
||||||
RootDevice: b.config.RootDevice,
|
RootDevice: b.config.RootDevice,
|
||||||
BlockDevices: b.config.BlockDevices.BuildAMIDevices(),
|
BlockDevices: b.config.BlockDevices.BuildAMIDevices(),
|
||||||
|
EnableAMISriovNetSupport: b.config.AMISriovNetSupport,
|
||||||
|
EnableAMIENASupport: b.config.AMIENASupport,
|
||||||
},
|
},
|
||||||
&awscommon.StepCreateEncryptedAMICopy{
|
&awscommon.StepCreateEncryptedAMICopy{
|
||||||
KeyID: b.config.AMIKmsKeyId,
|
KeyID: b.config.AMIKmsKeyId,
|
||||||
|
|
|
@ -14,6 +14,8 @@ import (
|
||||||
type StepRegisterAMI struct {
|
type StepRegisterAMI struct {
|
||||||
RootDevice RootBlockDevice
|
RootDevice RootBlockDevice
|
||||||
BlockDevices []*ec2.BlockDeviceMapping
|
BlockDevices []*ec2.BlockDeviceMapping
|
||||||
|
EnableAMIENASupport bool
|
||||||
|
EnableAMISriovNetSupport bool
|
||||||
image *ec2.Image
|
image *ec2.Image
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,16 +37,16 @@ func (s *StepRegisterAMI) Run(state multistep.StateBag) multistep.StepAction {
|
||||||
BlockDeviceMappings: blockDevicesExcludingRoot,
|
BlockDeviceMappings: blockDevicesExcludingRoot,
|
||||||
}
|
}
|
||||||
|
|
||||||
if config.AMIEnhancedNetworking {
|
if s.EnableAMISriovNetSupport {
|
||||||
// Set SriovNetSupport to "simple". See http://goo.gl/icuXh5
|
// 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)
|
// As of February 2017, this applies to C3, C4, D2, I2, R3, and M4 (excluding m4.16xlarge)
|
||||||
registerOpts.SriovNetSupport = aws.String("simple")
|
registerOpts.SriovNetSupport = aws.String("simple")
|
||||||
|
}
|
||||||
|
if s.EnableAMIENASupport {
|
||||||
// Set EnaSupport to true
|
// Set EnaSupport to true
|
||||||
// As of February 2017, this applies to C5, I3, P2, R4, X1, and m4.16xlarge
|
// As of February 2017, this applies to C5, I3, P2, R4, X1, and m4.16xlarge
|
||||||
registerOpts.EnaSupport = aws.Bool(true)
|
registerOpts.EnaSupport = aws.Bool(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
registerResp, err := ec2conn.RegisterImage(registerOpts)
|
registerResp, err := ec2conn.RegisterImage(registerOpts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
state.Put("error", fmt.Errorf("Error registering AMI: %s", err))
|
state.Put("error", fmt.Errorf("Error registering AMI: %s", err))
|
||||||
|
|
|
@ -24,8 +24,8 @@ type Config struct {
|
||||||
awscommon.RunConfig `mapstructure:",squash"`
|
awscommon.RunConfig `mapstructure:",squash"`
|
||||||
|
|
||||||
VolumeMappings []BlockDevice `mapstructure:"ebs_volumes"`
|
VolumeMappings []BlockDevice `mapstructure:"ebs_volumes"`
|
||||||
ENASupport bool `mapstructure:"ena_support"`
|
AMIENASupport bool `mapstructure:"ena_support"`
|
||||||
SriovNetSupport bool `mapstructure:"sriov_support"`
|
AMISriovNetSupport bool `mapstructure:"sriov_support"`
|
||||||
|
|
||||||
launchBlockDevices awscommon.BlockDevices
|
launchBlockDevices awscommon.BlockDevices
|
||||||
ctx interpolate.Context
|
ctx interpolate.Context
|
||||||
|
@ -105,8 +105,8 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
|
||||||
steps := []multistep.Step{
|
steps := []multistep.Step{
|
||||||
&awscommon.StepSourceAMIInfo{
|
&awscommon.StepSourceAMIInfo{
|
||||||
SourceAmi: b.config.SourceAmi,
|
SourceAmi: b.config.SourceAmi,
|
||||||
EnableSriovNetSupport: b.config.SriovNetSupport,
|
EnableAMISriovNetSupport: b.config.AMISriovNetSupport,
|
||||||
EnableENASupport: b.config.ENASupport,
|
EnableAMIENASupport: b.config.AMIENASupport,
|
||||||
AmiFilters: b.config.SourceAmiFilter,
|
AmiFilters: b.config.SourceAmiFilter,
|
||||||
},
|
},
|
||||||
&awscommon.StepKeyPair{
|
&awscommon.StepKeyPair{
|
||||||
|
@ -166,8 +166,8 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
|
||||||
DisableStopInstance: b.config.DisableStopInstance,
|
DisableStopInstance: b.config.DisableStopInstance,
|
||||||
},
|
},
|
||||||
&awscommon.StepModifyEBSBackedInstance{
|
&awscommon.StepModifyEBSBackedInstance{
|
||||||
EnableSriovNetSupport: b.config.SriovNetSupport,
|
EnableAMISriovNetSupport: b.config.AMISriovNetSupport,
|
||||||
EnableENASupport: b.config.ENASupport,
|
EnableAMIENASupport: b.config.AMIENASupport,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -201,8 +201,8 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
|
||||||
},
|
},
|
||||||
&awscommon.StepSourceAMIInfo{
|
&awscommon.StepSourceAMIInfo{
|
||||||
SourceAmi: b.config.SourceAmi,
|
SourceAmi: b.config.SourceAmi,
|
||||||
EnableSriovNetSupport: b.config.SriovNetSupport,
|
EnableAMISriovNetSupport: b.config.AMISriovNetSupport,
|
||||||
EnableENASupport: b.config.ENASupport,
|
EnableAMIENASupport: b.config.AMIENASupport,
|
||||||
AmiFilters: b.config.SourceAmiFilter,
|
AmiFilters: b.config.SourceAmiFilter,
|
||||||
},
|
},
|
||||||
&awscommon.StepKeyPair{
|
&awscommon.StepKeyPair{
|
||||||
|
@ -265,7 +265,10 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
|
||||||
AMIName: b.config.AMIName,
|
AMIName: b.config.AMIName,
|
||||||
Regions: b.config.AMIRegions,
|
Regions: b.config.AMIRegions,
|
||||||
},
|
},
|
||||||
&StepRegisterAMI{},
|
&StepRegisterAMI{
|
||||||
|
EnableAMISriovNetSupport: b.config.AMISriovNetSupport,
|
||||||
|
EnableAMIENASupport: b.config.AMIENASupport,
|
||||||
|
},
|
||||||
&awscommon.StepAMIRegionCopy{
|
&awscommon.StepAMIRegionCopy{
|
||||||
AccessConfig: &b.config.AccessConfig,
|
AccessConfig: &b.config.AccessConfig,
|
||||||
Regions: b.config.AMIRegions,
|
Regions: b.config.AMIRegions,
|
||||||
|
|
|
@ -10,7 +10,10 @@ import (
|
||||||
"github.com/mitchellh/multistep"
|
"github.com/mitchellh/multistep"
|
||||||
)
|
)
|
||||||
|
|
||||||
type StepRegisterAMI struct{}
|
type StepRegisterAMI struct {
|
||||||
|
EnableAMIENASupport bool
|
||||||
|
EnableAMISriovNetSupport bool
|
||||||
|
}
|
||||||
|
|
||||||
func (s *StepRegisterAMI) Run(state multistep.StateBag) multistep.StepAction {
|
func (s *StepRegisterAMI) Run(state multistep.StateBag) multistep.StepAction {
|
||||||
config := state.Get("config").(*Config)
|
config := state.Get("config").(*Config)
|
||||||
|
@ -29,12 +32,13 @@ func (s *StepRegisterAMI) Run(state multistep.StateBag) multistep.StepAction {
|
||||||
registerOpts.VirtualizationType = aws.String(config.AMIVirtType)
|
registerOpts.VirtualizationType = aws.String(config.AMIVirtType)
|
||||||
}
|
}
|
||||||
|
|
||||||
if config.AMIEnhancedNetworking {
|
if s.EnableAMISriovNetSupport {
|
||||||
// Set SriovNetSupport to "simple". See http://goo.gl/icuXh5
|
// 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)
|
// As of February 2017, this applies to C3, C4, D2, I2, R3, and M4 (excluding m4.16xlarge)
|
||||||
registerOpts.SriovNetSupport = aws.String("simple")
|
registerOpts.SriovNetSupport = aws.String("simple")
|
||||||
|
}
|
||||||
// Set EnaSupport to true.
|
if s.EnableAMIENASupport {
|
||||||
|
// Set EnaSupport to true
|
||||||
// As of February 2017, this applies to C5, I3, P2, R4, X1, and m4.16xlarge
|
// As of February 2017, this applies to C5, I3, P2, R4, X1, and m4.16xlarge
|
||||||
registerOpts.EnaSupport = aws.Bool(true)
|
registerOpts.EnaSupport = aws.Bool(true)
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@ func init() {
|
||||||
"sshkeypath": new(FixerSSHKeyPath),
|
"sshkeypath": new(FixerSSHKeyPath),
|
||||||
"manifest-filename": new(FixerManifestFilename),
|
"manifest-filename": new(FixerManifestFilename),
|
||||||
"amazon-shutdown_behavior": new(FixerAmazonShutdownBehavior),
|
"amazon-shutdown_behavior": new(FixerAmazonShutdownBehavior),
|
||||||
|
"enhanced-networking": new(FixerEnhancedNetworking),
|
||||||
}
|
}
|
||||||
|
|
||||||
FixerOrder = []string{
|
FixerOrder = []string{
|
||||||
|
@ -45,5 +46,6 @@ func init() {
|
||||||
"sshkeypath",
|
"sshkeypath",
|
||||||
"manifest-filename",
|
"manifest-filename",
|
||||||
"amazon-shutdown_behavior",
|
"amazon-shutdown_behavior",
|
||||||
|
"enhanced-networking",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
package fix
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/mitchellh/mapstructure"
|
||||||
|
)
|
||||||
|
|
||||||
|
// FixerEnhancedNetworking is a Fixer that replaces the "enhanced_networking" configuration key
|
||||||
|
// with the clearer "ena_support". This disambiguates ena_support from sriov_support.
|
||||||
|
type FixerEnhancedNetworking struct{}
|
||||||
|
|
||||||
|
func (FixerEnhancedNetworking) Fix(input map[string]interface{}) (map[string]interface{}, error) {
|
||||||
|
// Our template type we'll use for this fixer only
|
||||||
|
type template struct {
|
||||||
|
Builders []map[string]interface{}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Decode the input into our structure, if we can
|
||||||
|
var tpl template
|
||||||
|
if err := mapstructure.Decode(input, &tpl); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Go through each builder and replace the enhanced_networking if we can
|
||||||
|
for _, builder := range tpl.Builders {
|
||||||
|
enhancedNetworkingRaw, ok := builder["enhanced_networking"]
|
||||||
|
if !ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
enhancedNetworkingString, ok := enhancedNetworkingRaw.(bool)
|
||||||
|
if !ok {
|
||||||
|
// TODO: error?
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
delete(builder, "enhanced_networking")
|
||||||
|
builder["ena_support"] = enhancedNetworkingString
|
||||||
|
}
|
||||||
|
|
||||||
|
input["builders"] = tpl.Builders
|
||||||
|
return input, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (FixerEnhancedNetworking) Synopsis() string {
|
||||||
|
return `Replaces "enhanced_networking" in builders with "ena_support"`
|
||||||
|
}
|
|
@ -0,0 +1,64 @@
|
||||||
|
package fix
|
||||||
|
|
||||||
|
import (
|
||||||
|
"reflect"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestFixerEnhancedNetworking_Impl(t *testing.T) {
|
||||||
|
var _ Fixer = new(FixerEnhancedNetworking)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestFixerEnhancedNetworking(t *testing.T) {
|
||||||
|
cases := []struct {
|
||||||
|
Input map[string]interface{}
|
||||||
|
Expected map[string]interface{}
|
||||||
|
}{
|
||||||
|
// Attach field == false
|
||||||
|
{
|
||||||
|
Input: map[string]interface{}{
|
||||||
|
"type": "ebs",
|
||||||
|
"enhanced_networking": false,
|
||||||
|
},
|
||||||
|
|
||||||
|
Expected: map[string]interface{}{
|
||||||
|
"type": "ebs",
|
||||||
|
"ena_support": false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
// Attach field == true
|
||||||
|
{
|
||||||
|
Input: map[string]interface{}{
|
||||||
|
"type": "ebs",
|
||||||
|
"enhanced_networking": true,
|
||||||
|
},
|
||||||
|
|
||||||
|
Expected: map[string]interface{}{
|
||||||
|
"type": "ebs",
|
||||||
|
"ena_support": true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tc := range cases {
|
||||||
|
var f FixerEnhancedNetworking
|
||||||
|
|
||||||
|
input := map[string]interface{}{
|
||||||
|
"builders": []map[string]interface{}{tc.Input},
|
||||||
|
}
|
||||||
|
|
||||||
|
expected := map[string]interface{}{
|
||||||
|
"builders": []map[string]interface{}{tc.Expected},
|
||||||
|
}
|
||||||
|
|
||||||
|
output, err := f.Fix(input)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("err: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if !reflect.DeepEqual(output, expected) {
|
||||||
|
t.Fatalf("unexpected: %#v\nexpected: %#v\n", output, expected)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -168,15 +168,9 @@ builder.
|
||||||
- `ena_support` (boolean) - Enable enhanced networking (ENA but not SriovNetSupport)
|
- `ena_support` (boolean) - Enable enhanced networking (ENA but not SriovNetSupport)
|
||||||
on HVM-compatible AMIs. If true, add `ec2:ModifyInstanceAttribute` to your AWS IAM policy.
|
on HVM-compatible AMIs. If true, add `ec2:ModifyInstanceAttribute` to your AWS IAM policy.
|
||||||
Note: you must make sure enhanced networking is enabled on your instance. See [Amazon's
|
Note: you must make sure enhanced networking is enabled on your instance. See [Amazon's
|
||||||
documentation on enabling enhanced networking](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/enhanced-networking.html#enabling_enhanced_networking).
|
documentation on enabling enhanced networking](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/enhanced-networking.html#enabling_enhanced_networking). Default `false`.
|
||||||
If you want to set this, but not `sriov_support`, make sure to leave `enhanced_networking: false`.
|
|
||||||
Default `false`.
|
|
||||||
|
|
||||||
- `enhanced_networking` (boolean) - Enable enhanced
|
- `enhanced_networking` (boolean) - deprecated. Default `false`. For now, setting to `true` will set `ena_support` to `true` in order to preserve backwards compatability.
|
||||||
networking (SriovNetSupport and ENA) on HVM-compatible AMIs. If true, add
|
|
||||||
`ec2:ModifyInstanceAttribute` to your AWS IAM policy. Note: you must make
|
|
||||||
sure enhanced networking is enabled on your instance. See [Amazon's
|
|
||||||
documentation on enabling enhanced networking](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/enhanced-networking.html#enabling_enhanced_networking). To enable SriovNetSupport and ENA support independently, use `sriov_support` and `ena_support` instead of `enhanced_networking`. Using `enhanced_networking: true` will automatically set both `sriov_support` and `ena_support` to `true`, overriding any values you set. Default `false`.
|
|
||||||
|
|
||||||
- `force_deregister` (boolean) - Force Packer to first deregister an existing
|
- `force_deregister` (boolean) - Force Packer to first deregister an existing
|
||||||
AMI if one with the same name already exists. Default `false`.
|
AMI if one with the same name already exists. Default `false`.
|
||||||
|
|
|
@ -161,15 +161,9 @@ builder.
|
||||||
- `ena_support` (boolean) - Enable enhanced networking (ENA but not SriovNetSupport)
|
- `ena_support` (boolean) - Enable enhanced networking (ENA but not SriovNetSupport)
|
||||||
on HVM-compatible AMIs. If true, add `ec2:ModifyInstanceAttribute` to your AWS IAM policy.
|
on HVM-compatible AMIs. If true, add `ec2:ModifyInstanceAttribute` to your AWS IAM policy.
|
||||||
Note: you must make sure enhanced networking is enabled on your instance. See [Amazon's
|
Note: you must make sure enhanced networking is enabled on your instance. See [Amazon's
|
||||||
documentation on enabling enhanced networking](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/enhanced-networking.html#enabling_enhanced_networking).
|
documentation on enabling enhanced networking](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/enhanced-networking.html#enabling_enhanced_networking). Default `false`.
|
||||||
If you want to set this, but not `sriov_support`, make sure to leave `enhanced_networking: false`.
|
|
||||||
Default `false`.
|
|
||||||
|
|
||||||
- `enhanced_networking` (boolean) - Enable enhanced
|
- `enhanced_networking` (boolean) - deprecated. Default `false`. For now, setting to `true` will set `ena_support` to `true` in order to preserve backwards compatability.
|
||||||
networking (SriovNetSupport and ENA) on HVM-compatible AMIs. If true, add
|
|
||||||
`ec2:ModifyInstanceAttribute` to your AWS IAM policy. Note: you must make
|
|
||||||
sure enhanced networking is enabled on your instance. See [Amazon's
|
|
||||||
documentation on enabling enhanced networking](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/enhanced-networking.html#enabling_enhanced_networking). To enable SriovNetSupport and ENA support independently, use `sriov_support` and `ena_support` instead of `enhanced_networking`. Using `enhanced_networking: true` will automatically set both `sriov_support` and `ena_support` to `true`, overriding any values you set. Default `false`.
|
|
||||||
|
|
||||||
- `force_deregister` (boolean) - Force Packer to first deregister an existing
|
- `force_deregister` (boolean) - Force Packer to first deregister an existing
|
||||||
AMI if one with the same name already exists. Default `false`.
|
AMI if one with the same name already exists. Default `false`.
|
||||||
|
|
|
@ -107,15 +107,9 @@ builder.
|
||||||
- `ena_support` (boolean) - Enable enhanced networking (ENA but not SriovNetSupport)
|
- `ena_support` (boolean) - Enable enhanced networking (ENA but not SriovNetSupport)
|
||||||
on HVM-compatible AMIs. If true, add `ec2:ModifyInstanceAttribute` to your AWS IAM policy.
|
on HVM-compatible AMIs. If true, add `ec2:ModifyInstanceAttribute` to your AWS IAM policy.
|
||||||
Note: you must make sure enhanced networking is enabled on your instance. See [Amazon's
|
Note: you must make sure enhanced networking is enabled on your instance. See [Amazon's
|
||||||
documentation on enabling enhanced networking](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/enhanced-networking.html#enabling_enhanced_networking).
|
documentation on enabling enhanced networking](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/enhanced-networking.html#enabling_enhanced_networking). Default `false`.
|
||||||
If you want to set this, but not `sriov_support`, make sure to leave `enhanced_networking: false`.
|
|
||||||
Default `false`.
|
|
||||||
|
|
||||||
- `enhanced_networking` (boolean) - Enable enhanced
|
- `enhanced_networking` (boolean) - deprecated. Default `false`. For now, setting to `true` will set `ena_support` to `true` in order to preserve backwards compatability.
|
||||||
networking (SriovNetSupport and ENA) on HVM-compatible AMIs. If true, add
|
|
||||||
`ec2:ModifyInstanceAttribute` to your AWS IAM policy. Note: you must make
|
|
||||||
sure enhanced networking is enabled on your instance. See [Amazon's
|
|
||||||
documentation on enabling enhanced networking](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/enhanced-networking.html#enabling_enhanced_networking). To enable SriovNetSupport and ENA support independently, use `sriov_support` and `ena_support` instead of `enhanced_networking`. Using `enhanced_networking: true` will automatically set both `sriov_support` and `ena_support` to `true`, overriding any values you set. Default `false`.
|
|
||||||
|
|
||||||
- `iam_instance_profile` (string) - The name of an [IAM instance
|
- `iam_instance_profile` (string) - The name of an [IAM instance
|
||||||
profile](https://docs.aws.amazon.com/IAM/latest/UserGuide/instance-profiles.html)
|
profile](https://docs.aws.amazon.com/IAM/latest/UserGuide/instance-profiles.html)
|
||||||
|
|
|
@ -189,11 +189,7 @@ builder.
|
||||||
Optimized](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EBSOptimized.html).
|
Optimized](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EBSOptimized.html).
|
||||||
Default `false`.
|
Default `false`.
|
||||||
|
|
||||||
- `enhanced_networking` (boolean) - Enable enhanced
|
- `enhanced_networking` (boolean) - deprecated. Default `false`. For now, setting to `true` will set `ena_support` to `true` in order to preserve backwards compatability.
|
||||||
networking (SriovNetSupport and ENA) on HVM-compatible AMIs. If true, add
|
|
||||||
`ec2:ModifyInstanceAttribute` to your AWS IAM policy. Note: you must make
|
|
||||||
sure enhanced networking is enabled on your instance. See [Amazon's
|
|
||||||
documentation on enabling enhanced networking](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/enhanced-networking.html#enabling_enhanced_networking)
|
|
||||||
|
|
||||||
- `force_deregister` (boolean) - Force Packer to first deregister an existing
|
- `force_deregister` (boolean) - Force Packer to first deregister an existing
|
||||||
AMI if one with the same name already exists. Defaults to `false`.
|
AMI if one with the same name already exists. Defaults to `false`.
|
||||||
|
|
Loading…
Reference in New Issue