github.com/amanya/packer@v0.12.1-0.20161117214323-902ac5ab2eb6/builder/amazon/common/step_modify_ebs_instance.go (about) 1 package common 2 3 import ( 4 "fmt" 5 6 "github.com/aws/aws-sdk-go/service/ec2" 7 "github.com/mitchellh/multistep" 8 "github.com/mitchellh/packer/packer" 9 ) 10 11 type StepModifyEBSBackedInstance struct { 12 EnableEnhancedNetworking bool 13 } 14 15 func (s *StepModifyEBSBackedInstance) Run(state multistep.StateBag) multistep.StepAction { 16 ec2conn := state.Get("ec2").(*ec2.EC2) 17 instance := state.Get("instance").(*ec2.Instance) 18 ui := state.Get("ui").(packer.Ui) 19 20 // Set SriovNetSupport to "simple". See http://goo.gl/icuXh5 21 if s.EnableEnhancedNetworking { 22 ui.Say("Enabling Enhanced Networking...") 23 simple := "simple" 24 _, err := ec2conn.ModifyInstanceAttribute(&ec2.ModifyInstanceAttributeInput{ 25 InstanceId: instance.InstanceId, 26 SriovNetSupport: &ec2.AttributeValue{Value: &simple}, 27 }) 28 if err != nil { 29 err := fmt.Errorf("Error enabling Enhanced Networking on %s: %s", *instance.InstanceId, err) 30 state.Put("error", err) 31 ui.Error(err.Error()) 32 return multistep.ActionHalt 33 } 34 } 35 36 return multistep.ActionContinue 37 } 38 39 func (s *StepModifyEBSBackedInstance) Cleanup(state multistep.StateBag) { 40 // No cleanup... 41 }