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
413fc1b7
Commit
413fc1b7
authored
Aug 06, 2013
by
Mark Peek
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #233 from jmassara/tags
builder/amazon/ebs: Added tagging support for amazon/ebs AMIs
parents
7af60a88
fffce95c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
3 deletions
+40
-3
builder/amazon/ebs/builder.go
builder/amazon/ebs/builder.go
+18
-1
builder/amazon/ebs/step_create_ami.go
builder/amazon/ebs/step_create_ami.go
+15
-1
website/source/docs/builders/amazon-ebs.html.markdown
website/source/docs/builders/amazon-ebs.html.markdown
+7
-1
No files found.
builder/amazon/ebs/builder.go
View file @
413fc1b7
...
...
@@ -27,6 +27,12 @@ type config struct {
// Configuration of the resulting AMI
AMIName
string
`mapstructure:"ami_name"`
// Tags for the AMI
Tags
map
[
string
]
string
// Unexported fields that are calculated from others
ec2Tags
[]
ec2
.
Tag
}
type
Builder
struct
{
...
...
@@ -57,6 +63,15 @@ func (b *Builder) Prepare(raws ...interface{}) error {
}
}
// Convert Tags to ec2.Tag
if
b
.
config
.
Tags
!=
nil
{
var
ec2Tags
[]
ec2
.
Tag
for
key
,
value
:=
range
b
.
config
.
Tags
{
ec2Tags
=
append
(
ec2Tags
,
ec2
.
Tag
{
key
,
value
})
}
b
.
config
.
ec2Tags
=
ec2Tags
}
if
errs
!=
nil
&&
len
(
errs
.
Errors
)
>
0
{
return
errs
}
...
...
@@ -107,7 +122,9 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
},
&
common
.
StepProvision
{},
&
stepStopInstance
{},
&
stepCreateAMI
{},
&
stepCreateAMI
{
Tags
:
b
.
config
.
ec2Tags
,
},
}
// Run!
...
...
builder/amazon/ebs/step_create_ami.go
View file @
413fc1b7
...
...
@@ -12,7 +12,9 @@ import (
"time"
)
type
stepCreateAMI
struct
{}
type
stepCreateAMI
struct
{
Tags
[]
ec2
.
Tag
}
type
amiNameData
struct
{
CreateTime
string
...
...
@@ -64,6 +66,18 @@ func (s *stepCreateAMI) Run(state map[string]interface{}) multistep.StepAction {
return
multistep
.
ActionHalt
}
// Add tags to AMI
if
s
.
Tags
!=
nil
{
ui
.
Say
(
fmt
.
Sprintf
(
"Adding tags to AMI (%s)..."
,
createResp
.
ImageId
))
_
,
err
:=
ec2conn
.
CreateTags
([]
string
{
createResp
.
ImageId
},
s
.
Tags
)
if
err
!=
nil
{
err
:=
fmt
.
Errorf
(
"Error adding tags to AMI (%s): %s"
,
createResp
.
ImageId
,
err
)
state
[
"error"
]
=
err
ui
.
Error
(
err
.
Error
())
return
multistep
.
ActionHalt
}
}
return
multistep
.
ActionContinue
}
...
...
website/source/docs/builders/amazon-ebs.html.markdown
View file @
413fc1b7
...
...
@@ -81,6 +81,8 @@ Optional:
*
`vpc_id`
(string) - If launching into a VPC subnet, Packer needs the
VPC ID in order to create a temporary security group within the VPC.
*
`tags`
(array of key/value pairs) - Tags applied to the AMI.
## Basic Example
Here is a basic example. It is completely valid except for the access keys:
...
...
@@ -94,7 +96,11 @@ Here is a basic example. It is completely valid except for the access keys:
"source_ami": "ami-de0d9eb7",
"instance_type": "t1.micro",
"ssh_username": "ubuntu",
"ami_name": "packer-quick-start {{.CreateTime}}"
"ami_name": "packer-quick-start {{.CreateTime}}",
"tags": {
"myTagName1": "myTagValue1",
"myTagName2": "myTagValue2"
}
}
</pre>
...
...
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