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
4f568f49
Commit
4f568f49
authored
Jul 20, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
builder/amazon: extract StepSecurityGroup
parent
45096d07
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
17 deletions
+26
-17
builder/amazon/common/step_security_group.go
builder/amazon/common/step_security_group.go
+18
-16
builder/amazon/ebs/builder.go
builder/amazon/ebs/builder.go
+4
-1
builder/amazon/instance/builder.go
builder/amazon/instance/builder.go
+4
-0
No files found.
builder/amazon/
ebs
/step_security_group.go
→
builder/amazon/
common
/step_security_group.go
View file @
4f568f49
package
ebs
package
common
import
(
"cgl.tideland.biz/identifier"
...
...
@@ -10,18 +10,20 @@ import (
"log"
)
type
stepSecurityGroup
struct
{
groupId
string
type
StepSecurityGroup
struct
{
SecurityGroupId
string
SSHPort
int
createdGroupId
string
}
func
(
s
*
stepSecurityGroup
)
Run
(
state
map
[
string
]
interface
{})
multistep
.
StepAction
{
config
:=
state
[
"config"
]
.
(
config
)
func
(
s
*
StepSecurityGroup
)
Run
(
state
map
[
string
]
interface
{})
multistep
.
StepAction
{
ec2conn
:=
state
[
"ec2"
]
.
(
*
ec2
.
EC2
)
ui
:=
state
[
"ui"
]
.
(
packer
.
Ui
)
if
config
.
SecurityGroupId
!=
""
{
log
.
Printf
(
"Using specified security group: %s"
,
config
.
SecurityGroupId
)
state
[
"securityGroupId"
]
=
config
.
SecurityGroupId
if
s
.
SecurityGroupId
!=
""
{
log
.
Printf
(
"Using specified security group: %s"
,
s
.
SecurityGroupId
)
state
[
"securityGroupId"
]
=
s
.
SecurityGroupId
return
multistep
.
ActionContinue
}
...
...
@@ -36,14 +38,14 @@ func (s *stepSecurityGroup) Run(state map[string]interface{}) multistep.StepActi
}
// Set the group ID so we can delete it later
s
.
g
roupId
=
groupResp
.
Id
s
.
createdG
roupId
=
groupResp
.
Id
// Authorize the SSH access
perms
:=
[]
ec2
.
IPPerm
{
ec2
.
IPPerm
{
Protocol
:
"tcp"
,
FromPort
:
config
.
SSHPort
,
ToPort
:
config
.
SSHPort
,
FromPort
:
s
.
SSHPort
,
ToPort
:
s
.
SSHPort
,
SourceIPs
:
[]
string
{
"0.0.0.0/0"
},
},
}
...
...
@@ -57,13 +59,13 @@ func (s *stepSecurityGroup) Run(state map[string]interface{}) multistep.StepActi
}
// Set some state data for use in future steps
state
[
"securityGroupId"
]
=
s
.
g
roupId
state
[
"securityGroupId"
]
=
s
.
createdG
roupId
return
multistep
.
ActionContinue
}
func
(
s
*
s
tepSecurityGroup
)
Cleanup
(
state
map
[
string
]
interface
{})
{
if
s
.
g
roupId
==
""
{
func
(
s
*
S
tepSecurityGroup
)
Cleanup
(
state
map
[
string
]
interface
{})
{
if
s
.
createdG
roupId
==
""
{
return
}
...
...
@@ -71,10 +73,10 @@ func (s *stepSecurityGroup) Cleanup(state map[string]interface{}) {
ui
:=
state
[
"ui"
]
.
(
packer
.
Ui
)
ui
.
Say
(
"Deleting temporary security group..."
)
_
,
err
:=
ec2conn
.
DeleteSecurityGroup
(
ec2
.
SecurityGroup
{
Id
:
s
.
g
roupId
})
_
,
err
:=
ec2conn
.
DeleteSecurityGroup
(
ec2
.
SecurityGroup
{
Id
:
s
.
createdG
roupId
})
if
err
!=
nil
{
log
.
Printf
(
"Error deleting security group: %s"
,
err
)
ui
.
Error
(
fmt
.
Sprintf
(
"Error cleaning up security group. Please delete the group manually: %s"
,
s
.
g
roupId
))
"Error cleaning up security group. Please delete the group manually: %s"
,
s
.
createdG
roupId
))
}
}
builder/amazon/ebs/builder.go
View file @
4f568f49
...
...
@@ -91,7 +91,10 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
// Build the steps
steps
:=
[]
multistep
.
Step
{
&
awscommon
.
StepKeyPair
{},
&
stepSecurityGroup
{},
&
awscommon
.
StepSecurityGroup
{
SecurityGroupId
:
b
.
config
.
SecurityGroupId
,
SSHPort
:
b
.
config
.
SSHPort
,
},
&
stepRunSourceInstance
{},
&
common
.
StepConnectSSH
{
SSHAddress
:
sshAddress
,
...
...
builder/amazon/instance/builder.go
View file @
4f568f49
...
...
@@ -70,6 +70,10 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
// Build the steps
steps
:=
[]
multistep
.
Step
{
&
awscommon
.
StepKeyPair
{},
&
awscommon
.
StepSecurityGroup
{
SecurityGroupId
:
b
.
config
.
SecurityGroupId
,
SSHPort
:
b
.
config
.
SSHPort
,
},
}
// Run!
...
...
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