use aws helper method

pull/4600/head
Matthew Hooker 9 years ago
parent 61976dfd86
commit fd1b00a0d1
No known key found for this signature in database
GPG Key ID: 7B5F933D9CE8C6A1

@ -3,6 +3,7 @@ package common
import ( import (
"fmt" "fmt"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/ec2" "github.com/aws/aws-sdk-go/service/ec2"
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer" "github.com/mitchellh/packer/packer"
@ -22,12 +23,12 @@ func (s *StepModifyEBSBackedInstance) Run(state multistep.StateBag) multistep.St
// As of February 2017, this applies to C3, C4, D2, I2, R3, and M4 (excluding m4.16xlarge) // As of February 2017, this applies to C3, C4, D2, I2, R3, and M4 (excluding m4.16xlarge)
ui.Say("Enabling Enhanced Networking (SR-IOV)...") ui.Say("Enabling Enhanced Networking (SR-IOV)...")
simple := "simple" simple := "simple"
_, err_iov := ec2conn.ModifyInstanceAttribute(&ec2.ModifyInstanceAttributeInput{ _, err := ec2conn.ModifyInstanceAttribute(&ec2.ModifyInstanceAttributeInput{
InstanceId: instance.InstanceId, InstanceId: instance.InstanceId,
SriovNetSupport: &ec2.AttributeValue{Value: &simple}, SriovNetSupport: &ec2.AttributeValue{Value: &simple},
}) })
if err_iov != nil { if err != nil {
err := fmt.Errorf("Error enabling Enhanced Networking (SR-IOV) on %s: %s", *instance.InstanceId, err_iov) err := fmt.Errorf("Error enabling Enhanced Networking (SR-IOV) on %s: %s", *instance.InstanceId, err)
state.Put("error", err) state.Put("error", err)
ui.Error(err.Error()) ui.Error(err.Error())
return multistep.ActionHalt return multistep.ActionHalt
@ -36,13 +37,12 @@ func (s *StepModifyEBSBackedInstance) Run(state multistep.StateBag) multistep.St
// Set EnaSupport to true. // Set EnaSupport to true.
// As of February 2017, this applies to C5, I3, P2, R4, X1, and m4.16xlarge // As of February 2017, this applies to C5, I3, P2, R4, X1, and m4.16xlarge
ui.Say("Enabling Enhanced Networking (ENA)...") ui.Say("Enabling Enhanced Networking (ENA)...")
truthy := true _, err = ec2conn.ModifyInstanceAttribute(&ec2.ModifyInstanceAttributeInput{
_, err_ena := ec2conn.ModifyInstanceAttribute(&ec2.ModifyInstanceAttributeInput{
InstanceId: instance.InstanceId, InstanceId: instance.InstanceId,
EnaSupport: &ec2.AttributeBooleanValue{Value: &truthy}, EnaSupport: &ec2.AttributeBooleanValue{Value: aws.Bool(true)},
}) })
if err_ena != nil { if err != nil {
err := fmt.Errorf("Error enabling Enhanced Networking (ENA) on %s: %s", *instance.InstanceId, err_ena) err := fmt.Errorf("Error enabling Enhanced Networking (ENA) on %s: %s", *instance.InstanceId, err)
state.Put("error", err) state.Put("error", err)
ui.Error(err.Error()) ui.Error(err.Error())
return multistep.ActionHalt return multistep.ActionHalt

Loading…
Cancel
Save