fix(inputs.cloudwatch): enable custom endpoint support (#12657)
This commit is contained in:
parent
4d0f05980e
commit
f206c27d89
|
|
@ -182,14 +182,19 @@ func (c *CloudWatch) initializeCloudWatch() error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg, err := c.CredentialConfig.Credentials()
|
awsCreds, err := c.CredentialConfig.Credentials()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
c.client = cwClient.NewFromConfig(cfg, func(options *cwClient.Options) {
|
|
||||||
// Disable logging
|
|
||||||
options.ClientLogMode = 0
|
|
||||||
|
|
||||||
|
var customResolver cwClient.EndpointResolver
|
||||||
|
if c.CredentialConfig.EndpointURL != "" && c.CredentialConfig.Region != "" {
|
||||||
|
customResolver = cwClient.EndpointResolverFromURL(c.CredentialConfig.EndpointURL)
|
||||||
|
}
|
||||||
|
|
||||||
|
c.client = cwClient.NewFromConfig(awsCreds, func(options *cwClient.Options) {
|
||||||
|
options.EndpointResolver = customResolver
|
||||||
|
options.ClientLogMode = 0
|
||||||
options.HTTPClient = &http.Client{
|
options.HTTPClient = &http.Client{
|
||||||
// use values from DefaultTransport
|
// use values from DefaultTransport
|
||||||
Transport: &http.Transport{
|
Transport: &http.Transport{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue