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
95dd7974
Commit
95dd7974
authored
Jun 29, 2015
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2324 from tcahill/group-launch-permissions
Fix setting ami_groups
parents
79de517e
6644d769
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
11 deletions
+32
-11
builder/amazon/common/step_modify_ami_attributes.go
builder/amazon/common/step_modify_ami_attributes.go
+13
-4
builder/amazon/ebs/builder_acc_test.go
builder/amazon/ebs/builder_acc_test.go
+19
-7
No files found.
builder/amazon/common/step_modify_ami_attributes.go
View file @
95dd7974
...
...
@@ -44,12 +44,21 @@ func (s *StepModifyAMIAttributes) Run(state multistep.StateBag) multistep.StepAc
if
len
(
s
.
Groups
)
>
0
{
groups
:=
make
([]
*
string
,
len
(
s
.
Groups
))
for
i
,
g
:=
range
s
.
Groups
{
groups
[
i
]
=
&
g
adds
:=
make
([]
*
ec2
.
LaunchPermission
,
len
(
s
.
Groups
))
addGroups
:=
&
ec2
.
ModifyImageAttributeInput
{
LaunchPermission
:
&
ec2
.
LaunchPermissionModifications
{},
}
options
[
"groups"
]
=
&
ec2
.
ModifyImageAttributeInput
{
UserGroups
:
groups
,
for
i
,
g
:=
range
s
.
Groups
{
groups
[
i
]
=
aws
.
String
(
g
)
adds
[
i
]
=
&
ec2
.
LaunchPermission
{
Group
:
aws
.
String
(
g
),
}
}
addGroups
.
UserGroups
=
groups
addGroups
.
LaunchPermission
.
Add
=
adds
options
[
"groups"
]
=
addGroups
}
if
len
(
s
.
Users
)
>
0
{
...
...
builder/amazon/ebs/builder_acc_test.go
View file @
95dd7974
...
...
@@ -50,11 +50,11 @@ func TestBuilderAcc_amiSharing(t *testing.T) {
PreCheck
:
func
()
{
testAccPreCheck
(
t
)
},
Builder
:
&
Builder
{},
Template
:
testBuilderAccSharing
,
Check
:
checkAMISharing
(
1
,
"932021504756
"
),
Check
:
checkAMISharing
(
2
,
"932021504756"
,
"all
"
),
})
}
func
checkAMISharing
(
count
int
,
uid
string
)
builderT
.
TestCheckFunc
{
func
checkAMISharing
(
count
int
,
uid
,
group
string
)
builderT
.
TestCheckFunc
{
return
func
(
artifacts
[]
packer
.
Artifact
)
error
{
if
len
(
artifacts
)
>
1
{
return
fmt
.
Errorf
(
"more than 1 artifact"
)
...
...
@@ -84,17 +84,28 @@ func checkAMISharing(count int, uid string) builderT.TestCheckFunc {
return
fmt
.
Errorf
(
"Error in Image Attributes, expected (%d) Launch Permissions, got (%d)"
,
count
,
len
(
imageResp
.
LaunchPermissions
))
}
f
ound
:=
false
userF
ound
:=
false
for
_
,
lp
:=
range
imageResp
.
LaunchPermissions
{
if
uid
==
*
lp
.
UserID
{
f
ound
=
true
if
lp
.
UserID
!=
nil
&&
uid
==
*
lp
.
UserID
{
userF
ound
=
true
}
}
if
!
f
ound
{
if
!
userF
ound
{
return
fmt
.
Errorf
(
"Error in Image Attributes, expected User ID (%s) to have Launch Permissions, but was not found"
,
uid
)
}
groupFound
:=
false
for
_
,
lp
:=
range
imageResp
.
LaunchPermissions
{
if
lp
.
Group
!=
nil
&&
group
==
*
lp
.
Group
{
groupFound
=
true
}
}
if
!
groupFound
{
return
fmt
.
Errorf
(
"Error in Image Attributes, expected Group ID (%s) to have Launch Permissions, but was not found"
,
group
)
}
return
nil
}
}
...
...
@@ -203,7 +214,8 @@ const testBuilderAccSharing = `
"source_ami": "ami-76b2a71e",
"ssh_username": "ubuntu",
"ami_name": "packer-test {{timestamp}}",
"ami_users":["932021504756"]
"ami_users":["932021504756"],
"ami_groups":["all"]
}]
}
`
...
...
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