File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ import (
20
20
"strconv"
21
21
"strings"
22
22
23
+ "github.com/aws/aws-sdk-go/aws/endpoints"
23
24
"github.com/aws/aws-sdk-go/aws/session"
24
25
"github.com/rs/zerolog/log"
25
26
)
@@ -193,7 +194,8 @@ func ParseCliArgs() (config Config, err error) {
193
194
if config .AWSRegion != "" {
194
195
sess .Config .Region = & config .AWSRegion
195
196
} else if * sess .Config .Region == "" && config .QueueURL != "" {
196
- config .AWSRegion = strings .Split (config .QueueURL , "." )[1 ]
197
+ config .AWSRegion = getRegionFromQueueURL (config .QueueURL )
198
+ log .Debug ().Str ("Retrieved AWS region from queue-url: \" %s\" " , config .AWSRegion )
197
199
sess .Config .Region = & config .AWSRegion
198
200
} else {
199
201
config .AWSRegion = * sess .Config .Region
@@ -397,3 +399,14 @@ func isConfigProvided(cliArgName string, envVarName string) bool {
397
399
})
398
400
return cliArgProvided
399
401
}
402
+
403
+ func getRegionFromQueueURL (queueURL string ) string {
404
+ for _ , partition := range endpoints .DefaultPartitions () {
405
+ for regionID := range partition .Regions () {
406
+ if strings .Contains (queueURL , regionID ) {
407
+ return regionID
408
+ }
409
+ }
410
+ }
411
+ return ""
412
+ }
You can’t perform that action at this time.
0 commit comments