-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathaws-regions.go
57 lines (48 loc) · 1.16 KB
/
aws-regions.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
52
53
54
55
56
57
package main
import (
"fmt"
"os"
"sort"
"strings"
"text/tabwriter"
)
func main() {
regions := map[string]string{
"ap-northeast-1": "Asia Pacific (Tokyo)",
"ap-northeast-2": "Asia Pacific (Seoul)",
"ap-south-1": "Asia Pacific (Mumbai)",
"ap-southeast-1": "Asia Pacific (Singapore)",
"ap-southeast-2": "Asia Pacific (Sydney)",
"ca-central-1": "Canada (Central)",
"eu-central-1": "EU (Frankfurt)",
"eu-west-1": "EU (Ireland)",
"eu-west-2": "EU (London)",
"sa-east-1": "South America (Sao Paulo)",
"us-east-1": "US East (N. Virginia)",
"us-east-2": "US East (Ohio)",
"us-west-1": "US West (N. California)",
"us-west-2": "US West (Oregon)",
}
// short cut if given an exact region
region := ""
if len(os.Args) > 1 {
region = os.Args[1]
if desc, ok := regions[region]; ok {
fmt.Println(desc)
os.Exit(0)
}
}
w := new(tabwriter.Writer)
w.Init(os.Stdout, 30, 0, 2, ' ', 0)
var keys []string
for k := range regions {
keys = append(keys, k)
}
sort.Strings(keys)
for _, k := range keys {
if strings.Contains(k, region) {
fmt.Fprintln(w, k, "\t", regions[k])
}
}
w.Flush()
}