move region validation to run so that we don't break validation when we don't have aws creds set
This commit is contained in:
parent
fbde30c8c0
commit
fbb3d526e3
|
@ -162,13 +162,6 @@ func (c *AccessConfig) Prepare(ctx *interpolate.Context) []error {
|
|||
fmt.Errorf("`access_key` and `secret_key` must both be either set or not set."))
|
||||
}
|
||||
|
||||
if c.RawRegion != "" && !c.SkipValidation {
|
||||
err := c.ValidateRegion(c.RawRegion)
|
||||
if err != nil {
|
||||
errs = append(errs, fmt.Errorf("error validating region: %s", err.Error()))
|
||||
}
|
||||
}
|
||||
|
||||
return errs
|
||||
}
|
||||
|
||||
|
|
|
@ -96,14 +96,6 @@ func (c *AMIConfig) Prepare(accessConfig *AccessConfig, ctx *interpolate.Context
|
|||
|
||||
func (c *AMIConfig) prepareRegions(accessConfig *AccessConfig) (errs []error) {
|
||||
if len(c.AMIRegions) > 0 {
|
||||
if !c.AMISkipRegionValidation {
|
||||
// Verify the regions are real
|
||||
err := accessConfig.ValidateRegion(c.AMIRegions...)
|
||||
if err != nil {
|
||||
errs = append(errs, fmt.Errorf("error validating regions: %v", err))
|
||||
}
|
||||
}
|
||||
|
||||
regionSet := make(map[string]struct{})
|
||||
regions := make([]string, 0, len(c.AMIRegions))
|
||||
|
||||
|
|
|
@ -86,11 +86,17 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) {
|
|||
}
|
||||
|
||||
func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packer.Artifact, error) {
|
||||
|
||||
session, err := b.config.Session()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !b.config.AMISkipRegionValidation {
|
||||
regionsToValidate := append(b.config.AMIRegions, b.config.RawRegion)
|
||||
err := b.config.AccessConfig.ValidateRegion(regionsToValidate...)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error validating regions: %v", err)
|
||||
}
|
||||
}
|
||||
ec2conn := ec2.New(session)
|
||||
|
||||
// Setup the state bag and initial state for the steps
|
||||
|
|
Loading…
Reference in New Issue