|
|
@@ -234,10 +234,37 @@ func parseMultiSelectValue(input string) []string {
|
|
|
// Please update the region list in public/app/plugins/datasource/cloudwatch/partials/config.html
|
|
|
func (e *CloudWatchExecutor) handleGetRegions(ctx context.Context, parameters *simplejson.Json, queryContext *tsdb.TsdbQuery) ([]suggestData, error) {
|
|
|
regions := []string{
|
|
|
- "ap-northeast-1", "ap-northeast-2", "ap-southeast-1", "ap-southeast-2", "ap-south-1", "ca-central-1", "cn-north-1", "cn-northwest-1",
|
|
|
- "eu-central-1", "eu-west-1", "eu-west-2", "eu-west-3", "sa-east-1", "us-east-1", "us-east-2", "us-gov-west-1", "us-west-1", "us-west-2", "us-isob-east-1", "us-iso-east-1",
|
|
|
+ "ap-northeast-1", "ap-northeast-2", "ap-northeast-3", "ap-south-1", "ap-southeast-1", "ap-southeast-2", "ca-central-1",
|
|
|
+ "eu-central-1", "eu-north-1", "eu-west-1", "eu-west-2", "eu-west-3", "me-south-1", "sa-east-1", "us-east-1", "us-east-2", "us-west-1", "us-west-2",
|
|
|
+ "cn-north-1", "cn-northwest-1", "us-gov-east-1", "us-gov-west-1", "us-isob-east-1", "us-iso-east-1",
|
|
|
}
|
|
|
|
|
|
+ err := e.ensureClientSession("us-east-1")
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ r, err := e.ec2Svc.DescribeRegions(&ec2.DescribeRegionsInput{})
|
|
|
+ if err != nil {
|
|
|
+ // ignore error for backward compatibility
|
|
|
+ plog.Error("Failed to get regions", "error", err)
|
|
|
+ } else {
|
|
|
+ for _, region := range r.Regions {
|
|
|
+ exists := false
|
|
|
+
|
|
|
+ for _, existingRegion := range regions {
|
|
|
+ if existingRegion == *region.RegionName {
|
|
|
+ exists = true
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if !exists {
|
|
|
+ regions = append(regions, *region.RegionName)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ sort.Strings(regions)
|
|
|
+
|
|
|
result := make([]suggestData, 0)
|
|
|
for _, region := range regions {
|
|
|
result = append(result, suggestData{Text: region, Value: region})
|