Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
packer
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kristopher Ruzic
packer
Commits
68a6a0df
Commit
68a6a0df
authored
Jul 28, 2015
by
Chris Bednarski
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2523 from mitchellh/b-aws-0.7.0
Updated AWS SDK calls to match the 0.7.0 release of the AWS SDK
parents
8a426bea
28bf1877
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
38 additions
and
39 deletions
+38
-39
builder/amazon/chroot/step_create_volume.go
builder/amazon/chroot/step_create_volume.go
+2
-3
builder/amazon/chroot/step_register_ami.go
builder/amazon/chroot/step_register_ami.go
+2
-2
builder/amazon/common/access_config.go
builder/amazon/common/access_config.go
+2
-2
builder/amazon/common/artifact.go
builder/amazon/common/artifact.go
+1
-1
builder/amazon/common/block_device.go
builder/amazon/common/block_device.go
+4
-4
builder/amazon/common/block_device_test.go
builder/amazon/common/block_device_test.go
+10
-11
builder/amazon/common/step_ami_region_copy.go
builder/amazon/common/step_ami_region_copy.go
+5
-4
builder/amazon/common/step_create_tags.go
builder/amazon/common/step_create_tags.go
+1
-1
builder/amazon/common/step_modify_ami_attributes.go
builder/amazon/common/step_modify_ami_attributes.go
+1
-1
builder/amazon/common/step_run_source_instance.go
builder/amazon/common/step_run_source_instance.go
+6
-6
builder/amazon/common/step_security_group.go
builder/amazon/common/step_security_group.go
+2
-2
builder/amazon/ebs/step_create_ami.go
builder/amazon/ebs/step_create_ami.go
+1
-1
builder/amazon/instance/step_register_ami.go
builder/amazon/instance/step_register_ami.go
+1
-1
No files found.
builder/amazon/chroot/step_create_volume.go
View file @
68a6a0df
...
...
@@ -5,7 +5,6 @@ import (
"log"
"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/mitchellh/multistep"
awscommon
"github.com/mitchellh/packer/builder/amazon/common"
...
...
@@ -52,12 +51,12 @@ func (s *StepCreateVolume) Run(state multistep.StateBag) multistep.StepAction {
}
createVolume
:=
&
ec2
.
CreateVolumeInput
{
AvailabilityZone
:
instance
.
Placement
.
AvailabilityZone
,
Size
:
aws
.
Long
(
vs
),
Size
:
aws
.
Int64
(
vs
),
SnapshotID
:
rootDevice
.
EBS
.
SnapshotID
,
VolumeType
:
rootDevice
.
EBS
.
VolumeType
,
IOPS
:
rootDevice
.
EBS
.
IOPS
,
}
log
.
Printf
(
"Create args: %s"
,
awsutil
.
StringValue
(
createVolume
)
)
log
.
Printf
(
"Create args: %s"
,
createVolume
)
createVolumeResp
,
err
:=
ec2conn
.
CreateVolume
(
createVolume
)
if
err
!=
nil
{
...
...
builder/amazon/chroot/step_register_ami.go
View file @
68a6a0df
...
...
@@ -34,7 +34,7 @@ func (s *StepRegisterAMI) Run(state multistep.StateBag) multistep.StepAction {
}
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 {
// Set the AMI ID in the state
ui
.
Say
(
fmt
.
Sprintf
(
"AMI: %s"
,
*
registerResp
.
ImageID
))
amis
:=
make
(
map
[
string
]
string
)
amis
[
ec2conn
.
Config
.
Region
]
=
*
registerResp
.
ImageID
amis
[
*
ec2conn
.
Config
.
Region
]
=
*
registerResp
.
ImageID
state
.
Put
(
"amis"
,
amis
)
// Wait for the image to become ready
...
...
builder/amazon/common/access_config.go
View file @
68a6a0df
...
...
@@ -40,9 +40,9 @@ func (c *AccessConfig) Config() (*aws.Config, error) {
}
return
&
aws
.
Config
{
Region
:
region
,
Region
:
aws
.
String
(
region
)
,
Credentials
:
creds
,
MaxRetries
:
11
,
MaxRetries
:
aws
.
Int
(
11
)
,
},
nil
}
...
...
builder/amazon/common/artifact.go
View file @
68a6a0df
...
...
@@ -70,7 +70,7 @@ func (a *Artifact) Destroy() error {
regionConfig
:=
&
aws
.
Config
{
Credentials
:
a
.
Conn
.
Config
.
Credentials
,
Region
:
region
,
Region
:
aws
.
String
(
region
)
,
}
regionConn
:=
ec2
.
New
(
regionConfig
)
...
...
builder/amazon/common/block_device.go
View file @
68a6a0df
...
...
@@ -32,20 +32,20 @@ func buildBlockDevices(b []BlockDevice) []*ec2.BlockDeviceMapping {
for
_
,
blockDevice
:=
range
b
{
ebsBlockDevice
:=
&
ec2
.
EBSBlockDevice
{
VolumeType
:
aws
.
String
(
blockDevice
.
VolumeType
),
VolumeSize
:
aws
.
Long
(
blockDevice
.
VolumeSize
),
DeleteOnTermination
:
aws
.
Bool
ean
(
blockDevice
.
DeleteOnTermination
),
VolumeSize
:
aws
.
Int64
(
blockDevice
.
VolumeSize
),
DeleteOnTermination
:
aws
.
Bool
(
blockDevice
.
DeleteOnTermination
),
}
// IOPS is only valid for SSD Volumes
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
if
blockDevice
.
SnapshotId
!=
""
{
ebsBlockDevice
.
SnapshotID
=
aws
.
String
(
blockDevice
.
SnapshotId
)
}
else
if
blockDevice
.
Encrypted
{
ebsBlockDevice
.
Encrypted
=
aws
.
Bool
ean
(
blockDevice
.
Encrypted
)
ebsBlockDevice
.
Encrypted
=
aws
.
Bool
(
blockDevice
.
Encrypted
)
}
mapping
:=
&
ec2
.
BlockDeviceMapping
{
...
...
builder/amazon/common/block_device_test.go
View file @
68a6a0df
...
...
@@ -5,7 +5,6 @@ import (
"testing"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awsutil"
"github.com/aws/aws-sdk-go/service/ec2"
)
...
...
@@ -29,8 +28,8 @@ func TestBlockDevice(t *testing.T) {
EBS
:
&
ec2
.
EBSBlockDevice
{
SnapshotID
:
aws
.
String
(
"snap-1234"
),
VolumeType
:
aws
.
String
(
"standard"
),
VolumeSize
:
aws
.
Long
(
8
),
DeleteOnTermination
:
aws
.
Bool
ean
(
true
),
VolumeSize
:
aws
.
Int64
(
8
),
DeleteOnTermination
:
aws
.
Bool
(
true
),
},
},
},
...
...
@@ -45,8 +44,8 @@ func TestBlockDevice(t *testing.T) {
VirtualName
:
aws
.
String
(
""
),
EBS
:
&
ec2
.
EBSBlockDevice
{
VolumeType
:
aws
.
String
(
""
),
VolumeSize
:
aws
.
Long
(
8
),
DeleteOnTermination
:
aws
.
Bool
ean
(
false
),
VolumeSize
:
aws
.
Int64
(
8
),
DeleteOnTermination
:
aws
.
Bool
(
false
),
},
},
},
...
...
@@ -64,9 +63,9 @@ func TestBlockDevice(t *testing.T) {
VirtualName
:
aws
.
String
(
""
),
EBS
:
&
ec2
.
EBSBlockDevice
{
VolumeType
:
aws
.
String
(
"io1"
),
VolumeSize
:
aws
.
Long
(
8
),
DeleteOnTermination
:
aws
.
Bool
ean
(
true
),
IOPS
:
aws
.
Long
(
1000
),
VolumeSize
:
aws
.
Int64
(
8
),
DeleteOnTermination
:
aws
.
Bool
(
true
),
IOPS
:
aws
.
Int64
(
1000
),
},
},
},
...
...
@@ -93,13 +92,13 @@ func TestBlockDevice(t *testing.T) {
got
:=
blockDevices
.
BuildAMIDevices
()
if
!
reflect
.
DeepEqual
(
expected
,
got
)
{
t
.
Fatalf
(
"Bad block device,
\n
expected: %s
\n\n
got: %s"
,
awsutil
.
StringValue
(
expected
),
awsutil
.
StringValue
(
got
)
)
expected
,
got
)
}
if
!
reflect
.
DeepEqual
(
expected
,
blockDevices
.
BuildLaunchDevices
())
{
t
.
Fatalf
(
"Bad block device,
\n
expected: %s
\n\n
got: %s"
,
awsutil
.
StringValue
(
expected
)
,
awsutil
.
StringValue
(
blockDevices
.
BuildLaunchDevices
()
))
expected
,
blockDevices
.
BuildLaunchDevices
(
))
}
}
}
builder/amazon/common/step_ami_region_copy.go
View file @
68a6a0df
...
...
@@ -5,6 +5,7 @@ import (
"sync"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/ec2"
"github.com/mitchellh/multistep"
...
...
@@ -21,7 +22,7 @@ func (s *StepAMIRegionCopy) Run(state multistep.StateBag) multistep.StepAction {
ec2conn
:=
state
.
Get
(
"ec2"
)
.
(
*
ec2
.
EC2
)
ui
:=
state
.
Get
(
"ui"
)
.
(
packer
.
Ui
)
amis
:=
state
.
Get
(
"amis"
)
.
(
map
[
string
]
string
)
ami
:=
amis
[
ec2conn
.
Config
.
Region
]
ami
:=
amis
[
*
ec2conn
.
Config
.
Region
]
if
len
(
s
.
Regions
)
==
0
{
return
multistep
.
ActionContinue
...
...
@@ -33,7 +34,7 @@ func (s *StepAMIRegionCopy) Run(state multistep.StateBag) multistep.StepAction {
var
wg
sync
.
WaitGroup
errs
:=
new
(
packer
.
MultiError
)
for
_
,
region
:=
range
s
.
Regions
{
if
region
==
ec2conn
.
Config
.
Region
{
if
region
==
*
ec2conn
.
Config
.
Region
{
ui
.
Message
(
fmt
.
Sprintf
(
"Avoiding copying AMI to duplicate region %s"
,
region
))
continue
...
...
@@ -44,7 +45,7 @@ func (s *StepAMIRegionCopy) Run(state multistep.StateBag) multistep.StepAction {
go
func
(
region
string
)
{
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
()
defer
lock
.
Unlock
()
...
...
@@ -84,7 +85,7 @@ func amiRegionCopy(state multistep.StateBag, config *AccessConfig, name string,
if
err
!=
nil
{
return
""
,
err
}
awsConfig
.
Region
=
target
awsConfig
.
Region
=
aws
.
String
(
target
)
regionconn
:=
ec2
.
New
(
awsConfig
)
resp
,
err
:=
regionconn
.
CopyImage
(
&
ec2
.
CopyImageInput
{
...
...
builder/amazon/common/step_create_tags.go
View file @
68a6a0df
...
...
@@ -36,7 +36,7 @@ func (s *StepCreateTags) Run(state multistep.StateBag) multistep.StepAction {
regionconn
:=
ec2
.
New
(
&
aws
.
Config
{
Credentials
:
ec2conn
.
Config
.
Credentials
,
Region
:
region
,
Region
:
aws
.
String
(
region
)
,
})
// Retrieve image list for given AMI
...
...
builder/amazon/common/step_modify_ami_attributes.go
View file @
68a6a0df
...
...
@@ -90,7 +90,7 @@ func (s *StepModifyAMIAttributes) Run(state multistep.StateBag) multistep.StepAc
ui
.
Say
(
fmt
.
Sprintf
(
"Modifying attributes on AMI (%s)..."
,
ami
))
regionconn
:=
ec2
.
New
(
&
aws
.
Config
{
Credentials
:
ec2conn
.
Config
.
Credentials
,
Region
:
region
,
Region
:
aws
.
String
(
region
)
,
})
for
name
,
input
:=
range
options
{
ui
.
Message
(
fmt
.
Sprintf
(
"Modifying: %s"
,
name
))
...
...
builder/amazon/common/step_run_source_instance.go
View file @
68a6a0df
...
...
@@ -141,8 +141,8 @@ func (s *StepRunSourceInstance) Run(state multistep.StateBag) multistep.StepActi
ImageID
:
&
s
.
SourceAMI
,
InstanceType
:
&
s
.
InstanceType
,
UserData
:
&
userData
,
MaxCount
:
aws
.
Long
(
1
),
MinCount
:
aws
.
Long
(
1
),
MaxCount
:
aws
.
Int64
(
1
),
MinCount
:
aws
.
Int64
(
1
),
IAMInstanceProfile
:
&
ec2
.
IAMInstanceProfileSpecification
{
Name
:
&
s
.
IamInstanceProfile
},
BlockDeviceMappings
:
s
.
BlockDevices
.
BuildLaunchDevices
(),
Placement
:
&
ec2
.
Placement
{
AvailabilityZone
:
&
s
.
AvailabilityZone
},
...
...
@@ -151,11 +151,11 @@ func (s *StepRunSourceInstance) Run(state multistep.StateBag) multistep.StepActi
if
s
.
SubnetId
!=
""
&&
s
.
AssociatePublicIpAddress
{
runOpts
.
NetworkInterfaces
=
[]
*
ec2
.
InstanceNetworkInterfaceSpecification
{
&
ec2
.
InstanceNetworkInterfaceSpecification
{
DeviceIndex
:
aws
.
Long
(
0
),
DeviceIndex
:
aws
.
Int64
(
0
),
AssociatePublicIPAddress
:
&
s
.
AssociatePublicIpAddress
,
SubnetID
:
&
s
.
SubnetId
,
Groups
:
securityGroupIds
,
DeleteOnTermination
:
aws
.
Bool
ean
(
true
),
DeleteOnTermination
:
aws
.
Bool
(
true
),
},
}
}
else
{
...
...
@@ -185,11 +185,11 @@ func (s *StepRunSourceInstance) Run(state multistep.StateBag) multistep.StepActi
IAMInstanceProfile
:
&
ec2
.
IAMInstanceProfileSpecification
{
Name
:
&
s
.
IamInstanceProfile
},
NetworkInterfaces
:
[]
*
ec2
.
InstanceNetworkInterfaceSpecification
{
&
ec2
.
InstanceNetworkInterfaceSpecification
{
DeviceIndex
:
aws
.
Long
(
0
),
DeviceIndex
:
aws
.
Int64
(
0
),
AssociatePublicIPAddress
:
&
s
.
AssociatePublicIpAddress
,
SubnetID
:
&
s
.
SubnetId
,
Groups
:
securityGroupIds
,
DeleteOnTermination
:
aws
.
Bool
ean
(
true
),
DeleteOnTermination
:
aws
.
Bool
(
true
),
},
},
Placement
:
&
ec2
.
SpotPlacement
{
...
...
builder/amazon/common/step_security_group.go
View file @
68a6a0df
...
...
@@ -59,8 +59,8 @@ func (s *StepSecurityGroup) Run(state multistep.StateBag) multistep.StepAction {
req
:=
&
ec2
.
AuthorizeSecurityGroupIngressInput
{
GroupID
:
groupResp
.
GroupID
,
IPProtocol
:
aws
.
String
(
"tcp"
),
FromPort
:
aws
.
Long
(
int64
(
port
)),
ToPort
:
aws
.
Long
(
int64
(
port
)),
FromPort
:
aws
.
Int64
(
int64
(
port
)),
ToPort
:
aws
.
Int64
(
int64
(
port
)),
CIDRIP
:
aws
.
String
(
"0.0.0.0/0"
),
}
...
...
builder/amazon/ebs/step_create_ami.go
View file @
68a6a0df
...
...
@@ -38,7 +38,7 @@ func (s *stepCreateAMI) Run(state multistep.StateBag) multistep.StepAction {
// Set the AMI ID in the state
ui
.
Message
(
fmt
.
Sprintf
(
"AMI: %s"
,
*
createResp
.
ImageID
))
amis
:=
make
(
map
[
string
]
string
)
amis
[
ec2conn
.
Config
.
Region
]
=
*
createResp
.
ImageID
amis
[
*
ec2conn
.
Config
.
Region
]
=
*
createResp
.
ImageID
state
.
Put
(
"amis"
,
amis
)
// Wait for the image to become ready
...
...
builder/amazon/instance/step_register_ami.go
View file @
68a6a0df
...
...
@@ -44,7 +44,7 @@ func (s *StepRegisterAMI) Run(state multistep.StateBag) multistep.StepAction {
// Set the AMI ID in the state
ui
.
Say
(
fmt
.
Sprintf
(
"AMI: %s"
,
*
registerResp
.
ImageID
))
amis
:=
make
(
map
[
string
]
string
)
amis
[
ec2conn
.
Config
.
Region
]
=
*
registerResp
.
ImageID
amis
[
*
ec2conn
.
Config
.
Region
]
=
*
registerResp
.
ImageID
state
.
Put
(
"amis"
,
amis
)
// Wait for the image to become ready
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment