Skip to content

Commit 09475ad

Browse files
author
Thomas Labarussias
authored
Merge pull request #4 from claranet/fix-forced-region
2 parents 1251042 + 9a68700 commit 09475ad

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

main.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ var managedInstances []instance
4040

4141
func main() {
4242
profile := flag.String("p", "", "Profile from ~/.aws/config")
43-
region := flag.String("r", "eu-west-1", "Region, default is eu-west-1")
43+
region := flag.String("r", "", "Region, default is eu-west-1")
4444
instance := flag.String("i", "", "InstanceID for direct connection")
4545
portNumber := flag.String("pn", "", "Port Number for Proxy")
4646
localPortNumber := flag.String("lpn", "", "Local Port Number for Proxy")
@@ -60,9 +60,14 @@ func main() {
6060
*profile = selectProfile(p)
6161
}
6262
}
63-
64-
if reg, present := os.LookupEnv("AWS_DEFAULT_REGION"); *region == "" && present == true {
65-
*region = reg
63+
if *region == "" {
64+
if os.Getenv("AWS_REGION") != "" {
65+
*region = os.Getenv("AWS_REGION")
66+
} else if os.Getenv("AWS_DEFAULT_REGION") != "" {
67+
*region = os.Getenv("AWS_DEFAULT_PROFILE")
68+
} else {
69+
*region = "eu-west-1"
70+
}
6671
}
6772

6873
// Create session (credentials from ~/.aws/config)

0 commit comments

Comments
 (0)