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
b31534d5
Commit
b31534d5
authored
Jun 09, 2015
by
Clint
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2197 from mitchellh/f-aws-fixup-ebs-snapshots
Update AWS EBS builder to fix invalid params
parents
f3aed781
4da118c6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
6 deletions
+37
-6
builder/amazon/common/block_device.go
builder/amazon/common/block_device.go
+13
-3
builder/amazon/common/block_device_test.go
builder/amazon/common/block_device_test.go
+24
-3
No files found.
builder/amazon/common/block_device.go
View file @
b31534d5
...
...
@@ -29,13 +29,23 @@ func buildBlockDevices(b []BlockDevice) []*ec2.BlockDeviceMapping {
for
_
,
blockDevice
:=
range
b
{
ebsBlockDevice
:=
&
ec2
.
EBSBlockDevice
{
SnapshotID
:
&
blockDevice
.
SnapshotId
,
Encrypted
:
&
blockDevice
.
Encrypted
,
IOPS
:
&
blockDevice
.
IOPS
,
VolumeType
:
&
blockDevice
.
VolumeType
,
VolumeSize
:
&
blockDevice
.
VolumeSize
,
DeleteOnTermination
:
&
blockDevice
.
DeleteOnTermination
,
}
// IOPS is only valid for SSD Volumes
if
blockDevice
.
VolumeType
!=
"standard"
&&
blockDevice
.
VolumeType
!=
"gp2"
{
ebsBlockDevice
.
IOPS
=
&
blockDevice
.
IOPS
}
// You cannot specify Encrypted if you specify a Snapshot ID
if
blockDevice
.
SnapshotId
!=
""
{
ebsBlockDevice
.
SnapshotID
=
&
blockDevice
.
SnapshotId
}
else
{
ebsBlockDevice
.
Encrypted
=
&
blockDevice
.
Encrypted
}
mapping
:=
&
ec2
.
BlockDeviceMapping
{
EBS
:
ebsBlockDevice
,
DeviceName
:
&
blockDevice
.
DeviceName
,
...
...
builder/amazon/common/block_device_test.go
View file @
b31534d5
...
...
@@ -5,6 +5,7 @@ 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"
)
...
...
@@ -28,11 +29,31 @@ func TestBlockDevice(t *testing.T) {
DeviceName
:
aws
.
String
(
"/dev/sdb"
),
VirtualName
:
aws
.
String
(
"ephemeral0"
),
EBS
:
&
ec2
.
EBSBlockDevice
{
Encrypted
:
aws
.
Boolean
(
false
),
SnapshotID
:
aws
.
String
(
"snap-1234"
),
VolumeType
:
aws
.
String
(
"standard"
),
VolumeSize
:
aws
.
Long
(
8
),
DeleteOnTermination
:
aws
.
Boolean
(
true
),
},
},
},
{
Config
:
&
BlockDevice
{
DeviceName
:
"/dev/sdb"
,
VirtualName
:
"ephemeral0"
,
VolumeType
:
"io1"
,
VolumeSize
:
8
,
DeleteOnTermination
:
true
,
IOPS
:
1000
,
},
Result
:
&
ec2
.
BlockDeviceMapping
{
DeviceName
:
aws
.
String
(
"/dev/sdb"
),
VirtualName
:
aws
.
String
(
"ephemeral0"
),
EBS
:
&
ec2
.
EBSBlockDevice
{
Encrypted
:
aws
.
Boolean
(
false
),
VolumeType
:
aws
.
String
(
"io1"
),
VolumeSize
:
aws
.
Long
(
8
),
DeleteOnTermination
:
aws
.
Boolean
(
true
),
IOPS
:
aws
.
Long
(
1000
),
},
},
...
...
@@ -48,11 +69,11 @@ func TestBlockDevice(t *testing.T) {
expected
:=
[]
*
ec2
.
BlockDeviceMapping
{
tc
.
Result
}
got
:=
blockDevices
.
BuildAMIDevices
()
if
!
reflect
.
DeepEqual
(
expected
,
got
)
{
t
.
Fatalf
(
"
bad: %#v"
,
expected
)
t
.
Fatalf
(
"
Bad block device,
\n
expected: %s
\n\n
got: %s"
,
awsutil
.
StringValue
(
expected
),
awsutil
.
StringValue
(
got
)
)
}
if
!
reflect
.
DeepEqual
(
expected
,
blockDevices
.
BuildLaunchDevices
())
{
t
.
Fatalf
(
"
bad: %#v"
,
expected
)
t
.
Fatalf
(
"
Bad block device,
\n
expected: %s
\n\n
got: %s"
,
awsutil
.
StringValue
(
expected
),
awsutil
.
StringValue
(
blockDevices
.
BuildLaunchDevices
())
)
}
}
}
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