mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
return default region list from backend
This commit is contained in:
parent
a417d6fa21
commit
fce50cf1b8
@ -234,6 +234,8 @@ func parseMultiSelectValue(input string) []string {
|
|||||||
// Please update the region list in public/app/plugins/datasource/cloudwatch/partials/config.html
|
// 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) {
|
func (e *CloudWatchExecutor) handleGetRegions(ctx context.Context, parameters *simplejson.Json, queryContext *tsdb.TsdbQuery) ([]suggestData, error) {
|
||||||
regions := []string{
|
regions := []string{
|
||||||
|
"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",
|
"cn-north-1", "cn-northwest-1", "us-gov-east-1", "us-gov-west-1", "us-isob-east-1", "us-iso-east-1",
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -243,11 +245,13 @@ func (e *CloudWatchExecutor) handleGetRegions(ctx context.Context, parameters *s
|
|||||||
}
|
}
|
||||||
r, err := e.ec2Svc.DescribeRegions(&ec2.DescribeRegionsInput{})
|
r, err := e.ec2Svc.DescribeRegions(&ec2.DescribeRegionsInput{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
// ignore error for backward compatibility
|
||||||
}
|
plog.Error("Failed to get regions", "error", err)
|
||||||
|
} else {
|
||||||
for _, region := range r.Regions {
|
for _, region := range r.Regions {
|
||||||
regions = append(regions, *region.RegionName)
|
regions = append(regions, *region.RegionName)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
sort.Strings(regions)
|
sort.Strings(regions)
|
||||||
|
|
||||||
result := make([]suggestData, 0)
|
result := make([]suggestData, 0)
|
||||||
|
@ -41,32 +41,7 @@ export class CloudWatchConfigCtrl {
|
|||||||
{ name: 'Yearly', value: 'Yearly', example: '[logstash-]YYYY' },
|
{ name: 'Yearly', value: 'Yearly', example: '[logstash-]YYYY' },
|
||||||
];
|
];
|
||||||
|
|
||||||
regions = [
|
regions = [];
|
||||||
'ap-northeast-1',
|
|
||||||
'ap-northeast-2',
|
|
||||||
'ap-northeast-3',
|
|
||||||
'ap-south-1',
|
|
||||||
'ap-southeast-1',
|
|
||||||
'ap-southeast-2',
|
|
||||||
'ca-central-1',
|
|
||||||
'cn-north-1',
|
|
||||||
'cn-northwest-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-gov-east-1',
|
|
||||||
'us-gov-west-1',
|
|
||||||
'us-iso-east-1',
|
|
||||||
'us-isob-east-1',
|
|
||||||
'us-west-1',
|
|
||||||
'us-west-2',
|
|
||||||
];
|
|
||||||
|
|
||||||
getRegions() {
|
getRegions() {
|
||||||
this.datasourceSrv
|
this.datasourceSrv
|
||||||
@ -74,10 +49,13 @@ export class CloudWatchConfigCtrl {
|
|||||||
.then(ds => {
|
.then(ds => {
|
||||||
return ds.getRegions();
|
return ds.getRegions();
|
||||||
})
|
})
|
||||||
.then(regions => {
|
.then(
|
||||||
|
regions => {
|
||||||
this.regions = _.map(regions, 'value');
|
this.regions = _.map(regions, 'value');
|
||||||
}, err => {
|
},
|
||||||
console.error('failed to call ec2:DescribeRegions, please check iam setting');
|
err => {
|
||||||
});
|
console.error('failed to get latest regions');
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user