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
dcfbef4f
Commit
dcfbef4f
authored
Aug 08, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
builder/amazon/common: use new API for goamz to set AMI attributes
/cc @jmassara
parent
2ba59617
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
40 deletions
+12
-40
builder/amazon/common/step_modify_attributes.go
builder/amazon/common/step_modify_attributes.go
+12
-40
No files found.
builder/amazon/common/step_modify_attributes.go
View file @
dcfbef4f
...
...
@@ -20,48 +20,20 @@ func (s *StepModifyAttributes) Run(state map[string]interface{}) multistep.StepA
amis
:=
state
[
"amis"
]
.
(
map
[
string
]
string
)
ami
:=
amis
[
ec2conn
.
Region
.
Name
]
if
s
.
Description
!=
""
{
ui
.
Say
(
fmt
.
Sprintf
(
"Setting Description of AMI (%s) to '%s'..."
,
ami
,
s
.
Description
))
_
,
err
:=
ec2conn
.
ModifyImageAttribute
(
ami
,
&
ec2
.
ModifyImageAttribute
{
Attribute
:
ec2
.
DescriptionAttribute
,
Description
:
s
.
Description
,
})
if
err
!=
nil
{
err
:=
fmt
.
Errorf
(
"Error setting Description of AMI (%s): %s"
,
ami
,
err
)
state
[
"error"
]
=
err
ui
.
Error
(
err
.
Error
())
return
multistep
.
ActionHalt
}
options
:=
&
ec2
.
ModifyImageAttribute
{
Description
:
s
.
Description
,
AddUsers
:
s
.
Users
,
AddGroups
:
s
.
Groups
,
ProductCodes
:
s
.
ProductCodes
,
}
if
len
(
s
.
Users
)
>
0
||
len
(
s
.
Groups
)
>
0
{
ui
.
Say
(
fmt
.
Sprintf
(
"Setting Launch Permissions for AMI (%s)..."
,
ami
))
_
,
err
:=
ec2conn
.
ModifyImageAttribute
(
ami
,
&
ec2
.
ModifyImageAttribute
{
Attribute
:
ec2
.
LaunchPermissionAttribute
,
Operation
:
ec2
.
LaunchPermissionAdd
,
Users
:
s
.
Users
,
Groups
:
s
.
Groups
,
})
if
err
!=
nil
{
err
:=
fmt
.
Errorf
(
"Error setting Launch Permissions for AMI (%s): %s"
,
ami
,
err
)
state
[
"error"
]
=
err
ui
.
Error
(
err
.
Error
())
return
multistep
.
ActionHalt
}
}
if
len
(
s
.
ProductCodes
)
>
0
{
ui
.
Say
(
fmt
.
Sprintf
(
"Setting Product Code(s) for AMI (%s)..."
,
ami
))
_
,
err
:=
ec2conn
.
ModifyImageAttribute
(
ami
,
&
ec2
.
ModifyImageAttribute
{
Attribute
:
ec2
.
ProductCodeAttribute
,
ProductCodes
:
s
.
ProductCodes
,
})
if
err
!=
nil
{
err
:=
fmt
.
Errorf
(
"Error setting Product Code(s) for AMI (%s): %s"
,
ami
,
err
)
state
[
"error"
]
=
err
ui
.
Error
(
err
.
Error
())
return
multistep
.
ActionHalt
}
ui
.
Say
(
"Modifying AMI attributes..."
)
_
,
err
:=
ec2conn
.
ModifyImageAttribute
(
ami
,
options
)
if
err
!=
nil
{
err
:=
fmt
.
Errorf
(
"Error modify AMI attributes: %s"
,
err
)
state
[
"error"
]
=
err
ui
.
Error
(
err
.
Error
())
return
multistep
.
ActionHalt
}
return
multistep
.
ActionContinue
...
...
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