Make sure ami_regions are valid
This commit is contained in:
parent
228d0d593a
commit
c9de4c9644
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue