diff options
Diffstat (limited to 'vendor/github.com/mitchellh/packer/builder/amazon')
18 files changed, 229 insertions, 141 deletions
diff --git a/vendor/github.com/mitchellh/packer/builder/amazon/chroot/builder.go b/vendor/github.com/mitchellh/packer/builder/amazon/chroot/builder.go index 65660cf4..a259960d 100644 --- a/vendor/github.com/mitchellh/packer/builder/amazon/chroot/builder.go +++ b/vendor/github.com/mitchellh/packer/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, + EnableAMISriovNetSupport: b.config.AMISriovNetSupport, + EnableAMIENASupport: b.config.AMIENASupport, + AmiFilters: b.config.SourceAmiFilter, }, &StepCheckRootDevice{}, ) @@ -245,17 +246,22 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe &StepEarlyCleanup{}, &StepSnapshot{}, &awscommon.StepDeregisterAMI{ + AccessConfig: &b.config.AccessConfig, ForceDeregister: b.config.AMIForceDeregister, ForceDeleteSnapshot: b.config.AMIForceDeleteSnapshot, AMIName: b.config.AMIName, + 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, EncryptBootVolume: b.config.AMIEncryptBootVolume, Name: b.config.AMIName, + AMIMappings: b.config.AMIBlockDevices.AMIMappings, }, &awscommon.StepAMIRegionCopy{ AccessConfig: &b.config.AccessConfig, diff --git a/vendor/github.com/mitchellh/packer/builder/amazon/chroot/lockfile_unix.go b/vendor/github.com/mitchellh/packer/builder/amazon/chroot/lockfile_unix.go index 43e92af2..0d0f8c8f 100644 --- a/vendor/github.com/mitchellh/packer/builder/amazon/chroot/lockfile_unix.go +++ b/vendor/github.com/mitchellh/packer/builder/amazon/chroot/lockfile_unix.go @@ -4,7 +4,8 @@ package chroot import ( "os" - "syscall" + + "golang.org/x/sys/unix" ) // See: http://linux.die.net/include/sys/file.h @@ -13,7 +14,7 @@ const LOCK_NB = 4 const LOCK_UN = 8 func lockFile(f *os.File) error { - err := syscall.Flock(int(f.Fd()), LOCK_EX) + err := unix.Flock(int(f.Fd()), LOCK_EX) if err != nil { return err } @@ -22,5 +23,5 @@ func lockFile(f *os.File) error { } func unlockFile(f *os.File) error { - return syscall.Flock(int(f.Fd()), LOCK_UN) + return unix.Flock(int(f.Fd()), LOCK_UN) } diff --git a/vendor/github.com/mitchellh/packer/builder/amazon/chroot/step_register_ami.go b/vendor/github.com/mitchellh/packer/builder/amazon/chroot/step_register_ami.go index d387eada..a19266f5 100644 --- a/vendor/github.com/mitchellh/packer/builder/amazon/chroot/step_register_ami.go +++ b/vendor/github.com/mitchellh/packer/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/vendor/github.com/mitchellh/packer/builder/amazon/common/ami_config.go b/vendor/github.com/mitchellh/packer/builder/amazon/common/ami_config.go index 72fd0704..f59cb1d6 100644 --- a/vendor/github.com/mitchellh/packer/builder/amazon/common/ami_config.go +++ b/vendor/github.com/mitchellh/packer/builder/amazon/common/ami_config.go @@ -17,7 +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"` + 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"` diff --git a/vendor/github.com/mitchellh/packer/builder/amazon/common/artifact.go b/vendor/github.com/mitchellh/packer/builder/amazon/common/artifact.go index c9f9a08b..dc50f772 100644 --- a/vendor/github.com/mitchellh/packer/builder/amazon/common/artifact.go +++ b/vendor/github.com/mitchellh/packer/builder/amazon/common/artifact.go @@ -51,7 +51,7 @@ func (a *Artifact) String() string { } sort.Strings(amiStrings) - return fmt.Sprintf("AMIs were created:\n\n%s", strings.Join(amiStrings, "\n")) + return fmt.Sprintf("AMIs were created:\n%s\n", strings.Join(amiStrings, "\n")) } func (a *Artifact) State(name string) interface{} { diff --git a/vendor/github.com/mitchellh/packer/builder/amazon/common/artifact_test.go b/vendor/github.com/mitchellh/packer/builder/amazon/common/artifact_test.go index ccbf0a1e..d70754eb 100644 --- a/vendor/github.com/mitchellh/packer/builder/amazon/common/artifact_test.go +++ b/vendor/github.com/mitchellh/packer/builder/amazon/common/artifact_test.go @@ -48,9 +48,9 @@ func TestArtifactState_atlasMetadata(t *testing.T) { func TestArtifactString(t *testing.T) { expected := `AMIs were created: - east: foo -west: bar` +west: bar +` amis := make(map[string]string) amis["east"] = "foo" diff --git a/vendor/github.com/mitchellh/packer/builder/amazon/common/step_deregister_ami.go b/vendor/github.com/mitchellh/packer/builder/amazon/common/step_deregister_ami.go index 7dc39e28..3ad8711a 100644 --- a/vendor/github.com/mitchellh/packer/builder/amazon/common/step_deregister_ami.go +++ b/vendor/github.com/mitchellh/packer/builder/amazon/common/step_deregister_ami.go @@ -10,59 +10,76 @@ import ( ) type StepDeregisterAMI struct { + AccessConfig *AccessConfig ForceDeregister bool ForceDeleteSnapshot bool AMIName string + Regions []string } func (s *StepDeregisterAMI) Run(state multistep.StateBag) multistep.StepAction { - ec2conn := state.Get("ec2").(*ec2.EC2) ui := state.Get("ui").(packer.Ui) + regions := s.Regions + if len(regions) == 0 { + regions = append(regions, s.AccessConfig.RawRegion) + } // Check for force deregister if s.ForceDeregister { - resp, err := ec2conn.DescribeImages(&ec2.DescribeImagesInput{ - Filters: []*ec2.Filter{{ - Name: aws.String("name"), - Values: []*string{aws.String(s.AMIName)}, - }}}) + for _, region := range regions { + // get new connection for each region in which we need to deregister vms + session, err := s.AccessConfig.Session() + if err != nil { + return multistep.ActionHalt + } - if err != nil { - err := fmt.Errorf("Error describing AMI: %s", err) - state.Put("error", err) - ui.Error(err.Error()) - return multistep.ActionHalt - } + regionconn := ec2.New(session.Copy(&aws.Config{ + Region: aws.String(region)}, + )) - // Deregister image(s) by name - for _, i := range resp.Images { - _, err := ec2conn.DeregisterImage(&ec2.DeregisterImageInput{ - ImageId: i.ImageId, - }) + resp, err := regionconn.DescribeImages(&ec2.DescribeImagesInput{ + Filters: []*ec2.Filter{{ + Name: aws.String("name"), + Values: []*string{aws.String(s.AMIName)}, + }}}) if err != nil { - err := fmt.Errorf("Error deregistering existing AMI: %s", err) + err := fmt.Errorf("Error describing AMI: %s", err) state.Put("error", err) ui.Error(err.Error()) return multistep.ActionHalt } - ui.Say(fmt.Sprintf("Deregistered AMI %s, id: %s", s.AMIName, *i.ImageId)) - // Delete snapshot(s) by image - if s.ForceDeleteSnapshot { - for _, b := range i.BlockDeviceMappings { - if b.Ebs != nil && aws.StringValue(b.Ebs.SnapshotId) != "" { - _, err := ec2conn.DeleteSnapshot(&ec2.DeleteSnapshotInput{ - SnapshotId: b.Ebs.SnapshotId, - }) + // Deregister image(s) by name + for _, i := range resp.Images { + _, err := regionconn.DeregisterImage(&ec2.DeregisterImageInput{ + ImageId: i.ImageId, + }) + + if err != nil { + err := fmt.Errorf("Error deregistering existing AMI: %s", err) + state.Put("error", err) + ui.Error(err.Error()) + return multistep.ActionHalt + } + ui.Say(fmt.Sprintf("Deregistered AMI %s, id: %s", s.AMIName, *i.ImageId)) + + // Delete snapshot(s) by image + if s.ForceDeleteSnapshot { + for _, b := range i.BlockDeviceMappings { + if b.Ebs != nil && aws.StringValue(b.Ebs.SnapshotId) != "" { + _, err := regionconn.DeleteSnapshot(&ec2.DeleteSnapshotInput{ + SnapshotId: b.Ebs.SnapshotId, + }) - if err != nil { - err := fmt.Errorf("Error deleting existing snapshot: %s", err) - state.Put("error", err) - ui.Error(err.Error()) - return multistep.ActionHalt + if err != nil { + err := fmt.Errorf("Error deleting existing snapshot: %s", err) + state.Put("error", err) + ui.Error(err.Error()) + return multistep.ActionHalt + } + ui.Say(fmt.Sprintf("Deleted snapshot: %s", *b.Ebs.SnapshotId)) } - ui.Say(fmt.Sprintf("Deleted snapshot: %s", *b.Ebs.SnapshotId)) } } } diff --git a/vendor/github.com/mitchellh/packer/builder/amazon/common/step_encrypted_ami.go b/vendor/github.com/mitchellh/packer/builder/amazon/common/step_encrypted_ami.go index fec882b6..16c4ce7a 100644 --- a/vendor/github.com/mitchellh/packer/builder/amazon/common/step_encrypted_ami.go +++ b/vendor/github.com/mitchellh/packer/builder/amazon/common/step_encrypted_ami.go @@ -15,6 +15,7 @@ type StepCreateEncryptedAMICopy struct { KeyID string EncryptBootVolume bool Name string + AMIMappings []BlockDevice } func (s *StepCreateEncryptedAMICopy) Run(state multistep.StateBag) multistep.StepAction { @@ -116,9 +117,18 @@ func (s *StepCreateEncryptedAMICopy) Run(state multistep.StateBag) multistep.Ste ui.Say("Deleting unencrypted snapshots") snapshots := state.Get("snapshots").(map[string][]string) +OuterLoop: for _, blockDevice := range unencImage.BlockDeviceMappings { if blockDevice.Ebs != nil && blockDevice.Ebs.SnapshotId != nil { - ui.Message(fmt.Sprintf("Snapshot ID: %s", *blockDevice.Ebs.SnapshotId)) + // If this packer run didn't create it, then don't delete it + for _, origDevice := range s.AMIMappings { + if origDevice.SnapshotId == *blockDevice.Ebs.SnapshotId { + ui.Message(fmt.Sprintf("Keeping Snapshot ID: %s", *blockDevice.Ebs.SnapshotId)) + continue OuterLoop + } + } + + ui.Message(fmt.Sprintf("Deleting Snapshot ID: %s", *blockDevice.Ebs.SnapshotId)) deleteSnapOpts := &ec2.DeleteSnapshotInput{ SnapshotId: aws.String(*blockDevice.Ebs.SnapshotId), } diff --git a/vendor/github.com/mitchellh/packer/builder/amazon/common/step_modify_ebs_instance.go b/vendor/github.com/mitchellh/packer/builder/amazon/common/step_modify_ebs_instance.go index 11fa629d..12c2367a 100644 --- a/vendor/github.com/mitchellh/packer/builder/amazon/common/step_modify_ebs_instance.go +++ b/vendor/github.com/mitchellh/packer/builder/amazon/common/step_modify_ebs_instance.go @@ -10,7 +10,8 @@ import ( ) type StepModifyEBSBackedInstance struct { - EnableEnhancedNetworking bool + EnableAMIENASupport bool + EnableAMISriovNetSupport 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.EnableAMISriovNetSupport { 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.EnableAMIENASupport { 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/vendor/github.com/mitchellh/packer/builder/amazon/common/step_run_source_instance.go b/vendor/github.com/mitchellh/packer/builder/amazon/common/step_run_source_instance.go index 1aecd75f..5a864a5e 100644 --- a/vendor/github.com/mitchellh/packer/builder/amazon/common/step_run_source_instance.go +++ b/vendor/github.com/mitchellh/packer/builder/amazon/common/step_run_source_instance.go @@ -136,7 +136,23 @@ func (s *StepRunSourceInstance) Run(state multistep.StateBag) multistep.StepActi var instanceId string + ui.Say("Adding tags to source instance") + if _, exists := s.Tags["Name"]; !exists { + s.Tags["Name"] = "Packer Builder" + } + + createTagsAfterInstanceStarts := true + ec2Tags, err := ConvertToEC2Tags(s.Tags, *ec2conn.Config.Region, s.SourceAMI, s.Ctx) + if err != nil { + err := fmt.Errorf("Error tagging source instance: %s", err) + state.Put("error", err) + ui.Error(err.Error()) + return multistep.ActionHalt + } + ReportTags(ui, ec2Tags) + if spotPrice == "" || spotPrice == "0" { + runOpts := &ec2.RunInstancesInput{ ImageId: &s.SourceAMI, InstanceType: &s.InstanceType, @@ -149,6 +165,16 @@ func (s *StepRunSourceInstance) Run(state multistep.StateBag) multistep.StepActi EbsOptimized: &s.EbsOptimized, } + if len(ec2Tags) > 0 { + runTags := &ec2.TagSpecification{ + ResourceType: aws.String("instance"), + Tags: ec2Tags, + } + + runOpts.SetTagSpecifications([]*ec2.TagSpecification{runTags}) + createTagsAfterInstanceStarts = false + } + if keyName != "" { runOpts.KeyName = &keyName } @@ -255,6 +281,7 @@ func (s *StepRunSourceInstance) Run(state multistep.StateBag) multistep.StepActi return multistep.ActionHalt } instanceId = *spotResp.SpotInstanceRequests[0].InstanceId + } // Set the instance ID so that the cleanup works properly @@ -278,43 +305,30 @@ func (s *StepRunSourceInstance) Run(state multistep.StateBag) multistep.StepActi instance := latestInstance.(*ec2.Instance) - ui.Say("Adding tags to source instance") - if _, exists := s.Tags["Name"]; !exists { - s.Tags["Name"] = "Packer Builder" - } - - ec2Tags, err := ConvertToEC2Tags(s.Tags, *ec2conn.Config.Region, s.SourceAMI, s.Ctx) - if err != nil { - err := fmt.Errorf("Error tagging source instance: %s", err) - state.Put("error", err) - ui.Error(err.Error()) - return multistep.ActionHalt - } - - ReportTags(ui, ec2Tags) - - // Retry creating tags for about 2.5 minutes - err = retry.Retry(0.2, 30, 11, func(_ uint) (bool, error) { - _, err := ec2conn.CreateTags(&ec2.CreateTagsInput{ - Tags: ec2Tags, - Resources: []*string{instance.InstanceId}, - }) - if err == nil { - return true, nil - } - if awsErr, ok := err.(awserr.Error); ok { - if awsErr.Code() == "InvalidInstanceID.NotFound" { - return false, nil + if createTagsAfterInstanceStarts { + // Retry creating tags for about 2.5 minutes + err = retry.Retry(0.2, 30, 11, func(_ uint) (bool, error) { + _, err := ec2conn.CreateTags(&ec2.CreateTagsInput{ + Tags: ec2Tags, + Resources: []*string{instance.InstanceId}, + }) + if err == nil { + return true, nil } - } - return true, err - }) + if awsErr, ok := err.(awserr.Error); ok { + if awsErr.Code() == "InvalidInstanceID.NotFound" { + return false, nil + } + } + return true, err + }) - if err != nil { - err := fmt.Errorf("Error tagging source instance: %s", err) - state.Put("error", err) - ui.Error(err.Error()) - return multistep.ActionHalt + if err != nil { + err := fmt.Errorf("Error tagging source instance: %s", err) + state.Put("error", err) + ui.Error(err.Error()) + return multistep.ActionHalt + } } if s.Debug { diff --git a/vendor/github.com/mitchellh/packer/builder/amazon/common/step_security_group.go b/vendor/github.com/mitchellh/packer/builder/amazon/common/step_security_group.go index a5032772..e7bc294b 100644 --- a/vendor/github.com/mitchellh/packer/builder/amazon/common/step_security_group.go +++ b/vendor/github.com/mitchellh/packer/builder/amazon/common/step_security_group.go @@ -6,7 +6,7 @@ import ( "time" "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/private/waiter" + "github.com/aws/aws-sdk-go/aws/request" "github.com/aws/aws-sdk-go/service/ec2" "github.com/hashicorp/packer/common/uuid" "github.com/hashicorp/packer/helper/communicator" @@ -153,36 +153,42 @@ func (s *StepSecurityGroup) Cleanup(state multistep.StateBag) { } func waitUntilSecurityGroupExists(c *ec2.EC2, input *ec2.DescribeSecurityGroupsInput) error { - waiterCfg := waiter.Config{ - Operation: "DescribeSecurityGroups", - Delay: 15, + ctx := aws.BackgroundContext() + w := request.Waiter{ + Name: "DescribeSecurityGroups", MaxAttempts: 40, - Acceptors: []waiter.WaitAcceptor{ + Acceptors: []request.WaiterAcceptor{ { - State: "success", - Matcher: "path", + State: request.SuccessWaiterState, + Matcher: request.PathWaiterMatch, Argument: "length(SecurityGroups[]) > `0`", Expected: true, }, { - State: "retry", - Matcher: "error", + State: request.RetryWaiterState, + Matcher: request.ErrorWaiterMatch, Argument: "", Expected: "InvalidGroup.NotFound", }, { - State: "retry", - Matcher: "error", + State: request.RetryWaiterState, + Matcher: request.ErrorWaiterMatch, Argument: "", Expected: "InvalidSecurityGroupID.NotFound", }, }, + Logger: c.Config.Logger, + NewRequest: func(opts []request.Option) (*request.Request, error) { + var inCpy *ec2.DescribeSecurityGroupsInput + if input != nil { + tmp := *input + inCpy = &tmp + } + req, _ := c.DescribeSecurityGroupsRequest(inCpy) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return req, nil + }, } - - w := waiter.Waiter{ - Client: c, - Input: input, - Config: waiterCfg, - } - return w.Wait() + return w.WaitWithContext(ctx) } diff --git a/vendor/github.com/mitchellh/packer/builder/amazon/common/step_source_ami_info.go b/vendor/github.com/mitchellh/packer/builder/amazon/common/step_source_ami_info.go index 386e8e8d..c7e9f733 100644 --- a/vendor/github.com/mitchellh/packer/builder/amazon/common/step_source_ami_info.go +++ b/vendor/github.com/mitchellh/packer/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 + EnableAMISriovNetSupport bool + EnableAMIENASupport 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.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/vendor/github.com/mitchellh/packer/builder/amazon/ebs/builder.go b/vendor/github.com/mitchellh/packer/builder/amazon/ebs/builder.go index 79ef6e68..c31da73a 100644 --- a/vendor/github.com/mitchellh/packer/builder/amazon/ebs/builder.go +++ b/vendor/github.com/mitchellh/packer/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, + EnableAMISriovNetSupport: b.config.AMISriovNetSupport, + EnableAMIENASupport: b.config.AMIENASupport, + AmiFilters: b.config.SourceAmiFilter, }, &awscommon.StepKeyPair{ Debug: b.config.PackerDebug, @@ -179,18 +180,22 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe DisableStopInstance: b.config.DisableStopInstance, }, &awscommon.StepModifyEBSBackedInstance{ - EnableEnhancedNetworking: b.config.AMIEnhancedNetworking, + EnableAMISriovNetSupport: b.config.AMISriovNetSupport, + EnableAMIENASupport: b.config.AMIENASupport, }, &awscommon.StepDeregisterAMI{ + AccessConfig: &b.config.AccessConfig, ForceDeregister: b.config.AMIForceDeregister, ForceDeleteSnapshot: b.config.AMIForceDeleteSnapshot, AMIName: b.config.AMIName, + Regions: b.config.AMIRegions, }, &stepCreateAMI{}, &awscommon.StepCreateEncryptedAMICopy{ KeyID: b.config.AMIKmsKeyId, EncryptBootVolume: b.config.AMIEncryptBootVolume, Name: b.config.AMIName, + AMIMappings: b.config.AMIBlockDevices.AMIMappings, }, &awscommon.StepAMIRegionCopy{ AccessConfig: &b.config.AccessConfig, diff --git a/vendor/github.com/mitchellh/packer/builder/amazon/ebssurrogate/builder.go b/vendor/github.com/mitchellh/packer/builder/amazon/ebssurrogate/builder.go index 5508abde..20984fee 100644 --- a/vendor/github.com/mitchellh/packer/builder/amazon/ebssurrogate/builder.go +++ b/vendor/github.com/mitchellh/packer/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, + EnableAMISriovNetSupport: b.config.AMISriovNetSupport, + EnableAMIENASupport: b.config.AMIENASupport, + AmiFilters: b.config.SourceAmiFilter, }, &awscommon.StepKeyPair{ Debug: b.config.PackerDebug, @@ -189,19 +190,24 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe DisableStopInstance: b.config.DisableStopInstance, }, &awscommon.StepModifyEBSBackedInstance{ - EnableEnhancedNetworking: b.config.AMIEnhancedNetworking, + EnableAMISriovNetSupport: b.config.AMISriovNetSupport, + EnableAMIENASupport: b.config.AMIENASupport, }, &StepSnapshotNewRootVolume{ NewRootMountPoint: b.config.RootDevice.SourceDeviceName, }, &awscommon.StepDeregisterAMI{ + AccessConfig: &b.config.AccessConfig, ForceDeregister: b.config.AMIForceDeregister, ForceDeleteSnapshot: b.config.AMIForceDeleteSnapshot, AMIName: b.config.AMIName, + 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/vendor/github.com/mitchellh/packer/builder/amazon/ebssurrogate/step_register_ami.go b/vendor/github.com/mitchellh/packer/builder/amazon/ebssurrogate/step_register_ami.go index d2f0f225..f0d145f3 100644 --- a/vendor/github.com/mitchellh/packer/builder/amazon/ebssurrogate/step_register_ami.go +++ b/vendor/github.com/mitchellh/packer/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/vendor/github.com/mitchellh/packer/builder/amazon/ebsvolume/builder.go b/vendor/github.com/mitchellh/packer/builder/amazon/ebsvolume/builder.go index 098cb4c9..1aad1819 100644 --- a/vendor/github.com/mitchellh/packer/builder/amazon/ebsvolume/builder.go +++ b/vendor/github.com/mitchellh/packer/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"` + AMIENASupport bool `mapstructure:"ena_support"` + AMISriovNetSupport 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, + EnableAMISriovNetSupport: b.config.AMISriovNetSupport, + EnableAMIENASupport: b.config.AMIENASupport, + 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, + EnableAMISriovNetSupport: b.config.AMISriovNetSupport, + EnableAMIENASupport: b.config.AMIENASupport, }, } diff --git a/vendor/github.com/mitchellh/packer/builder/amazon/instance/builder.go b/vendor/github.com/mitchellh/packer/builder/amazon/instance/builder.go index d45dc64d..6329008f 100644 --- a/vendor/github.com/mitchellh/packer/builder/amazon/instance/builder.go +++ b/vendor/github.com/mitchellh/packer/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, + EnableAMISriovNetSupport: b.config.AMISriovNetSupport, + EnableAMIENASupport: b.config.AMIENASupport, + AmiFilters: b.config.SourceAmiFilter, }, &awscommon.StepKeyPair{ Debug: b.config.PackerDebug, @@ -258,11 +259,16 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe Debug: b.config.PackerDebug, }, &awscommon.StepDeregisterAMI{ + AccessConfig: &b.config.AccessConfig, ForceDeregister: b.config.AMIForceDeregister, ForceDeleteSnapshot: b.config.AMIForceDeleteSnapshot, AMIName: b.config.AMIName, + Regions: b.config.AMIRegions, + }, + &StepRegisterAMI{ + EnableAMISriovNetSupport: b.config.AMISriovNetSupport, + EnableAMIENASupport: b.config.AMIENASupport, }, - &StepRegisterAMI{}, &awscommon.StepAMIRegionCopy{ AccessConfig: &b.config.AccessConfig, Regions: b.config.AMIRegions, diff --git a/vendor/github.com/mitchellh/packer/builder/amazon/instance/step_register_ami.go b/vendor/github.com/mitchellh/packer/builder/amazon/instance/step_register_ami.go index 01ba46bd..d363bdfd 100644 --- a/vendor/github.com/mitchellh/packer/builder/amazon/instance/step_register_ami.go +++ b/vendor/github.com/mitchellh/packer/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) } |