From ce8532e94bf9e84c9fcc16cf18dc1313b9d1b2f0 Mon Sep 17 00:00:00 2001 From: Adrien Delorme Date: Mon, 26 Nov 2018 11:33:20 +0100 Subject: [PATCH] aws: document ValidateRegion better --- builder/amazon/common/regions.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/builder/amazon/common/regions.go b/builder/amazon/common/regions.go index 773e8ad33..24344c726 100644 --- a/builder/amazon/common/regions.go +++ b/builder/amazon/common/regions.go @@ -19,8 +19,10 @@ func listEC2Regions(ec2conn ec2iface.EC2API) ([]string, error) { return regions, nil } -// ValidateRegion returns true if the supplied region is a valid AWS -// region and false if it's not. +// ValidateRegion returns an nil if the regions are valid +// and exists; otherwise an error. +// ValidateRegion calls ec2conn.DescribeRegions to get the list of +// regions available to this account. func (c *AccessConfig) ValidateRegion(regions ...string) error { ec2conn, err := c.NewEC2Connection() if err != nil { @@ -50,7 +52,7 @@ func (c *AccessConfig) ValidateRegion(regions ...string) error { } if len(invalidRegions) > 0 { - return fmt.Errorf("Invalid region(s): %v", invalidRegions) + return fmt.Errorf("Invalid region(s): %v, available regions: %v", invalidRegions, validRegions) } return nil }