github.com/rothwerx/packer@v0.9.0/builder/amazon/ebs/step_modify_instance.go (about) 1 package ebs 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 stepModifyInstance struct{} 12 13 func (s *stepModifyInstance) Run(state multistep.StateBag) multistep.StepAction { 14 config := state.Get("config").(Config) 15 ec2conn := state.Get("ec2").(*ec2.EC2) 16 instance := state.Get("instance").(*ec2.Instance) 17 ui := state.Get("ui").(packer.Ui) 18 19 // Set SriovNetSupport to "simple". See http://goo.gl/icuXh5 20 if config.AMIEnhancedNetworking { 21 ui.Say("Enabling Enhanced Networking...") 22 simple := "simple" 23 _, err := ec2conn.ModifyInstanceAttribute(&ec2.ModifyInstanceAttributeInput{ 24 InstanceId: instance.InstanceId, 25 SriovNetSupport: &ec2.AttributeValue{Value: &simple}, 26 }) 27 if err != nil { 28 err := fmt.Errorf("Error enabling Enhanced Networking on %s: %s", *instance.InstanceId, err) 29 state.Put("error", err) 30 ui.Error(err.Error()) 31 return multistep.ActionHalt 32 } 33 } 34 35 return multistep.ActionContinue 36 } 37 38 func (s *stepModifyInstance) Cleanup(state multistep.StateBag) { 39 // No cleanup... 40 }