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
8aabe01b
Commit
8aabe01b
authored
Dec 27, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
builder/amazon/common: run_tags to apply to launch [GH-722]
parent
4c8b8d4f
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
63 additions
and
23 deletions
+63
-23
CHANGELOG.md
CHANGELOG.md
+2
-0
builder/amazon/common/run_config.go
builder/amazon/common/run_config.go
+37
-15
builder/amazon/common/step_run_source_instance.go
builder/amazon/common/step_run_source_instance.go
+14
-8
builder/amazon/ebs/builder.go
builder/amazon/ebs/builder.go
+1
-0
builder/amazon/instance/builder.go
builder/amazon/instance/builder.go
+1
-0
website/source/docs/builders/amazon-ebs.html.markdown
website/source/docs/builders/amazon-ebs.html.markdown
+4
-0
website/source/docs/builders/amazon-instance.html.markdown
website/source/docs/builders/amazon-instance.html.markdown
+4
-0
No files found.
CHANGELOG.md
View file @
8aabe01b
...
...
@@ -47,6 +47,8 @@ IMPROVEMENTS:
"Packer Builder" so that they are easily recognizable. [GH-642]
*
builder/amazon/all: Copying AMIs to multiple regions now happens
in parallel. [GH-495]
*
builder/amazon/all: Ability to specify "run
\_
tags" to tag the instance
while running. [GH-722]
*
builder/digitalocean: Private networking support. [GH-698]
*
builder/docker: A "run
\_
command" can be specified, configuring how
the container is started. [GH-648]
...
...
builder/amazon/common/run_config.go
View file @
8aabe01b
...
...
@@ -15,6 +15,7 @@ type RunConfig struct {
AvailabilityZone
string
`mapstructure:"availability_zone"`
IamInstanceProfile
string
`mapstructure:"iam_instance_profile"`
InstanceType
string
`mapstructure:"instance_type"`
RunTags
map
[
string
]
string
`mapstructure:"run_tags"`
SourceAmi
string
`mapstructure:"source_ami"`
RawSSHTimeout
string
`mapstructure:"ssh_timeout"`
SSHUsername
string
`mapstructure:"ssh_username"`
...
...
@@ -121,6 +122,27 @@ func (c *RunConfig) Prepare(t *packer.ConfigTemplate) []error {
}
}
newTags
:=
make
(
map
[
string
]
string
)
for
k
,
v
:=
range
c
.
RunTags
{
k
,
err
:=
t
.
Process
(
k
,
nil
)
if
err
!=
nil
{
errs
=
append
(
errs
,
fmt
.
Errorf
(
"Error processing tag key %s: %s"
,
k
,
err
))
continue
}
v
,
err
:=
t
.
Process
(
v
,
nil
)
if
err
!=
nil
{
errs
=
append
(
errs
,
fmt
.
Errorf
(
"Error processing tag value '%s': %s"
,
v
,
err
))
continue
}
newTags
[
k
]
=
v
}
c
.
RunTags
=
newTags
c
.
sshTimeout
,
err
=
time
.
ParseDuration
(
c
.
RawSSHTimeout
)
if
err
!=
nil
{
errs
=
append
(
errs
,
fmt
.
Errorf
(
"Failed parsing ssh_timeout: %s"
,
err
))
...
...
builder/amazon/common/step_run_source_instance.go
View file @
8aabe01b
...
...
@@ -9,17 +9,18 @@ import (
)
type
StepRunSourceInstance
struct
{
AssociatePublicIpAddress
bool
AvailabilityZone
string
BlockDevices
BlockDevices
Debug
bool
ExpectedRootDevice
string
InstanceType
string
UserData
string
UserDataFile
string
SourceAMI
string
IamInstanceProfile
string
SourceAMI
string
SubnetId
string
AssociatePublicIpAddress
bool
AvailabilityZone
string
BlockDevices
BlockDevices
Tags
map
[
string
]
string
UserData
string
UserDataFile
string
instance
*
ec2
.
Instance
}
...
...
@@ -92,8 +93,13 @@ func (s *StepRunSourceInstance) Run(state multistep.StateBag) multistep.StepActi
s
.
instance
=
&
runResp
.
Instances
[
0
]
ui
.
Message
(
fmt
.
Sprintf
(
"Instance ID: %s"
,
s
.
instance
.
InstanceId
))
_
,
err
=
ec2conn
.
CreateTags
(
[]
string
{
s
.
instance
.
InstanceId
},
[]
ec2
.
Tag
{{
"Name"
,
"Packer Builder"
}})
ec2Tags
:=
make
([]
ec2
.
Tag
,
1
,
len
(
s
.
Tags
)
+
1
)
ec2Tags
[
0
]
=
ec2
.
Tag
{
"Name"
,
"Packer Builder"
}
for
k
,
v
:=
range
s
.
Tags
{
ec2Tags
=
append
(
ec2Tags
,
ec2
.
Tag
{
k
,
v
})
}
_
,
err
=
ec2conn
.
CreateTags
([]
string
{
s
.
instance
.
InstanceId
},
ec2Tags
)
if
err
!=
nil
{
ui
.
Message
(
fmt
.
Sprintf
(
"Failed to tag a Name on the builder instance: %s"
,
err
))
...
...
builder/amazon/ebs/builder.go
View file @
8aabe01b
...
...
@@ -104,6 +104,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
AssociatePublicIpAddress
:
b
.
config
.
AssociatePublicIpAddress
,
AvailabilityZone
:
b
.
config
.
AvailabilityZone
,
BlockDevices
:
b
.
config
.
BlockDevices
,
Tags
:
b
.
config
.
RunTags
,
},
&
common
.
StepConnectSSH
{
SSHAddress
:
awscommon
.
SSHAddress
(
ec2conn
,
b
.
config
.
SSHPort
),
...
...
builder/amazon/instance/builder.go
View file @
8aabe01b
...
...
@@ -208,6 +208,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
AssociatePublicIpAddress
:
b
.
config
.
AssociatePublicIpAddress
,
AvailabilityZone
:
b
.
config
.
AvailabilityZone
,
BlockDevices
:
b
.
config
.
BlockDevices
,
Tags
:
b
.
config
.
RunTags
,
},
&
common
.
StepConnectSSH
{
SSHAddress
:
awscommon
.
SSHAddress
(
ec2conn
,
b
.
config
.
SSHPort
),
...
...
website/source/docs/builders/amazon-ebs.html.markdown
View file @
8aabe01b
...
...
@@ -91,6 +91,10 @@ Optional:
block device mappings to the launch instance. The block device mappings are
the same as
`ami_block_device_mappings`
above.
*
`run_tags`
(object of key/value strings) - Tags to apply to the instance
that is _launched_ to create the AMI. These tags are _not_ applied to
the resulting AMI unless they're duplicated in
`tags`
.
*
`security_group_id`
(string) - The ID (_not_ the name) of the security
group to assign to the instance. By default this is not set and Packer
will automatically create a new temporary security group to allow SSH
...
...
website/source/docs/builders/amazon-instance.html.markdown
View file @
8aabe01b
...
...
@@ -130,6 +130,10 @@ Optional:
block device mappings to the launch instance. The block device mappings are
the same as
`ami_block_device_mappings`
above.
*
`run_tags`
(object of key/value strings) - Tags to apply to the instance
that is _launched_ to create the AMI. These tags are _not_ applied to
the resulting AMI unless they're duplicated in
`tags`
.
*
`security_group_id`
(string) - The ID (_not_ the name) of the security
group to assign to the instance. By default this is not set and Packer
will automatically create a new temporary security group to allow SSH
...
...
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