Commit 28bf1877 authored by Chris Bednarski's avatar Chris Bednarski

Updated AWS SDK calls to match the 0.7.0 release of the AWS SDK

parent 8a426bea
...@@ -5,7 +5,6 @@ import ( ...@@ -5,7 +5,6 @@ import (
"log" "log"
"github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awsutil"
"github.com/aws/aws-sdk-go/service/ec2" "github.com/aws/aws-sdk-go/service/ec2"
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
awscommon "github.com/mitchellh/packer/builder/amazon/common" awscommon "github.com/mitchellh/packer/builder/amazon/common"
...@@ -52,12 +51,12 @@ func (s *StepCreateVolume) Run(state multistep.StateBag) multistep.StepAction { ...@@ -52,12 +51,12 @@ func (s *StepCreateVolume) Run(state multistep.StateBag) multistep.StepAction {
} }
createVolume := &ec2.CreateVolumeInput{ createVolume := &ec2.CreateVolumeInput{
AvailabilityZone: instance.Placement.AvailabilityZone, AvailabilityZone: instance.Placement.AvailabilityZone,
Size: aws.Long(vs), Size: aws.Int64(vs),
SnapshotID: rootDevice.EBS.SnapshotID, SnapshotID: rootDevice.EBS.SnapshotID,
VolumeType: rootDevice.EBS.VolumeType, VolumeType: rootDevice.EBS.VolumeType,
IOPS: rootDevice.EBS.IOPS, IOPS: rootDevice.EBS.IOPS,
} }
log.Printf("Create args: %s", awsutil.StringValue(createVolume)) log.Printf("Create args: %s", createVolume)
createVolumeResp, err := ec2conn.CreateVolume(createVolume) createVolumeResp, err := ec2conn.CreateVolume(createVolume)
if err != nil { if err != nil {
......
...@@ -34,7 +34,7 @@ func (s *StepRegisterAMI) Run(state multistep.StateBag) multistep.StepAction { ...@@ -34,7 +34,7 @@ func (s *StepRegisterAMI) Run(state multistep.StateBag) multistep.StepAction {
} }
if s.RootVolumeSize > *newDevice.EBS.VolumeSize { if s.RootVolumeSize > *newDevice.EBS.VolumeSize {
newDevice.EBS.VolumeSize = aws.Long(s.RootVolumeSize) newDevice.EBS.VolumeSize = aws.Int64(s.RootVolumeSize)
} }
} }
...@@ -64,7 +64,7 @@ func (s *StepRegisterAMI) Run(state multistep.StateBag) multistep.StepAction { ...@@ -64,7 +64,7 @@ func (s *StepRegisterAMI) Run(state multistep.StateBag) multistep.StepAction {
// Set the AMI ID in the state // Set the AMI ID in the state
ui.Say(fmt.Sprintf("AMI: %s", *registerResp.ImageID)) ui.Say(fmt.Sprintf("AMI: %s", *registerResp.ImageID))
amis := make(map[string]string) amis := make(map[string]string)
amis[ec2conn.Config.Region] = *registerResp.ImageID amis[*ec2conn.Config.Region] = *registerResp.ImageID
state.Put("amis", amis) state.Put("amis", amis)
// Wait for the image to become ready // Wait for the image to become ready
......
...@@ -40,9 +40,9 @@ func (c *AccessConfig) Config() (*aws.Config, error) { ...@@ -40,9 +40,9 @@ func (c *AccessConfig) Config() (*aws.Config, error) {
} }
return &aws.Config{ return &aws.Config{
Region: region, Region: aws.String(region),
Credentials: creds, Credentials: creds,
MaxRetries: 11, MaxRetries: aws.Int(11),
}, nil }, nil
} }
......
...@@ -70,7 +70,7 @@ func (a *Artifact) Destroy() error { ...@@ -70,7 +70,7 @@ func (a *Artifact) Destroy() error {
regionConfig := &aws.Config{ regionConfig := &aws.Config{
Credentials: a.Conn.Config.Credentials, Credentials: a.Conn.Config.Credentials,
Region: region, Region: aws.String(region),
} }
regionConn := ec2.New(regionConfig) regionConn := ec2.New(regionConfig)
......
...@@ -32,20 +32,20 @@ func buildBlockDevices(b []BlockDevice) []*ec2.BlockDeviceMapping { ...@@ -32,20 +32,20 @@ func buildBlockDevices(b []BlockDevice) []*ec2.BlockDeviceMapping {
for _, blockDevice := range b { for _, blockDevice := range b {
ebsBlockDevice := &ec2.EBSBlockDevice{ ebsBlockDevice := &ec2.EBSBlockDevice{
VolumeType: aws.String(blockDevice.VolumeType), VolumeType: aws.String(blockDevice.VolumeType),
VolumeSize: aws.Long(blockDevice.VolumeSize), VolumeSize: aws.Int64(blockDevice.VolumeSize),
DeleteOnTermination: aws.Boolean(blockDevice.DeleteOnTermination), DeleteOnTermination: aws.Bool(blockDevice.DeleteOnTermination),
} }
// IOPS is only valid for SSD Volumes // IOPS is only valid for SSD Volumes
if blockDevice.VolumeType != "" && blockDevice.VolumeType != "standard" && blockDevice.VolumeType != "gp2" { if blockDevice.VolumeType != "" && blockDevice.VolumeType != "standard" && blockDevice.VolumeType != "gp2" {
ebsBlockDevice.IOPS = aws.Long(blockDevice.IOPS) ebsBlockDevice.IOPS = aws.Int64(blockDevice.IOPS)
} }
// You cannot specify Encrypted if you specify a Snapshot ID // You cannot specify Encrypted if you specify a Snapshot ID
if blockDevice.SnapshotId != "" { if blockDevice.SnapshotId != "" {
ebsBlockDevice.SnapshotID = aws.String(blockDevice.SnapshotId) ebsBlockDevice.SnapshotID = aws.String(blockDevice.SnapshotId)
} else if blockDevice.Encrypted { } else if blockDevice.Encrypted {
ebsBlockDevice.Encrypted = aws.Boolean(blockDevice.Encrypted) ebsBlockDevice.Encrypted = aws.Bool(blockDevice.Encrypted)
} }
mapping := &ec2.BlockDeviceMapping{ mapping := &ec2.BlockDeviceMapping{
......
...@@ -5,7 +5,6 @@ import ( ...@@ -5,7 +5,6 @@ import (
"testing" "testing"
"github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awsutil"
"github.com/aws/aws-sdk-go/service/ec2" "github.com/aws/aws-sdk-go/service/ec2"
) )
...@@ -29,8 +28,8 @@ func TestBlockDevice(t *testing.T) { ...@@ -29,8 +28,8 @@ func TestBlockDevice(t *testing.T) {
EBS: &ec2.EBSBlockDevice{ EBS: &ec2.EBSBlockDevice{
SnapshotID: aws.String("snap-1234"), SnapshotID: aws.String("snap-1234"),
VolumeType: aws.String("standard"), VolumeType: aws.String("standard"),
VolumeSize: aws.Long(8), VolumeSize: aws.Int64(8),
DeleteOnTermination: aws.Boolean(true), DeleteOnTermination: aws.Bool(true),
}, },
}, },
}, },
...@@ -45,8 +44,8 @@ func TestBlockDevice(t *testing.T) { ...@@ -45,8 +44,8 @@ func TestBlockDevice(t *testing.T) {
VirtualName: aws.String(""), VirtualName: aws.String(""),
EBS: &ec2.EBSBlockDevice{ EBS: &ec2.EBSBlockDevice{
VolumeType: aws.String(""), VolumeType: aws.String(""),
VolumeSize: aws.Long(8), VolumeSize: aws.Int64(8),
DeleteOnTermination: aws.Boolean(false), DeleteOnTermination: aws.Bool(false),
}, },
}, },
}, },
...@@ -64,9 +63,9 @@ func TestBlockDevice(t *testing.T) { ...@@ -64,9 +63,9 @@ func TestBlockDevice(t *testing.T) {
VirtualName: aws.String(""), VirtualName: aws.String(""),
EBS: &ec2.EBSBlockDevice{ EBS: &ec2.EBSBlockDevice{
VolumeType: aws.String("io1"), VolumeType: aws.String("io1"),
VolumeSize: aws.Long(8), VolumeSize: aws.Int64(8),
DeleteOnTermination: aws.Boolean(true), DeleteOnTermination: aws.Bool(true),
IOPS: aws.Long(1000), IOPS: aws.Int64(1000),
}, },
}, },
}, },
...@@ -93,13 +92,13 @@ func TestBlockDevice(t *testing.T) { ...@@ -93,13 +92,13 @@ func TestBlockDevice(t *testing.T) {
got := blockDevices.BuildAMIDevices() got := blockDevices.BuildAMIDevices()
if !reflect.DeepEqual(expected, got) { if !reflect.DeepEqual(expected, got) {
t.Fatalf("Bad block device, \nexpected: %s\n\ngot: %s", t.Fatalf("Bad block device, \nexpected: %s\n\ngot: %s",
awsutil.StringValue(expected), awsutil.StringValue(got)) expected, got)
} }
if !reflect.DeepEqual(expected, blockDevices.BuildLaunchDevices()) { if !reflect.DeepEqual(expected, blockDevices.BuildLaunchDevices()) {
t.Fatalf("Bad block device, \nexpected: %s\n\ngot: %s", t.Fatalf("Bad block device, \nexpected: %s\n\ngot: %s",
awsutil.StringValue(expected), expected,
awsutil.StringValue(blockDevices.BuildLaunchDevices())) blockDevices.BuildLaunchDevices())
} }
} }
} }
...@@ -5,6 +5,7 @@ import ( ...@@ -5,6 +5,7 @@ import (
"sync" "sync"
"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"
...@@ -21,7 +22,7 @@ func (s *StepAMIRegionCopy) Run(state multistep.StateBag) multistep.StepAction { ...@@ -21,7 +22,7 @@ func (s *StepAMIRegionCopy) Run(state multistep.StateBag) multistep.StepAction {
ec2conn := state.Get("ec2").(*ec2.EC2) ec2conn := state.Get("ec2").(*ec2.EC2)
ui := state.Get("ui").(packer.Ui) ui := state.Get("ui").(packer.Ui)
amis := state.Get("amis").(map[string]string) amis := state.Get("amis").(map[string]string)
ami := amis[ec2conn.Config.Region] ami := amis[*ec2conn.Config.Region]
if len(s.Regions) == 0 { if len(s.Regions) == 0 {
return multistep.ActionContinue return multistep.ActionContinue
...@@ -33,7 +34,7 @@ func (s *StepAMIRegionCopy) Run(state multistep.StateBag) multistep.StepAction { ...@@ -33,7 +34,7 @@ func (s *StepAMIRegionCopy) Run(state multistep.StateBag) multistep.StepAction {
var wg sync.WaitGroup var wg sync.WaitGroup
errs := new(packer.MultiError) errs := new(packer.MultiError)
for _, region := range s.Regions { for _, region := range s.Regions {
if region == ec2conn.Config.Region { if region == *ec2conn.Config.Region {
ui.Message(fmt.Sprintf( ui.Message(fmt.Sprintf(
"Avoiding copying AMI to duplicate region %s", region)) "Avoiding copying AMI to duplicate region %s", region))
continue continue
...@@ -44,7 +45,7 @@ func (s *StepAMIRegionCopy) Run(state multistep.StateBag) multistep.StepAction { ...@@ -44,7 +45,7 @@ func (s *StepAMIRegionCopy) Run(state multistep.StateBag) multistep.StepAction {
go func(region string) { go func(region string) {
defer wg.Done() defer wg.Done()
id, err := amiRegionCopy(state, s.AccessConfig, s.Name, ami, region, ec2conn.Config.Region) id, err := amiRegionCopy(state, s.AccessConfig, s.Name, ami, region, *ec2conn.Config.Region)
lock.Lock() lock.Lock()
defer lock.Unlock() defer lock.Unlock()
...@@ -84,7 +85,7 @@ func amiRegionCopy(state multistep.StateBag, config *AccessConfig, name string, ...@@ -84,7 +85,7 @@ func amiRegionCopy(state multistep.StateBag, config *AccessConfig, name string,
if err != nil { if err != nil {
return "", err return "", err
} }
awsConfig.Region = target awsConfig.Region = aws.String(target)
regionconn := ec2.New(awsConfig) regionconn := ec2.New(awsConfig)
resp, err := regionconn.CopyImage(&ec2.CopyImageInput{ resp, err := regionconn.CopyImage(&ec2.CopyImageInput{
......
...@@ -36,7 +36,7 @@ func (s *StepCreateTags) Run(state multistep.StateBag) multistep.StepAction { ...@@ -36,7 +36,7 @@ func (s *StepCreateTags) Run(state multistep.StateBag) multistep.StepAction {
regionconn := ec2.New(&aws.Config{ regionconn := ec2.New(&aws.Config{
Credentials: ec2conn.Config.Credentials, Credentials: ec2conn.Config.Credentials,
Region: region, Region: aws.String(region),
}) })
// Retrieve image list for given AMI // Retrieve image list for given AMI
......
...@@ -90,7 +90,7 @@ func (s *StepModifyAMIAttributes) Run(state multistep.StateBag) multistep.StepAc ...@@ -90,7 +90,7 @@ func (s *StepModifyAMIAttributes) Run(state multistep.StateBag) multistep.StepAc
ui.Say(fmt.Sprintf("Modifying attributes on AMI (%s)...", ami)) ui.Say(fmt.Sprintf("Modifying attributes on AMI (%s)...", ami))
regionconn := ec2.New(&aws.Config{ regionconn := ec2.New(&aws.Config{
Credentials: ec2conn.Config.Credentials, Credentials: ec2conn.Config.Credentials,
Region: region, Region: aws.String(region),
}) })
for name, input := range options { for name, input := range options {
ui.Message(fmt.Sprintf("Modifying: %s", name)) ui.Message(fmt.Sprintf("Modifying: %s", name))
......
...@@ -141,8 +141,8 @@ func (s *StepRunSourceInstance) Run(state multistep.StateBag) multistep.StepActi ...@@ -141,8 +141,8 @@ func (s *StepRunSourceInstance) Run(state multistep.StateBag) multistep.StepActi
ImageID: &s.SourceAMI, ImageID: &s.SourceAMI,
InstanceType: &s.InstanceType, InstanceType: &s.InstanceType,
UserData: &userData, UserData: &userData,
MaxCount: aws.Long(1), MaxCount: aws.Int64(1),
MinCount: aws.Long(1), MinCount: aws.Int64(1),
IAMInstanceProfile: &ec2.IAMInstanceProfileSpecification{Name: &s.IamInstanceProfile}, IAMInstanceProfile: &ec2.IAMInstanceProfileSpecification{Name: &s.IamInstanceProfile},
BlockDeviceMappings: s.BlockDevices.BuildLaunchDevices(), BlockDeviceMappings: s.BlockDevices.BuildLaunchDevices(),
Placement: &ec2.Placement{AvailabilityZone: &s.AvailabilityZone}, Placement: &ec2.Placement{AvailabilityZone: &s.AvailabilityZone},
...@@ -151,11 +151,11 @@ func (s *StepRunSourceInstance) Run(state multistep.StateBag) multistep.StepActi ...@@ -151,11 +151,11 @@ func (s *StepRunSourceInstance) Run(state multistep.StateBag) multistep.StepActi
if s.SubnetId != "" && s.AssociatePublicIpAddress { if s.SubnetId != "" && s.AssociatePublicIpAddress {
runOpts.NetworkInterfaces = []*ec2.InstanceNetworkInterfaceSpecification{ runOpts.NetworkInterfaces = []*ec2.InstanceNetworkInterfaceSpecification{
&ec2.InstanceNetworkInterfaceSpecification{ &ec2.InstanceNetworkInterfaceSpecification{
DeviceIndex: aws.Long(0), DeviceIndex: aws.Int64(0),
AssociatePublicIPAddress: &s.AssociatePublicIpAddress, AssociatePublicIPAddress: &s.AssociatePublicIpAddress,
SubnetID: &s.SubnetId, SubnetID: &s.SubnetId,
Groups: securityGroupIds, Groups: securityGroupIds,
DeleteOnTermination: aws.Boolean(true), DeleteOnTermination: aws.Bool(true),
}, },
} }
} else { } else {
...@@ -185,11 +185,11 @@ func (s *StepRunSourceInstance) Run(state multistep.StateBag) multistep.StepActi ...@@ -185,11 +185,11 @@ func (s *StepRunSourceInstance) Run(state multistep.StateBag) multistep.StepActi
IAMInstanceProfile: &ec2.IAMInstanceProfileSpecification{Name: &s.IamInstanceProfile}, IAMInstanceProfile: &ec2.IAMInstanceProfileSpecification{Name: &s.IamInstanceProfile},
NetworkInterfaces: []*ec2.InstanceNetworkInterfaceSpecification{ NetworkInterfaces: []*ec2.InstanceNetworkInterfaceSpecification{
&ec2.InstanceNetworkInterfaceSpecification{ &ec2.InstanceNetworkInterfaceSpecification{
DeviceIndex: aws.Long(0), DeviceIndex: aws.Int64(0),
AssociatePublicIPAddress: &s.AssociatePublicIpAddress, AssociatePublicIPAddress: &s.AssociatePublicIpAddress,
SubnetID: &s.SubnetId, SubnetID: &s.SubnetId,
Groups: securityGroupIds, Groups: securityGroupIds,
DeleteOnTermination: aws.Boolean(true), DeleteOnTermination: aws.Bool(true),
}, },
}, },
Placement: &ec2.SpotPlacement{ Placement: &ec2.SpotPlacement{
......
...@@ -59,8 +59,8 @@ func (s *StepSecurityGroup) Run(state multistep.StateBag) multistep.StepAction { ...@@ -59,8 +59,8 @@ func (s *StepSecurityGroup) Run(state multistep.StateBag) multistep.StepAction {
req := &ec2.AuthorizeSecurityGroupIngressInput{ req := &ec2.AuthorizeSecurityGroupIngressInput{
GroupID: groupResp.GroupID, GroupID: groupResp.GroupID,
IPProtocol: aws.String("tcp"), IPProtocol: aws.String("tcp"),
FromPort: aws.Long(int64(port)), FromPort: aws.Int64(int64(port)),
ToPort: aws.Long(int64(port)), ToPort: aws.Int64(int64(port)),
CIDRIP: aws.String("0.0.0.0/0"), CIDRIP: aws.String("0.0.0.0/0"),
} }
......
...@@ -38,7 +38,7 @@ func (s *stepCreateAMI) Run(state multistep.StateBag) multistep.StepAction { ...@@ -38,7 +38,7 @@ func (s *stepCreateAMI) Run(state multistep.StateBag) multistep.StepAction {
// Set the AMI ID in the state // Set the AMI ID in the state
ui.Message(fmt.Sprintf("AMI: %s", *createResp.ImageID)) ui.Message(fmt.Sprintf("AMI: %s", *createResp.ImageID))
amis := make(map[string]string) amis := make(map[string]string)
amis[ec2conn.Config.Region] = *createResp.ImageID amis[*ec2conn.Config.Region] = *createResp.ImageID
state.Put("amis", amis) state.Put("amis", amis)
// Wait for the image to become ready // Wait for the image to become ready
......
...@@ -44,7 +44,7 @@ func (s *StepRegisterAMI) Run(state multistep.StateBag) multistep.StepAction { ...@@ -44,7 +44,7 @@ func (s *StepRegisterAMI) Run(state multistep.StateBag) multistep.StepAction {
// Set the AMI ID in the state // Set the AMI ID in the state
ui.Say(fmt.Sprintf("AMI: %s", *registerResp.ImageID)) ui.Say(fmt.Sprintf("AMI: %s", *registerResp.ImageID))
amis := make(map[string]string) amis := make(map[string]string)
amis[ec2conn.Config.Region] = *registerResp.ImageID amis[*ec2conn.Config.Region] = *registerResp.ImageID
state.Put("amis", amis) state.Put("amis", amis)
// Wait for the image to become ready // Wait for the image to become ready
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment