Make sure ami_regions are valid

This commit is contained in:
James Massara 2013-08-21 18:44:14 -07:00
parent 228d0d593a
commit c9de4c9644
1 changed files with 9 additions and 0 deletions

View File

@ -2,6 +2,7 @@ package common
import (
"fmt"
"github.com/mitchellh/goamz/aws"
"github.com/mitchellh/packer/packer"
)
@ -61,6 +62,14 @@ func (c *AMIConfig) Prepare(t *packer.ConfigTemplate) []error {
errs = append(errs, fmt.Errorf("ami_name must be specified"))
}
if len(c.AMIRegions) > 0 {
for _, region := range c.AMIRegions {
if _, ok := aws.Regions[region]; !ok {
errs = append(errs, fmt.Errorf("Unknown region: %s", region))
}
}
}
if len(errs) > 0 {
return errs
}