|
|
|
|
@ -38,12 +38,23 @@ func stringInSlice(s []string, searchstr string) bool {
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (c *AMIConfig) Prepare(ctx *interpolate.Context) []error {
|
|
|
|
|
func (c *AMIConfig) Prepare(accessConfig *AccessConfig, ctx *interpolate.Context) []error {
|
|
|
|
|
var errs []error
|
|
|
|
|
|
|
|
|
|
session, err := accessConfig.Session()
|
|
|
|
|
if err != nil {
|
|
|
|
|
errs = append(errs, err)
|
|
|
|
|
}
|
|
|
|
|
region := *session.Config.Region
|
|
|
|
|
|
|
|
|
|
if c.AMIName == "" {
|
|
|
|
|
errs = append(errs, fmt.Errorf("ami_name must be specified"))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if stringInSlice(c.AMIRegions, region) {
|
|
|
|
|
errs = append(errs, fmt.Errorf("Cannot copy AMI to AWS session region '%s', please remove it from `ami_regions`.", region))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if len(c.AMIRegions) > 0 {
|
|
|
|
|
regionSet := make(map[string]struct{})
|
|
|
|
|
regions := make([]string, 0, len(c.AMIRegions))
|
|
|
|
|
@ -61,7 +72,6 @@ func (c *AMIConfig) Prepare(ctx *interpolate.Context) []error {
|
|
|
|
|
// Verify the region is real
|
|
|
|
|
if valid := ValidateRegion(region); !valid {
|
|
|
|
|
errs = append(errs, fmt.Errorf("Unknown region: %s", region))
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|