Commit bf296b39 authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

builder/amazonebs: panics in edge cases

parent e629eef9
...@@ -47,7 +47,7 @@ func (b *Builder) Prepare(raw interface{}) (err error) { ...@@ -47,7 +47,7 @@ func (b *Builder) Prepare(raw interface{}) (err error) {
// TODO: config validation and asking for fields: // TODO: config validation and asking for fields:
// * access key // * access key
// * secret key // * secret key
// * region // * region (exists and valid)
// * source ami // * source ami
// * instance type // * instance type
// * SSH username // * SSH username
...@@ -57,8 +57,26 @@ func (b *Builder) Prepare(raw interface{}) (err error) { ...@@ -57,8 +57,26 @@ func (b *Builder) Prepare(raw interface{}) (err error) {
} }
func (b *Builder) Run(ui packer.Ui, hook packer.Hook) packer.Artifact { func (b *Builder) Run(ui packer.Ui, hook packer.Hook) packer.Artifact {
// Basic sanity checks. These are panics now because the Prepare
// method should verify these exist and such.
if b.config.AccessKey == "" {
panic("access key not filled in")
}
if b.config.SecretKey == "" {
panic("secret key not filled in")
}
if b.config.Region == "" {
panic("region not filled in")
}
region, ok := aws.Regions[b.config.Region]
if !ok {
panic("region not found")
}
auth := aws.Auth{b.config.AccessKey, b.config.SecretKey} auth := aws.Auth{b.config.AccessKey, b.config.SecretKey}
region := aws.Regions[b.config.Region]
ec2conn := ec2.New(auth, region) ec2conn := ec2.New(auth, region)
// Setup the state bag and initial state for the steps // Setup the state bag and initial state for the steps
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment