mirror of
https://github.com/grafana/grafana.git
synced 2025-07-31 07:32:13 +08:00
CloudWatch: Fix http client handling + assume role bug (#107893)
This commit is contained in:

committed by
GitHub

parent
c5fbf6217c
commit
f34a9fc0c2
@ -16,9 +16,9 @@ import (
|
||||
|
||||
"github.com/grafana/grafana-aws-sdk/pkg/awsauth"
|
||||
"github.com/grafana/grafana-plugin-sdk-go/backend"
|
||||
"github.com/grafana/grafana-plugin-sdk-go/backend/httpclient"
|
||||
"github.com/grafana/grafana-plugin-sdk-go/backend/instancemgmt"
|
||||
"github.com/grafana/grafana-plugin-sdk-go/backend/log"
|
||||
"github.com/grafana/grafana-plugin-sdk-go/backend/proxy"
|
||||
"github.com/grafana/grafana-plugin-sdk-go/backend/resource/httpadapter"
|
||||
"github.com/grafana/grafana/pkg/tsdb/cloudwatch/clients"
|
||||
"github.com/grafana/grafana/pkg/tsdb/cloudwatch/kinds/dataquery"
|
||||
@ -50,7 +50,7 @@ type DataQueryJson struct {
|
||||
|
||||
type DataSource struct {
|
||||
Settings models.CloudWatchSettings
|
||||
HTTPClient *http.Client
|
||||
ProxyOpts *proxy.Options
|
||||
AWSConfigProvider awsauth.ConfigProvider
|
||||
|
||||
logger log.Logger
|
||||
@ -74,7 +74,10 @@ func (ds *DataSource) newAWSConfig(ctx context.Context, region string) (aws.Conf
|
||||
Region: region,
|
||||
AccessKey: ds.Settings.AccessKey,
|
||||
SecretKey: ds.Settings.SecretKey,
|
||||
HTTPClient: ds.HTTPClient,
|
||||
HTTPClient: &http.Client{},
|
||||
}
|
||||
if ds.Settings.GrafanaSettings.SecureSocksDSProxyEnabled && ds.Settings.SecureSocksProxyEnabled {
|
||||
authSettings.ProxyOptions = ds.ProxyOpts
|
||||
}
|
||||
cfg, err := ds.AWSConfigProvider.GetConfig(ctx, authSettings)
|
||||
if err != nil {
|
||||
@ -93,14 +96,11 @@ func NewDatasource(ctx context.Context, settings backend.DataSourceInstanceSetti
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
httpClient, err := httpclient.New(opts)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ds := &DataSource{
|
||||
Settings: instanceSettings,
|
||||
HTTPClient: httpClient,
|
||||
// this is used to build a custom dialer when secure socks proxy is enabled
|
||||
ProxyOpts: opts.ProxyOptions,
|
||||
AWSConfigProvider: awsauth.NewConfigProvider(),
|
||||
logger: backend.NewLoggerWith("logger", "grafana-cloudwatch-datasource"),
|
||||
tagValueCache: cache.New(tagValueCacheExpiration, tagValueCacheExpiration*5),
|
||||
|
Reference in New Issue
Block a user