aws: document ValidateRegion better

This commit is contained in:
Adrien Delorme 2018-11-26 11:33:20 +01:00
parent 6af621c37a
commit ce8532e94b
1 changed files with 5 additions and 3 deletions

View File

@ -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
}