From 9e2e467b319c9922900997183b7dab66193784dc Mon Sep 17 00:00:00 2001 From: Megan Marsh Date: Fri, 25 Aug 2017 09:14:12 -0700 Subject: [PATCH 1/4] Allow granular modification of sriov and ena enhanced networking options in amazon amis. Maintain old functionality. --- builder/amazon/chroot/builder.go | 7 ++++--- builder/amazon/common/ami_config.go | 8 ++++++++ .../amazon/common/step_modify_ebs_instance.go | 17 ++++++++++------- builder/amazon/common/step_source_ami_info.go | 9 +++++---- builder/amazon/ebs/builder.go | 10 ++++++---- builder/amazon/ebssurrogate/builder.go | 10 ++++++---- builder/amazon/ebsvolume/builder.go | 15 +++++++++------ builder/amazon/instance/builder.go | 7 ++++--- .../source/docs/builders/amazon-chroot.html.md | 6 ------ website/source/docs/builders/amazon-ebs.html.md | 16 +++++++++++++++- .../docs/builders/amazon-ebssurrogate.html.md | 16 +++++++++++++++- .../docs/builders/amazon-ebsvolume.html.md | 16 +++++++++++++++- 12 files changed, 97 insertions(+), 40 deletions(-) diff --git a/builder/amazon/chroot/builder.go b/builder/amazon/chroot/builder.go index afd026f95..7bface62d 100644 --- a/builder/amazon/chroot/builder.go +++ b/builder/amazon/chroot/builder.go @@ -213,9 +213,10 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe if !b.config.FromScratch { steps = append(steps, &awscommon.StepSourceAMIInfo{ - SourceAmi: b.config.SourceAmi, - EnhancedNetworking: b.config.AMIEnhancedNetworking, - AmiFilters: b.config.SourceAmiFilter, + SourceAmi: b.config.SourceAmi, + EnableSriovNetSupport: b.config.SriovNetSupport, + EnableENASupport: b.config.ENASupport, + AmiFilters: b.config.SourceAmiFilter, }, &StepCheckRootDevice{}, ) diff --git a/builder/amazon/common/ami_config.go b/builder/amazon/common/ami_config.go index 72fd07046..35db315a9 100644 --- a/builder/amazon/common/ami_config.go +++ b/builder/amazon/common/ami_config.go @@ -18,6 +18,8 @@ type AMIConfig struct { AMISkipRegionValidation bool `mapstructure:"skip_region_validation"` AMITags map[string]string `mapstructure:"tags"` AMIEnhancedNetworking bool `mapstructure:"enhanced_networking"` + ENASupport bool `mapstructure:"ena_support"` + SriovNetSupport bool `mapstructure:"sriov_support"` AMIForceDeregister bool `mapstructure:"force_deregister"` AMIForceDeleteSnapshot bool `mapstructure:"force_delete_snapshot"` AMIEncryptBootVolume bool `mapstructure:"encrypt_boot"` @@ -103,6 +105,12 @@ 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 { errs = append(errs, fmt.Errorf("ami_name must be between 3 and 128 characters long")) diff --git a/builder/amazon/common/step_modify_ebs_instance.go b/builder/amazon/common/step_modify_ebs_instance.go index 11fa629d9..6af48f6f6 100644 --- a/builder/amazon/common/step_modify_ebs_instance.go +++ b/builder/amazon/common/step_modify_ebs_instance.go @@ -10,7 +10,8 @@ import ( ) type StepModifyEBSBackedInstance struct { - EnableEnhancedNetworking bool + EnableENASupport bool + EnableSriovNetSupport bool } func (s *StepModifyEBSBackedInstance) Run(state multistep.StateBag) multistep.StepAction { @@ -18,9 +19,9 @@ func (s *StepModifyEBSBackedInstance) Run(state multistep.StateBag) multistep.St instance := state.Get("instance").(*ec2.Instance) ui := state.Get("ui").(packer.Ui) - if s.EnableEnhancedNetworking { - // 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) + // 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.EnableSriovNetSupport { ui.Say("Enabling Enhanced Networking (SR-IOV)...") simple := "simple" _, err := ec2conn.ModifyInstanceAttribute(&ec2.ModifyInstanceAttributeInput{ @@ -33,11 +34,13 @@ func (s *StepModifyEBSBackedInstance) Run(state multistep.StateBag) multistep.St ui.Error(err.Error()) return multistep.ActionHalt } + } - // Set EnaSupport to true. - // As of February 2017, this applies to C5, I3, P2, R4, X1, and m4.16xlarge + // Set EnaSupport to true. + // As of February 2017, this applies to C5, I3, P2, R4, X1, and m4.16xlarge + if s.EnableENASupport { ui.Say("Enabling Enhanced Networking (ENA)...") - _, err = ec2conn.ModifyInstanceAttribute(&ec2.ModifyInstanceAttributeInput{ + _, err := ec2conn.ModifyInstanceAttribute(&ec2.ModifyInstanceAttributeInput{ InstanceId: instance.InstanceId, EnaSupport: &ec2.AttributeBooleanValue{Value: aws.Bool(true)}, }) diff --git a/builder/amazon/common/step_source_ami_info.go b/builder/amazon/common/step_source_ami_info.go index 386e8e8db..dbbf4a218 100644 --- a/builder/amazon/common/step_source_ami_info.go +++ b/builder/amazon/common/step_source_ami_info.go @@ -17,9 +17,10 @@ import ( // Produces: // source_image *ec2.Image - the source AMI info type StepSourceAMIInfo struct { - SourceAmi string - EnhancedNetworking bool - AmiFilters AmiFilterOptions + SourceAmi string + EnableSriovNetSupport bool + EnableENASupport bool + AmiFilters AmiFilterOptions } // Build a slice of AMI filter options from the filters provided. @@ -103,7 +104,7 @@ func (s *StepSourceAMIInfo) Run(state multistep.StateBag) multistep.StepAction { // Enhanced Networking can only be enabled on HVM AMIs. // See http://goo.gl/icuXh5 - if s.EnhancedNetworking && *image.VirtualizationType != "hvm" { + if (s.EnableENASupport || s.EnableSriovNetSupport) && *image.VirtualizationType != "hvm" { err := fmt.Errorf("Cannot enable enhanced networking, source AMI '%s' is not HVM", s.SourceAmi) state.Put("error", err) ui.Error(err.Error()) diff --git a/builder/amazon/ebs/builder.go b/builder/amazon/ebs/builder.go index 5d8a3e4be..4f35568fc 100644 --- a/builder/amazon/ebs/builder.go +++ b/builder/amazon/ebs/builder.go @@ -115,9 +115,10 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe ForceDeregister: b.config.AMIForceDeregister, }, &awscommon.StepSourceAMIInfo{ - SourceAmi: b.config.SourceAmi, - EnhancedNetworking: b.config.AMIEnhancedNetworking, - AmiFilters: b.config.SourceAmiFilter, + SourceAmi: b.config.SourceAmi, + EnableSriovNetSupport: b.config.SriovNetSupport, + EnableENASupport: b.config.ENASupport, + AmiFilters: b.config.SourceAmiFilter, }, &awscommon.StepKeyPair{ Debug: b.config.PackerDebug, @@ -179,7 +180,8 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe DisableStopInstance: b.config.DisableStopInstance, }, &awscommon.StepModifyEBSBackedInstance{ - EnableEnhancedNetworking: b.config.AMIEnhancedNetworking, + EnableSriovNetSupport: b.config.SriovNetSupport, + EnableENASupport: b.config.ENASupport, }, &awscommon.StepDeregisterAMI{ AccessConfig: &b.config.AccessConfig, diff --git a/builder/amazon/ebssurrogate/builder.go b/builder/amazon/ebssurrogate/builder.go index bf00921e7..e2f7b3fd0 100644 --- a/builder/amazon/ebssurrogate/builder.go +++ b/builder/amazon/ebssurrogate/builder.go @@ -129,9 +129,10 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe ForceDeregister: b.config.AMIForceDeregister, }, &awscommon.StepSourceAMIInfo{ - SourceAmi: b.config.SourceAmi, - EnhancedNetworking: b.config.AMIEnhancedNetworking, - AmiFilters: b.config.SourceAmiFilter, + SourceAmi: b.config.SourceAmi, + EnableSriovNetSupport: b.config.SriovNetSupport, + EnableENASupport: b.config.ENASupport, + AmiFilters: b.config.SourceAmiFilter, }, &awscommon.StepKeyPair{ Debug: b.config.PackerDebug, @@ -189,7 +190,8 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe DisableStopInstance: b.config.DisableStopInstance, }, &awscommon.StepModifyEBSBackedInstance{ - EnableEnhancedNetworking: b.config.AMIEnhancedNetworking, + EnableSriovNetSupport: b.config.SriovNetSupport, + EnableENASupport: b.config.ENASupport, }, &StepSnapshotNewRootVolume{ NewRootMountPoint: b.config.RootDevice.SourceDeviceName, diff --git a/builder/amazon/ebsvolume/builder.go b/builder/amazon/ebsvolume/builder.go index 098cb4c9e..d04366975 100644 --- a/builder/amazon/ebsvolume/builder.go +++ b/builder/amazon/ebsvolume/builder.go @@ -23,8 +23,9 @@ type Config struct { awscommon.AccessConfig `mapstructure:",squash"` awscommon.RunConfig `mapstructure:",squash"` - VolumeMappings []BlockDevice `mapstructure:"ebs_volumes"` - AMIEnhancedNetworking bool `mapstructure:"enhanced_networking"` + VolumeMappings []BlockDevice `mapstructure:"ebs_volumes"` + ENASupport bool `mapstructure:"ena_support"` + SriovNetSupport bool `mapstructure:"sriov_support"` launchBlockDevices awscommon.BlockDevices ctx interpolate.Context @@ -103,9 +104,10 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe // Build the steps steps := []multistep.Step{ &awscommon.StepSourceAMIInfo{ - SourceAmi: b.config.SourceAmi, - EnhancedNetworking: b.config.AMIEnhancedNetworking, - AmiFilters: b.config.SourceAmiFilter, + SourceAmi: b.config.SourceAmi, + EnableSriovNetSupport: b.config.SriovNetSupport, + EnableENASupport: b.config.ENASupport, + AmiFilters: b.config.SourceAmiFilter, }, &awscommon.StepKeyPair{ Debug: b.config.PackerDebug, @@ -164,7 +166,8 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe DisableStopInstance: b.config.DisableStopInstance, }, &awscommon.StepModifyEBSBackedInstance{ - EnableEnhancedNetworking: b.config.AMIEnhancedNetworking, + EnableSriovNetSupport: b.config.SriovNetSupport, + EnableENASupport: b.config.ENASupport, }, } diff --git a/builder/amazon/instance/builder.go b/builder/amazon/instance/builder.go index 5580caf8a..d90e8e1a0 100644 --- a/builder/amazon/instance/builder.go +++ b/builder/amazon/instance/builder.go @@ -200,9 +200,10 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe ForceDeregister: b.config.AMIForceDeregister, }, &awscommon.StepSourceAMIInfo{ - SourceAmi: b.config.SourceAmi, - EnhancedNetworking: b.config.AMIEnhancedNetworking, - AmiFilters: b.config.SourceAmiFilter, + SourceAmi: b.config.SourceAmi, + EnableSriovNetSupport: b.config.SriovNetSupport, + EnableENASupport: b.config.ENASupport, + AmiFilters: b.config.SourceAmiFilter, }, &awscommon.StepKeyPair{ Debug: b.config.PackerDebug, diff --git a/website/source/docs/builders/amazon-chroot.html.md b/website/source/docs/builders/amazon-chroot.html.md index 36c0cde1f..2d06d9e7a 100644 --- a/website/source/docs/builders/amazon-chroot.html.md +++ b/website/source/docs/builders/amazon-chroot.html.md @@ -128,12 +128,6 @@ each category, the available configuration keys are alphabetized. source AMI will be attached. This defaults to "" (empty string), which forces Packer to find an open device automatically. -- `enhanced_networking` (boolean) - Enable enhanced - 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 AMI if one with the same name already exists. Default `false`. diff --git a/website/source/docs/builders/amazon-ebs.html.md b/website/source/docs/builders/amazon-ebs.html.md index 0bdb3021c..a95aa4624 100644 --- a/website/source/docs/builders/amazon-ebs.html.md +++ b/website/source/docs/builders/amazon-ebs.html.md @@ -165,11 +165,18 @@ builder. Optimized](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EBSOptimized.html). Default `false`. +- `ena_support` (boolean) - Enable enhanced networking (ENA but not SriovNetSupport) + 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). + If you want to set this, but not `sriov_support`, make sure to leave `enhanced_networking: false`. + Default `false`. + - `enhanced_networking` (boolean) - Enable enhanced 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) + 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 AMI if one with the same name already exists. Default `false`. @@ -302,6 +309,13 @@ builder. best spot price. This must be one of: `Linux/UNIX`, `SUSE Linux`, `Windows`, `Linux/UNIX (Amazon VPC)`, `SUSE Linux (Amazon VPC)`, `Windows (Amazon VPC)` +- `sriov_support` (boolean) - Enable enhanced networking (SriovNetSupport but not 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). + If you want to set this, but not `ena_support`, make sure to leave `enhanced_networking: false`. + Default `false`. + - `ssh_keypair_name` (string) - If specified, this is the key that will be used for SSH with the machine. The key must match a key pair name loaded up into Amazon EC2. By default, this is blank, and Packer will diff --git a/website/source/docs/builders/amazon-ebssurrogate.html.md b/website/source/docs/builders/amazon-ebssurrogate.html.md index 071af814a..3bf3e7feb 100644 --- a/website/source/docs/builders/amazon-ebssurrogate.html.md +++ b/website/source/docs/builders/amazon-ebssurrogate.html.md @@ -158,11 +158,18 @@ builder. Optimized](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EBSOptimized.html). Default `false`. +- `ena_support` (boolean) - Enable enhanced networking (ENA but not SriovNetSupport) + 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). + If you want to set this, but not `sriov_support`, make sure to leave `enhanced_networking: false`. + Default `false`. + - `enhanced_networking` (boolean) - Enable enhanced 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) + 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 AMI if one with the same name already exists. Default `false`. @@ -295,6 +302,13 @@ builder. best spot price. This must be one of: `Linux/UNIX`, `SUSE Linux`, `Windows`, `Linux/UNIX (Amazon VPC)`, `SUSE Linux (Amazon VPC)`, `Windows (Amazon VPC)` +- `sriov_support` (boolean) - Enable enhanced networking (SriovNetSupport but not 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). + If you want to set this, but not `ena_support`, make sure to leave `enhanced_networking: false`. + Default `false`. + - `ssh_keypair_name` (string) - If specified, this is the key that will be used for SSH with the machine. The key must match a key pair name loaded up into Amazon EC2. By default, this is blank, and Packer will diff --git a/website/source/docs/builders/amazon-ebsvolume.html.md b/website/source/docs/builders/amazon-ebsvolume.html.md index c27c54148..97a76d921 100644 --- a/website/source/docs/builders/amazon-ebsvolume.html.md +++ b/website/source/docs/builders/amazon-ebsvolume.html.md @@ -104,11 +104,18 @@ builder. Optimized](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EBSOptimized.html). Default `false`. +- `ena_support` (boolean) - Enable enhanced networking (ENA but not SriovNetSupport) + 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). + If you want to set this, but not `sriov_support`, make sure to leave `enhanced_networking: false`. + Default `false`. + - `enhanced_networking` (boolean) - Enable enhanced 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) + 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 profile](https://docs.aws.amazon.com/IAM/latest/UserGuide/instance-profiles.html) @@ -208,6 +215,13 @@ builder. best spot price. This must be one of: `Linux/UNIX`, `SUSE Linux`, `Windows`, `Linux/UNIX (Amazon VPC)`, `SUSE Linux (Amazon VPC)` or `Windows (Amazon VPC)` +- `sriov_support` (boolean) - Enable enhanced networking (SriovNetSupport but not 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). + If you want to set this, but not `ena_support`, make sure to leave `enhanced_networking: false`. + Default `false`. + - `ssh_keypair_name` (string) - If specified, this is the key that will be used for SSH with the machine. By default, this is blank, and Packer will generate a temporary key pair unless From 2d4bc70d7b351dd9068e4605a33df83f984ed13e Mon Sep 17 00:00:00 2001 From: Megan Marsh Date: Mon, 28 Aug 2017 09:18:23 -0700 Subject: [PATCH 2/4] use ami prefix to make it clear that these variables are amazon specific add fixer, fixer tests --- builder/amazon/chroot/builder.go | 8 +-- builder/amazon/chroot/step_register_ami.go | 9 ++- builder/amazon/common/ami_config.go | 11 +--- .../amazon/common/step_modify_ebs_instance.go | 8 +-- builder/amazon/common/step_source_ami_info.go | 10 +-- builder/amazon/ebs/builder.go | 12 ++-- builder/amazon/ebssurrogate/builder.go | 18 +++--- .../amazon/ebssurrogate/step_register_ami.go | 14 ++-- builder/amazon/ebsvolume/builder.go | 18 +++--- builder/amazon/instance/builder.go | 13 ++-- builder/amazon/instance/step_register_ami.go | 12 ++-- fix/fixer.go | 2 + fix/fixer_enhanced_networking.go | 45 +++++++++++++ fix/fixer_enhanced_networking_test.go | 64 +++++++++++++++++++ .../source/docs/builders/amazon-ebs.html.md | 12 +--- .../docs/builders/amazon-ebssurrogate.html.md | 12 +--- .../docs/builders/amazon-ebsvolume.html.md | 12 +--- .../docs/builders/amazon-instance.html.md | 6 +- 18 files changed, 191 insertions(+), 95 deletions(-) create mode 100644 fix/fixer_enhanced_networking.go create mode 100644 fix/fixer_enhanced_networking_test.go diff --git a/builder/amazon/chroot/builder.go b/builder/amazon/chroot/builder.go index 7bface62d..8b8c4ec87 100644 --- a/builder/amazon/chroot/builder.go +++ b/builder/amazon/chroot/builder.go @@ -213,10 +213,10 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe if !b.config.FromScratch { steps = append(steps, &awscommon.StepSourceAMIInfo{ - SourceAmi: b.config.SourceAmi, - EnableSriovNetSupport: b.config.SriovNetSupport, - EnableENASupport: b.config.ENASupport, - AmiFilters: b.config.SourceAmiFilter, + SourceAmi: b.config.SourceAmi, + EnableAMISriovNetSupport: b.config.AMISriovNetSupport, + EnableAMIENASupport: b.config.AMIENASupport, + AmiFilters: b.config.SourceAmiFilter, }, &StepCheckRootDevice{}, ) diff --git a/builder/amazon/chroot/step_register_ami.go b/builder/amazon/chroot/step_register_ami.go index d387eada8..a19266f57 100644 --- a/builder/amazon/chroot/step_register_ami.go +++ b/builder/amazon/chroot/step_register_ami.go @@ -12,7 +12,9 @@ import ( // StepRegisterAMI creates the AMI. type StepRegisterAMI struct { - RootVolumeSize int64 + RootVolumeSize int64 + EnableAMIENASupport bool + EnableAMISriovNetSupport bool } 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) } - if config.AMIEnhancedNetworking { + if s.EnableAMISriovNetSupport { // 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) registerOpts.SriovNetSupport = aws.String("simple") - + } + if s.EnableAMIENASupport { // Set EnaSupport to true // As of February 2017, this applies to C5, I3, P2, R4, X1, and m4.16xlarge registerOpts.EnaSupport = aws.Bool(true) diff --git a/builder/amazon/common/ami_config.go b/builder/amazon/common/ami_config.go index 35db315a9..f59cb1d61 100644 --- a/builder/amazon/common/ami_config.go +++ b/builder/amazon/common/ami_config.go @@ -17,9 +17,8 @@ type AMIConfig struct { AMIRegions []string `mapstructure:"ami_regions"` AMISkipRegionValidation bool `mapstructure:"skip_region_validation"` AMITags map[string]string `mapstructure:"tags"` - AMIEnhancedNetworking bool `mapstructure:"enhanced_networking"` - ENASupport bool `mapstructure:"ena_support"` - SriovNetSupport bool `mapstructure:"sriov_support"` + AMIENASupport bool `mapstructure:"ena_support"` + AMISriovNetSupport bool `mapstructure:"sriov_support"` AMIForceDeregister bool `mapstructure:"force_deregister"` AMIForceDeleteSnapshot bool `mapstructure:"force_delete_snapshot"` 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 { errs = append(errs, fmt.Errorf("ami_name must be between 3 and 128 characters long")) diff --git a/builder/amazon/common/step_modify_ebs_instance.go b/builder/amazon/common/step_modify_ebs_instance.go index 6af48f6f6..12c2367aa 100644 --- a/builder/amazon/common/step_modify_ebs_instance.go +++ b/builder/amazon/common/step_modify_ebs_instance.go @@ -10,8 +10,8 @@ import ( ) type StepModifyEBSBackedInstance struct { - EnableENASupport bool - EnableSriovNetSupport bool + EnableAMIENASupport bool + EnableAMISriovNetSupport bool } 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 // 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)...") simple := "simple" _, err := ec2conn.ModifyInstanceAttribute(&ec2.ModifyInstanceAttributeInput{ @@ -38,7 +38,7 @@ func (s *StepModifyEBSBackedInstance) Run(state multistep.StateBag) multistep.St // Set EnaSupport to true. // 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)...") _, err := ec2conn.ModifyInstanceAttribute(&ec2.ModifyInstanceAttributeInput{ InstanceId: instance.InstanceId, diff --git a/builder/amazon/common/step_source_ami_info.go b/builder/amazon/common/step_source_ami_info.go index dbbf4a218..c7e9f733e 100644 --- a/builder/amazon/common/step_source_ami_info.go +++ b/builder/amazon/common/step_source_ami_info.go @@ -17,10 +17,10 @@ import ( // Produces: // source_image *ec2.Image - the source AMI info type StepSourceAMIInfo struct { - SourceAmi string - EnableSriovNetSupport bool - EnableENASupport bool - AmiFilters AmiFilterOptions + SourceAmi string + EnableAMISriovNetSupport bool + EnableAMIENASupport bool + AmiFilters AmiFilterOptions } // Build a slice of AMI filter options from the filters provided. @@ -104,7 +104,7 @@ func (s *StepSourceAMIInfo) Run(state multistep.StateBag) multistep.StepAction { // Enhanced Networking can only be enabled on HVM AMIs. // 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) state.Put("error", err) ui.Error(err.Error()) diff --git a/builder/amazon/ebs/builder.go b/builder/amazon/ebs/builder.go index 4f35568fc..c31da73a3 100644 --- a/builder/amazon/ebs/builder.go +++ b/builder/amazon/ebs/builder.go @@ -115,10 +115,10 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe ForceDeregister: b.config.AMIForceDeregister, }, &awscommon.StepSourceAMIInfo{ - SourceAmi: b.config.SourceAmi, - EnableSriovNetSupport: b.config.SriovNetSupport, - EnableENASupport: b.config.ENASupport, - AmiFilters: b.config.SourceAmiFilter, + SourceAmi: b.config.SourceAmi, + EnableAMISriovNetSupport: b.config.AMISriovNetSupport, + EnableAMIENASupport: b.config.AMIENASupport, + AmiFilters: b.config.SourceAmiFilter, }, &awscommon.StepKeyPair{ Debug: b.config.PackerDebug, @@ -180,8 +180,8 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe DisableStopInstance: b.config.DisableStopInstance, }, &awscommon.StepModifyEBSBackedInstance{ - EnableSriovNetSupport: b.config.SriovNetSupport, - EnableENASupport: b.config.ENASupport, + EnableAMISriovNetSupport: b.config.AMISriovNetSupport, + EnableAMIENASupport: b.config.AMIENASupport, }, &awscommon.StepDeregisterAMI{ AccessConfig: &b.config.AccessConfig, diff --git a/builder/amazon/ebssurrogate/builder.go b/builder/amazon/ebssurrogate/builder.go index e2f7b3fd0..20984fee5 100644 --- a/builder/amazon/ebssurrogate/builder.go +++ b/builder/amazon/ebssurrogate/builder.go @@ -129,10 +129,10 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe ForceDeregister: b.config.AMIForceDeregister, }, &awscommon.StepSourceAMIInfo{ - SourceAmi: b.config.SourceAmi, - EnableSriovNetSupport: b.config.SriovNetSupport, - EnableENASupport: b.config.ENASupport, - AmiFilters: b.config.SourceAmiFilter, + SourceAmi: b.config.SourceAmi, + EnableAMISriovNetSupport: b.config.AMISriovNetSupport, + EnableAMIENASupport: b.config.AMIENASupport, + AmiFilters: b.config.SourceAmiFilter, }, &awscommon.StepKeyPair{ Debug: b.config.PackerDebug, @@ -190,8 +190,8 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe DisableStopInstance: b.config.DisableStopInstance, }, &awscommon.StepModifyEBSBackedInstance{ - EnableSriovNetSupport: b.config.SriovNetSupport, - EnableENASupport: b.config.ENASupport, + EnableAMISriovNetSupport: b.config.AMISriovNetSupport, + EnableAMIENASupport: b.config.AMIENASupport, }, &StepSnapshotNewRootVolume{ NewRootMountPoint: b.config.RootDevice.SourceDeviceName, @@ -204,8 +204,10 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe Regions: b.config.AMIRegions, }, &StepRegisterAMI{ - RootDevice: b.config.RootDevice, - BlockDevices: b.config.BlockDevices.BuildAMIDevices(), + RootDevice: b.config.RootDevice, + BlockDevices: b.config.BlockDevices.BuildAMIDevices(), + EnableAMISriovNetSupport: b.config.AMISriovNetSupport, + EnableAMIENASupport: b.config.AMIENASupport, }, &awscommon.StepCreateEncryptedAMICopy{ KeyID: b.config.AMIKmsKeyId, diff --git a/builder/amazon/ebssurrogate/step_register_ami.go b/builder/amazon/ebssurrogate/step_register_ami.go index d2f0f2250..f0d145f35 100644 --- a/builder/amazon/ebssurrogate/step_register_ami.go +++ b/builder/amazon/ebssurrogate/step_register_ami.go @@ -12,9 +12,11 @@ import ( // StepRegisterAMI creates the AMI. type StepRegisterAMI struct { - RootDevice RootBlockDevice - BlockDevices []*ec2.BlockDeviceMapping - image *ec2.Image + RootDevice RootBlockDevice + BlockDevices []*ec2.BlockDeviceMapping + EnableAMIENASupport bool + EnableAMISriovNetSupport bool + image *ec2.Image } func (s *StepRegisterAMI) Run(state multistep.StateBag) multistep.StepAction { @@ -35,16 +37,16 @@ func (s *StepRegisterAMI) Run(state multistep.StateBag) multistep.StepAction { BlockDeviceMappings: blockDevicesExcludingRoot, } - if config.AMIEnhancedNetworking { + if s.EnableAMISriovNetSupport { // 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) registerOpts.SriovNetSupport = aws.String("simple") - + } + if s.EnableAMIENASupport { // Set EnaSupport to true // As of February 2017, this applies to C5, I3, P2, R4, X1, and m4.16xlarge registerOpts.EnaSupport = aws.Bool(true) } - registerResp, err := ec2conn.RegisterImage(registerOpts) if err != nil { state.Put("error", fmt.Errorf("Error registering AMI: %s", err)) diff --git a/builder/amazon/ebsvolume/builder.go b/builder/amazon/ebsvolume/builder.go index d04366975..1aad1819a 100644 --- a/builder/amazon/ebsvolume/builder.go +++ b/builder/amazon/ebsvolume/builder.go @@ -23,9 +23,9 @@ type Config struct { awscommon.AccessConfig `mapstructure:",squash"` awscommon.RunConfig `mapstructure:",squash"` - VolumeMappings []BlockDevice `mapstructure:"ebs_volumes"` - ENASupport bool `mapstructure:"ena_support"` - SriovNetSupport bool `mapstructure:"sriov_support"` + VolumeMappings []BlockDevice `mapstructure:"ebs_volumes"` + AMIENASupport bool `mapstructure:"ena_support"` + AMISriovNetSupport bool `mapstructure:"sriov_support"` launchBlockDevices awscommon.BlockDevices ctx interpolate.Context @@ -104,10 +104,10 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe // Build the steps steps := []multistep.Step{ &awscommon.StepSourceAMIInfo{ - SourceAmi: b.config.SourceAmi, - EnableSriovNetSupport: b.config.SriovNetSupport, - EnableENASupport: b.config.ENASupport, - AmiFilters: b.config.SourceAmiFilter, + SourceAmi: b.config.SourceAmi, + EnableAMISriovNetSupport: b.config.AMISriovNetSupport, + EnableAMIENASupport: b.config.AMIENASupport, + AmiFilters: b.config.SourceAmiFilter, }, &awscommon.StepKeyPair{ Debug: b.config.PackerDebug, @@ -166,8 +166,8 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe DisableStopInstance: b.config.DisableStopInstance, }, &awscommon.StepModifyEBSBackedInstance{ - EnableSriovNetSupport: b.config.SriovNetSupport, - EnableENASupport: b.config.ENASupport, + EnableAMISriovNetSupport: b.config.AMISriovNetSupport, + EnableAMIENASupport: b.config.AMIENASupport, }, } diff --git a/builder/amazon/instance/builder.go b/builder/amazon/instance/builder.go index d90e8e1a0..6329008fe 100644 --- a/builder/amazon/instance/builder.go +++ b/builder/amazon/instance/builder.go @@ -200,10 +200,10 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe ForceDeregister: b.config.AMIForceDeregister, }, &awscommon.StepSourceAMIInfo{ - SourceAmi: b.config.SourceAmi, - EnableSriovNetSupport: b.config.SriovNetSupport, - EnableENASupport: b.config.ENASupport, - AmiFilters: b.config.SourceAmiFilter, + SourceAmi: b.config.SourceAmi, + EnableAMISriovNetSupport: b.config.AMISriovNetSupport, + EnableAMIENASupport: b.config.AMIENASupport, + AmiFilters: b.config.SourceAmiFilter, }, &awscommon.StepKeyPair{ Debug: b.config.PackerDebug, @@ -265,7 +265,10 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe AMIName: b.config.AMIName, Regions: b.config.AMIRegions, }, - &StepRegisterAMI{}, + &StepRegisterAMI{ + EnableAMISriovNetSupport: b.config.AMISriovNetSupport, + EnableAMIENASupport: b.config.AMIENASupport, + }, &awscommon.StepAMIRegionCopy{ AccessConfig: &b.config.AccessConfig, Regions: b.config.AMIRegions, diff --git a/builder/amazon/instance/step_register_ami.go b/builder/amazon/instance/step_register_ami.go index 01ba46bd9..d363bdfdd 100644 --- a/builder/amazon/instance/step_register_ami.go +++ b/builder/amazon/instance/step_register_ami.go @@ -10,7 +10,10 @@ import ( "github.com/mitchellh/multistep" ) -type StepRegisterAMI struct{} +type StepRegisterAMI struct { + EnableAMIENASupport bool + EnableAMISriovNetSupport bool +} func (s *StepRegisterAMI) Run(state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) @@ -29,12 +32,13 @@ func (s *StepRegisterAMI) Run(state multistep.StateBag) multistep.StepAction { registerOpts.VirtualizationType = aws.String(config.AMIVirtType) } - if config.AMIEnhancedNetworking { + if s.EnableAMISriovNetSupport { // 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) 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 registerOpts.EnaSupport = aws.Bool(true) } diff --git a/fix/fixer.go b/fix/fixer.go index 3c285c4be..7c9d8e2dd 100644 --- a/fix/fixer.go +++ b/fix/fixer.go @@ -31,6 +31,7 @@ func init() { "sshkeypath": new(FixerSSHKeyPath), "manifest-filename": new(FixerManifestFilename), "amazon-shutdown_behavior": new(FixerAmazonShutdownBehavior), + "enhanced-networking": new(FixerEnhancedNetworking), } FixerOrder = []string{ @@ -45,5 +46,6 @@ func init() { "sshkeypath", "manifest-filename", "amazon-shutdown_behavior", + "enhanced-networking", } } diff --git a/fix/fixer_enhanced_networking.go b/fix/fixer_enhanced_networking.go new file mode 100644 index 000000000..be19cb47d --- /dev/null +++ b/fix/fixer_enhanced_networking.go @@ -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"` +} diff --git a/fix/fixer_enhanced_networking_test.go b/fix/fixer_enhanced_networking_test.go new file mode 100644 index 000000000..589aaa680 --- /dev/null +++ b/fix/fixer_enhanced_networking_test.go @@ -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) + } + } +} diff --git a/website/source/docs/builders/amazon-ebs.html.md b/website/source/docs/builders/amazon-ebs.html.md index a95aa4624..51c0ed891 100644 --- a/website/source/docs/builders/amazon-ebs.html.md +++ b/website/source/docs/builders/amazon-ebs.html.md @@ -168,15 +168,9 @@ builder. - `ena_support` (boolean) - Enable enhanced networking (ENA but not SriovNetSupport) 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). - If you want to set this, but not `sriov_support`, make sure to leave `enhanced_networking: false`. - Default `false`. + documentation on enabling enhanced networking](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/enhanced-networking.html#enabling_enhanced_networking). Default `false`. -- `enhanced_networking` (boolean) - Enable enhanced - 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`. +- `enhanced_networking` (boolean) - deprecated. Default `false`. For now, setting to `true` will set `ena_support` to `true` in order to preserve backwards compatability. - `force_deregister` (boolean) - Force Packer to first deregister an existing AMI if one with the same name already exists. Default `false`. @@ -310,7 +304,7 @@ builder. `Linux/UNIX (Amazon VPC)`, `SUSE Linux (Amazon VPC)`, `Windows (Amazon VPC)` - `sriov_support` (boolean) - Enable enhanced networking (SriovNetSupport but not ENA) - on HVM-compatible AMIs. If true, add `ec2:ModifyInstanceAttribute` to your AWS IAM + 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). If you want to set this, but not `ena_support`, make sure to leave `enhanced_networking: false`. diff --git a/website/source/docs/builders/amazon-ebssurrogate.html.md b/website/source/docs/builders/amazon-ebssurrogate.html.md index 3bf3e7feb..7224420f3 100644 --- a/website/source/docs/builders/amazon-ebssurrogate.html.md +++ b/website/source/docs/builders/amazon-ebssurrogate.html.md @@ -161,15 +161,9 @@ builder. - `ena_support` (boolean) - Enable enhanced networking (ENA but not SriovNetSupport) 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). - If you want to set this, but not `sriov_support`, make sure to leave `enhanced_networking: false`. - Default `false`. + documentation on enabling enhanced networking](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/enhanced-networking.html#enabling_enhanced_networking). Default `false`. -- `enhanced_networking` (boolean) - Enable enhanced - 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`. +- `enhanced_networking` (boolean) - deprecated. Default `false`. For now, setting to `true` will set `ena_support` to `true` in order to preserve backwards compatability. - `force_deregister` (boolean) - Force Packer to first deregister an existing AMI if one with the same name already exists. Default `false`. @@ -303,7 +297,7 @@ builder. `Linux/UNIX (Amazon VPC)`, `SUSE Linux (Amazon VPC)`, `Windows (Amazon VPC)` - `sriov_support` (boolean) - Enable enhanced networking (SriovNetSupport but not ENA) - on HVM-compatible AMIs. If true, add `ec2:ModifyInstanceAttribute` to your AWS IAM + 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). If you want to set this, but not `ena_support`, make sure to leave `enhanced_networking: false`. diff --git a/website/source/docs/builders/amazon-ebsvolume.html.md b/website/source/docs/builders/amazon-ebsvolume.html.md index 97a76d921..9dbc4f505 100644 --- a/website/source/docs/builders/amazon-ebsvolume.html.md +++ b/website/source/docs/builders/amazon-ebsvolume.html.md @@ -107,15 +107,9 @@ builder. - `ena_support` (boolean) - Enable enhanced networking (ENA but not SriovNetSupport) 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). - If you want to set this, but not `sriov_support`, make sure to leave `enhanced_networking: false`. - Default `false`. + documentation on enabling enhanced networking](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/enhanced-networking.html#enabling_enhanced_networking). Default `false`. -- `enhanced_networking` (boolean) - Enable enhanced - 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`. +- `enhanced_networking` (boolean) - deprecated. Default `false`. For now, setting to `true` will set `ena_support` to `true` in order to preserve backwards compatability. - `iam_instance_profile` (string) - The name of an [IAM instance profile](https://docs.aws.amazon.com/IAM/latest/UserGuide/instance-profiles.html) @@ -216,7 +210,7 @@ builder. `Linux/UNIX (Amazon VPC)`, `SUSE Linux (Amazon VPC)` or `Windows (Amazon VPC)` - `sriov_support` (boolean) - Enable enhanced networking (SriovNetSupport but not ENA) - on HVM-compatible AMIs. If true, add `ec2:ModifyInstanceAttribute` to your AWS IAM + 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). If you want to set this, but not `ena_support`, make sure to leave `enhanced_networking: false`. diff --git a/website/source/docs/builders/amazon-instance.html.md b/website/source/docs/builders/amazon-instance.html.md index c63e537a5..be919e735 100644 --- a/website/source/docs/builders/amazon-instance.html.md +++ b/website/source/docs/builders/amazon-instance.html.md @@ -189,11 +189,7 @@ builder. Optimized](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EBSOptimized.html). Default `false`. -- `enhanced_networking` (boolean) - Enable enhanced - 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) +- `enhanced_networking` (boolean) - deprecated. Default `false`. For now, setting to `true` will set `ena_support` to `true` in order to preserve backwards compatability. - `force_deregister` (boolean) - Force Packer to first deregister an existing AMI if one with the same name already exists. Defaults to `false`. From 85ad1f58fbbc690e65a3f53e2cd04fbc16cff652 Mon Sep 17 00:00:00 2001 From: Megan Marsh Date: Tue, 29 Aug 2017 09:36:06 -0700 Subject: [PATCH 3/4] include ena_support and sriov_support in chroot and instance docs --- builder/amazon/chroot/builder.go | 4 +++- website/source/docs/builders/amazon-chroot.html.md | 14 ++++++++++++++ .../source/docs/builders/amazon-instance.html.md | 12 ++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/builder/amazon/chroot/builder.go b/builder/amazon/chroot/builder.go index 8b8c4ec87..a259960d1 100644 --- a/builder/amazon/chroot/builder.go +++ b/builder/amazon/chroot/builder.go @@ -253,7 +253,9 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe Regions: b.config.AMIRegions, }, &StepRegisterAMI{ - RootVolumeSize: b.config.RootVolumeSize, + RootVolumeSize: b.config.RootVolumeSize, + EnableAMISriovNetSupport: b.config.AMISriovNetSupport, + EnableAMIENASupport: b.config.AMIENASupport, }, &awscommon.StepCreateEncryptedAMICopy{ KeyID: b.config.AMIKmsKeyId, diff --git a/website/source/docs/builders/amazon-chroot.html.md b/website/source/docs/builders/amazon-chroot.html.md index 2d06d9e7a..3085a494f 100644 --- a/website/source/docs/builders/amazon-chroot.html.md +++ b/website/source/docs/builders/amazon-chroot.html.md @@ -128,6 +128,13 @@ each category, the available configuration keys are alphabetized. source AMI will be attached. This defaults to "" (empty string), which forces Packer to find an open device automatically. +- `ena_support` (boolean) - Enable enhanced networking (ENA but not SriovNetSupport) + 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). Default `false`. + +- `enhanced_networking` (boolean) - deprecated. Default `false`. For now, setting to `true` will set `ena_support` to `true` in order to preserve backwards compatability. + - `force_deregister` (boolean) - Force Packer to first deregister an existing AMI if one with the same name already exists. Default `false`. @@ -287,6 +294,13 @@ each category, the available configuration keys are alphabetized. - `most_recent` (bool) - Selects the newest created image when true. This is most useful for selecting a daily distro build. +- `sriov_support` (boolean) - Enable enhanced networking (SriovNetSupport but not 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). + If you want to set this, but not `ena_support`, make sure to leave `enhanced_networking: false`. + Default `false`. + - `tags` (object of key/value strings) - Tags applied to the AMI. This is a [template engine](/docs/templates/engine.html) where the `SourceAMI` variable is replaced with the source AMI ID and diff --git a/website/source/docs/builders/amazon-instance.html.md b/website/source/docs/builders/amazon-instance.html.md index be919e735..1a766c4b7 100644 --- a/website/source/docs/builders/amazon-instance.html.md +++ b/website/source/docs/builders/amazon-instance.html.md @@ -189,6 +189,11 @@ builder. Optimized](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EBSOptimized.html). Default `false`. +- `ena_support` (boolean) - Enable enhanced networking (ENA but not SriovNetSupport) + 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). Default `false`. + - `enhanced_networking` (boolean) - deprecated. Default `false`. For now, setting to `true` will set `ena_support` to `true` in order to preserve backwards compatability. - `force_deregister` (boolean) - Force Packer to first deregister an existing @@ -299,6 +304,13 @@ builder. best spot price. This must be one of: `Linux/UNIX`, `SUSE Linux`, `Windows`, `Linux/UNIX (Amazon VPC)`, `SUSE Linux (Amazon VPC)`, `Windows (Amazon VPC)` +- `sriov_support` (boolean) - Enable enhanced networking (SriovNetSupport but not 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). + If you want to set this, but not `ena_support`, make sure to leave `enhanced_networking: false`. + Default `false`. + - `ssh_keypair_name` (string) - If specified, this is the key that will be used for SSH with the machine. The key must match a key pair name loaded up into Amazon EC2. By default, this is blank, and Packer will From 2c2321fb99d68a7e1961a8b99708dd0556b917ba Mon Sep 17 00:00:00 2001 From: Megan Marsh Date: Tue, 29 Aug 2017 10:53:52 -0700 Subject: [PATCH 4/4] remove enhanced_networking deprecation note from docs. changelog will suffice --- website/source/docs/builders/amazon-chroot.html.md | 3 --- website/source/docs/builders/amazon-ebs.html.md | 3 --- website/source/docs/builders/amazon-ebssurrogate.html.md | 3 --- website/source/docs/builders/amazon-ebsvolume.html.md | 3 --- website/source/docs/builders/amazon-instance.html.md | 3 --- 5 files changed, 15 deletions(-) diff --git a/website/source/docs/builders/amazon-chroot.html.md b/website/source/docs/builders/amazon-chroot.html.md index 3085a494f..ac46e2846 100644 --- a/website/source/docs/builders/amazon-chroot.html.md +++ b/website/source/docs/builders/amazon-chroot.html.md @@ -133,8 +133,6 @@ each category, the available configuration keys are alphabetized. 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). Default `false`. -- `enhanced_networking` (boolean) - deprecated. Default `false`. For now, setting to `true` will set `ena_support` to `true` in order to preserve backwards compatability. - - `force_deregister` (boolean) - Force Packer to first deregister an existing AMI if one with the same name already exists. Default `false`. @@ -298,7 +296,6 @@ each category, the available configuration keys are alphabetized. 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). - If you want to set this, but not `ena_support`, make sure to leave `enhanced_networking: false`. Default `false`. - `tags` (object of key/value strings) - Tags applied to the AMI. This is a diff --git a/website/source/docs/builders/amazon-ebs.html.md b/website/source/docs/builders/amazon-ebs.html.md index 51c0ed891..e5f1e852b 100644 --- a/website/source/docs/builders/amazon-ebs.html.md +++ b/website/source/docs/builders/amazon-ebs.html.md @@ -170,8 +170,6 @@ builder. 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). Default `false`. -- `enhanced_networking` (boolean) - deprecated. Default `false`. For now, setting to `true` will set `ena_support` to `true` in order to preserve backwards compatability. - - `force_deregister` (boolean) - Force Packer to first deregister an existing AMI if one with the same name already exists. Default `false`. @@ -307,7 +305,6 @@ builder. 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). - If you want to set this, but not `ena_support`, make sure to leave `enhanced_networking: false`. Default `false`. - `ssh_keypair_name` (string) - If specified, this is the key that will be diff --git a/website/source/docs/builders/amazon-ebssurrogate.html.md b/website/source/docs/builders/amazon-ebssurrogate.html.md index 7224420f3..5788fa65e 100644 --- a/website/source/docs/builders/amazon-ebssurrogate.html.md +++ b/website/source/docs/builders/amazon-ebssurrogate.html.md @@ -163,8 +163,6 @@ builder. 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). Default `false`. -- `enhanced_networking` (boolean) - deprecated. Default `false`. For now, setting to `true` will set `ena_support` to `true` in order to preserve backwards compatability. - - `force_deregister` (boolean) - Force Packer to first deregister an existing AMI if one with the same name already exists. Default `false`. @@ -300,7 +298,6 @@ builder. 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). - If you want to set this, but not `ena_support`, make sure to leave `enhanced_networking: false`. Default `false`. - `ssh_keypair_name` (string) - If specified, this is the key that will be diff --git a/website/source/docs/builders/amazon-ebsvolume.html.md b/website/source/docs/builders/amazon-ebsvolume.html.md index 9dbc4f505..959047fd8 100644 --- a/website/source/docs/builders/amazon-ebsvolume.html.md +++ b/website/source/docs/builders/amazon-ebsvolume.html.md @@ -109,8 +109,6 @@ builder. 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). Default `false`. -- `enhanced_networking` (boolean) - deprecated. Default `false`. For now, setting to `true` will set `ena_support` to `true` in order to preserve backwards compatability. - - `iam_instance_profile` (string) - The name of an [IAM instance profile](https://docs.aws.amazon.com/IAM/latest/UserGuide/instance-profiles.html) to launch the EC2 instance with. @@ -213,7 +211,6 @@ builder. 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). - If you want to set this, but not `ena_support`, make sure to leave `enhanced_networking: false`. Default `false`. - `ssh_keypair_name` (string) - If specified, this is the key that will be diff --git a/website/source/docs/builders/amazon-instance.html.md b/website/source/docs/builders/amazon-instance.html.md index 1a766c4b7..5f375e898 100644 --- a/website/source/docs/builders/amazon-instance.html.md +++ b/website/source/docs/builders/amazon-instance.html.md @@ -194,8 +194,6 @@ builder. 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). Default `false`. -- `enhanced_networking` (boolean) - deprecated. Default `false`. For now, setting to `true` will set `ena_support` to `true` in order to preserve backwards compatability. - - `force_deregister` (boolean) - Force Packer to first deregister an existing AMI if one with the same name already exists. Defaults to `false`. @@ -308,7 +306,6 @@ builder. 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). - If you want to set this, but not `ena_support`, make sure to leave `enhanced_networking: false`. Default `false`. - `ssh_keypair_name` (string) - If specified, this is the key that will be