forked from docker/machine
/
utils.go
51 lines (42 loc) · 1.13 KB
/
utils.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package amazonec2
import (
"errors"
)
var (
errInvalidRegion = errors.New("invalid region specified")
errNoVpcs = errors.New("No VPCs found in region")
errMachineFailure = errors.New("Machine failed to start")
errNoIP = errors.New("No IP Address associated with the instance")
errComplete = errors.New("Complete")
)
type region struct {
AmiId string
}
var regionDetails map[string]*region = map[string]*region{
"ap-northeast-1": {"ami-44f1e245"},
"ap-southeast-1": {"ami-f95875ab"},
"ap-southeast-2": {"ami-890b62b3"},
"cn-north-1": {"ami-fe7ae8c7"},
"eu-west-1": {"ami-823686f5"},
"eu-central-1": {"ami-ac1524b1"},
"sa-east-1": {"ami-c770c1da"},
"us-east-1": {"ami-4ae27e22"},
"us-west-1": {"ami-d1180894"},
"us-west-2": {"ami-898dd9b9"},
"us-gov-west-1": {"ami-cf5630ec"},
}
func awsRegionsList() []string {
var list []string
for k := range regionDetails {
list = append(list, k)
}
return list
}
func validateAwsRegion(region string) (string, error) {
for _, v := range awsRegionsList() {
if v == region {
return region, nil
}
}
return "", errInvalidRegion
}