From 8682dec178221c2a66d7b3518bc81ff58e44f3d3 Mon Sep 17 00:00:00 2001 From: Luke Amdor Date: Fri, 30 Oct 2015 13:58:56 -0500 Subject: [PATCH] aws: build after upstream breaking change see https://github.com/aws/aws-sdk-go/commit/1a69d069352edadd48f12b0f2c5f375de4a636d7 --- builder/amazon/chroot/builder.go | 4 +++- builder/amazon/common/artifact.go | 4 +++- builder/amazon/common/step_ami_region_copy.go | 5 ++++- builder/amazon/common/step_create_tags.go | 9 ++++++--- builder/amazon/common/step_modify_ami_attributes.go | 7 +++++-- builder/amazon/ebs/builder.go | 4 +++- builder/amazon/instance/builder.go | 4 +++- 7 files changed, 27 insertions(+), 10 deletions(-) diff --git a/builder/amazon/chroot/builder.go b/builder/amazon/chroot/builder.go index 636de8df7..637b1e40f 100644 --- a/builder/amazon/chroot/builder.go +++ b/builder/amazon/chroot/builder.go @@ -9,6 +9,7 @@ import ( "log" "runtime" + "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/ec2" "github.com/mitchellh/multistep" awscommon "github.com/mitchellh/packer/builder/amazon/common" @@ -131,7 +132,8 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe return nil, err } - ec2conn := ec2.New(config) + session := session.New(config) + ec2conn := ec2.New(session) wrappedCommand := func(command string) (string, error) { ctx := b.config.ctx diff --git a/builder/amazon/common/artifact.go b/builder/amazon/common/artifact.go index 8eed0134d..76f4e03e0 100644 --- a/builder/amazon/common/artifact.go +++ b/builder/amazon/common/artifact.go @@ -7,6 +7,7 @@ import ( "strings" "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/ec2" "github.com/mitchellh/packer/packer" ) @@ -72,7 +73,8 @@ func (a *Artifact) Destroy() error { Credentials: a.Conn.Config.Credentials, Region: aws.String(region), } - regionConn := ec2.New(regionConfig) + sess := session.New(regionConfig) + regionConn := ec2.New(sess) input := &ec2.DeregisterImageInput{ ImageId: &imageId, diff --git a/builder/amazon/common/step_ami_region_copy.go b/builder/amazon/common/step_ami_region_copy.go index 0cf4d40fa..fa955ac7b 100644 --- a/builder/amazon/common/step_ami_region_copy.go +++ b/builder/amazon/common/step_ami_region_copy.go @@ -6,6 +6,7 @@ import ( "sync" "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/ec2" "github.com/mitchellh/multistep" @@ -87,7 +88,9 @@ func amiRegionCopy(state multistep.StateBag, config *AccessConfig, name string, } awsConfig.Region = aws.String(target) - regionconn := ec2.New(awsConfig) + sess := session.New(awsConfig) + regionconn := ec2.New(sess) + resp, err := regionconn.CopyImage(&ec2.CopyImageInput{ SourceRegion: &source, SourceImageId: &imageId, diff --git a/builder/amazon/common/step_create_tags.go b/builder/amazon/common/step_create_tags.go index 7f62d2657..2ac39dc02 100644 --- a/builder/amazon/common/step_create_tags.go +++ b/builder/amazon/common/step_create_tags.go @@ -4,6 +4,7 @@ import ( "fmt" "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/ec2" "github.com/mitchellh/multistep" "github.com/mitchellh/packer/packer" @@ -33,11 +34,13 @@ func (s *StepCreateTags) Run(state multistep.StateBag) multistep.StepAction { // Declare list of resources to tag resourceIds := []*string{&ami} - - regionconn := ec2.New(&aws.Config{ + awsConfig := aws.Config{ Credentials: ec2conn.Config.Credentials, Region: aws.String(region), - }) + } + session := session.New(&awsConfig) + + regionconn := ec2.New(session) // Retrieve image list for given AMI imageResp, err := regionconn.DescribeImages(&ec2.DescribeImagesInput{ diff --git a/builder/amazon/common/step_modify_ami_attributes.go b/builder/amazon/common/step_modify_ami_attributes.go index e8e7de589..31d60a392 100644 --- a/builder/amazon/common/step_modify_ami_attributes.go +++ b/builder/amazon/common/step_modify_ami_attributes.go @@ -4,6 +4,7 @@ import ( "fmt" "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/ec2" "github.com/mitchellh/multistep" "github.com/mitchellh/packer/packer" @@ -88,10 +89,12 @@ func (s *StepModifyAMIAttributes) Run(state multistep.StateBag) multistep.StepAc for region, ami := range amis { ui.Say(fmt.Sprintf("Modifying attributes on AMI (%s)...", ami)) - regionconn := ec2.New(&aws.Config{ + awsConfig := aws.Config{ Credentials: ec2conn.Config.Credentials, Region: aws.String(region), - }) + } + session := session.New(&awsConfig) + regionconn := ec2.New(session) for name, input := range options { ui.Message(fmt.Sprintf("Modifying: %s", name)) input.ImageId = &ami diff --git a/builder/amazon/ebs/builder.go b/builder/amazon/ebs/builder.go index 26a525bcb..b9277a5ab 100644 --- a/builder/amazon/ebs/builder.go +++ b/builder/amazon/ebs/builder.go @@ -9,6 +9,7 @@ import ( "fmt" "log" + "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/ec2" "github.com/mitchellh/multistep" awscommon "github.com/mitchellh/packer/builder/amazon/common" @@ -68,7 +69,8 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe return nil, err } - ec2conn := ec2.New(config) + session := session.New(config) + ec2conn := ec2.New(session) // Setup the state bag and initial state for the steps state := new(multistep.BasicStateBag) diff --git a/builder/amazon/instance/builder.go b/builder/amazon/instance/builder.go index 6ca908230..6b1726efb 100644 --- a/builder/amazon/instance/builder.go +++ b/builder/amazon/instance/builder.go @@ -9,6 +9,7 @@ import ( "os" "strings" + "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/ec2" "github.com/mitchellh/multistep" awscommon "github.com/mitchellh/packer/builder/amazon/common" @@ -159,7 +160,8 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe return nil, err } - ec2conn := ec2.New(config) + session := session.New(config) + ec2conn := ec2.New(session) // Setup the state bag and initial state for the steps state := new(multistep.BasicStateBag)