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
4fc76443
Commit
4fc76443
authored
May 10, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
builder/amazonebs: Wait for AMI to become ready
parent
e071739c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
1 deletion
+16
-1
builder/amazonebs/builder.go
builder/amazonebs/builder.go
+16
-1
No files found.
builder/amazonebs/builder.go
View file @
4fc76443
...
...
@@ -17,6 +17,7 @@ import (
type
config
struct
{
AccessKey
string
`json:"access_key"`
AMIName
string
`json:"ami_name"`
Region
string
SecretKey
string
`json:"secret_key"`
SourceAmi
string
`json:"source_ami"`
...
...
@@ -96,7 +97,7 @@ func (b *Builder) Run(build packer.Build, ui packer.Ui) {
ui
.
Say
(
"Creating the AMI...
\n
"
)
createOpts
:=
&
ec2
.
CreateImage
{
InstanceId
:
instance
.
InstanceId
,
Name
:
"ZIMAGINE"
,
Name
:
b
.
config
.
AMIName
,
}
createResp
,
err
:=
ec2conn
.
CreateImage
(
createOpts
)
...
...
@@ -107,6 +108,20 @@ func (b *Builder) Run(build packer.Build, ui packer.Ui) {
ui
.
Say
(
"AMI: %s
\n
"
,
createResp
.
ImageId
)
// Wait for the image to become ready
ui
.
Say
(
"Waiting for AMI to become ready...
\n
"
)
for
{
imageResp
,
err
:=
ec2conn
.
Images
([]
string
{
createResp
.
ImageId
},
ec2
.
NewFilter
())
if
err
!=
nil
{
ui
.
Error
(
"%s
\n
"
,
err
.
Error
())
return
}
if
imageResp
.
Images
[
0
]
.
State
==
"available"
{
break
}
}
// Make sure we clean up the instance by terminating it, no matter what
defer
func
()
{
// TODO: error handling
...
...
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