Add support for configuring an AWS endpoint_url (#4485)
This commit is contained in:
parent
228efe9a1d
commit
93ed28e745
|
@ -16,6 +16,7 @@ type CredentialConfig struct {
|
||||||
Profile string
|
Profile string
|
||||||
Filename string
|
Filename string
|
||||||
Token string
|
Token string
|
||||||
|
EndpointURL string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *CredentialConfig) Credentials() client.ConfigProvider {
|
func (c *CredentialConfig) Credentials() client.ConfigProvider {
|
||||||
|
@ -29,6 +30,7 @@ func (c *CredentialConfig) Credentials() client.ConfigProvider {
|
||||||
func (c *CredentialConfig) rootCredentials() client.ConfigProvider {
|
func (c *CredentialConfig) rootCredentials() client.ConfigProvider {
|
||||||
config := &aws.Config{
|
config := &aws.Config{
|
||||||
Region: aws.String(c.Region),
|
Region: aws.String(c.Region),
|
||||||
|
Endpoint: &c.EndpointURL,
|
||||||
}
|
}
|
||||||
if c.AccessKey != "" || c.SecretKey != "" {
|
if c.AccessKey != "" || c.SecretKey != "" {
|
||||||
config.Credentials = credentials.NewStaticCredentials(c.AccessKey, c.SecretKey, c.Token)
|
config.Credentials = credentials.NewStaticCredentials(c.AccessKey, c.SecretKey, c.Token)
|
||||||
|
@ -43,6 +45,7 @@ func (c *CredentialConfig) assumeCredentials() client.ConfigProvider {
|
||||||
rootCredentials := c.rootCredentials()
|
rootCredentials := c.rootCredentials()
|
||||||
config := &aws.Config{
|
config := &aws.Config{
|
||||||
Region: aws.String(c.Region),
|
Region: aws.String(c.Region),
|
||||||
|
Endpoint: &c.EndpointURL,
|
||||||
}
|
}
|
||||||
config.Credentials = stscreds.NewCredentials(rootCredentials, c.RoleARN)
|
config.Credentials = stscreds.NewCredentials(rootCredentials, c.RoleARN)
|
||||||
return session.New(config)
|
return session.New(config)
|
||||||
|
|
|
@ -35,6 +35,12 @@ API endpoint. In the following order the plugin will attempt to authenticate.
|
||||||
#profile = ""
|
#profile = ""
|
||||||
#shared_credential_file = ""
|
#shared_credential_file = ""
|
||||||
|
|
||||||
|
## Endpoint to make request against, the correct endpoint is automatically
|
||||||
|
## determined and this option should only be set if you wish to override the
|
||||||
|
## default.
|
||||||
|
## ex: endpoint_url = "http://localhost:8000"
|
||||||
|
# endpoint_url = ""
|
||||||
|
|
||||||
# The minimum period for Cloudwatch metrics is 1 minute (60s). However not all
|
# The minimum period for Cloudwatch metrics is 1 minute (60s). However not all
|
||||||
# metrics are made available to the 1 minute period. Some are collected at
|
# metrics are made available to the 1 minute period. Some are collected at
|
||||||
# 3 minute, 5 minute, or larger intervals. See https://aws.amazon.com/cloudwatch/faqs/#monitoring.
|
# 3 minute, 5 minute, or larger intervals. See https://aws.amazon.com/cloudwatch/faqs/#monitoring.
|
||||||
|
|
|
@ -26,6 +26,7 @@ type (
|
||||||
Profile string `toml:"profile"`
|
Profile string `toml:"profile"`
|
||||||
Filename string `toml:"shared_credential_file"`
|
Filename string `toml:"shared_credential_file"`
|
||||||
Token string `toml:"token"`
|
Token string `toml:"token"`
|
||||||
|
EndpointURL string `toml:"endpoint_url"`
|
||||||
|
|
||||||
Period internal.Duration `toml:"period"`
|
Period internal.Duration `toml:"period"`
|
||||||
Delay internal.Duration `toml:"delay"`
|
Delay internal.Duration `toml:"delay"`
|
||||||
|
@ -79,6 +80,12 @@ func (c *CloudWatch) SampleConfig() string {
|
||||||
#profile = ""
|
#profile = ""
|
||||||
#shared_credential_file = ""
|
#shared_credential_file = ""
|
||||||
|
|
||||||
|
## Endpoint to make request against, the correct endpoint is automatically
|
||||||
|
## determined and this option should only be set if you wish to override the
|
||||||
|
## default.
|
||||||
|
## ex: endpoint_url = "http://localhost:8000"
|
||||||
|
# endpoint_url = ""
|
||||||
|
|
||||||
# The minimum period for Cloudwatch metrics is 1 minute (60s). However not all
|
# The minimum period for Cloudwatch metrics is 1 minute (60s). However not all
|
||||||
# metrics are made available to the 1 minute period. Some are collected at
|
# metrics are made available to the 1 minute period. Some are collected at
|
||||||
# 3 minute, 5 minute, or larger intervals. See https://aws.amazon.com/cloudwatch/faqs/#monitoring.
|
# 3 minute, 5 minute, or larger intervals. See https://aws.amazon.com/cloudwatch/faqs/#monitoring.
|
||||||
|
@ -231,6 +238,7 @@ func (c *CloudWatch) initializeCloudWatch() error {
|
||||||
Profile: c.Profile,
|
Profile: c.Profile,
|
||||||
Filename: c.Filename,
|
Filename: c.Filename,
|
||||||
Token: c.Token,
|
Token: c.Token,
|
||||||
|
EndpointURL: c.EndpointURL,
|
||||||
}
|
}
|
||||||
configProvider := credentialConfig.Credentials()
|
configProvider := credentialConfig.Credentials()
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ type CloudWatch struct {
|
||||||
Profile string `toml:"profile"`
|
Profile string `toml:"profile"`
|
||||||
Filename string `toml:"shared_credential_file"`
|
Filename string `toml:"shared_credential_file"`
|
||||||
Token string `toml:"token"`
|
Token string `toml:"token"`
|
||||||
|
EndpointURL string `toml:"endpoint_url"`
|
||||||
|
|
||||||
Namespace string `toml:"namespace"` // CloudWatch Metrics Namespace
|
Namespace string `toml:"namespace"` // CloudWatch Metrics Namespace
|
||||||
svc *cloudwatch.CloudWatch
|
svc *cloudwatch.CloudWatch
|
||||||
|
@ -48,6 +49,12 @@ var sampleConfig = `
|
||||||
#profile = ""
|
#profile = ""
|
||||||
#shared_credential_file = ""
|
#shared_credential_file = ""
|
||||||
|
|
||||||
|
## Endpoint to make request against, the correct endpoint is automatically
|
||||||
|
## determined and this option should only be set if you wish to override the
|
||||||
|
## default.
|
||||||
|
## ex: endpoint_url = "http://localhost:8000"
|
||||||
|
# endpoint_url = ""
|
||||||
|
|
||||||
## Namespace for the CloudWatch MetricDatums
|
## Namespace for the CloudWatch MetricDatums
|
||||||
namespace = "InfluxData/Telegraf"
|
namespace = "InfluxData/Telegraf"
|
||||||
`
|
`
|
||||||
|
@ -69,6 +76,7 @@ func (c *CloudWatch) Connect() error {
|
||||||
Profile: c.Profile,
|
Profile: c.Profile,
|
||||||
Filename: c.Filename,
|
Filename: c.Filename,
|
||||||
Token: c.Token,
|
Token: c.Token,
|
||||||
|
EndpointURL: c.EndpointURL,
|
||||||
}
|
}
|
||||||
configProvider := credentialConfig.Credentials()
|
configProvider := credentialConfig.Credentials()
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ type (
|
||||||
Profile string `toml:"profile"`
|
Profile string `toml:"profile"`
|
||||||
Filename string `toml:"shared_credential_file"`
|
Filename string `toml:"shared_credential_file"`
|
||||||
Token string `toml:"token"`
|
Token string `toml:"token"`
|
||||||
|
EndpointURL string `toml:"endpoint_url"`
|
||||||
|
|
||||||
StreamName string `toml:"streamname"`
|
StreamName string `toml:"streamname"`
|
||||||
PartitionKey string `toml:"partitionkey"`
|
PartitionKey string `toml:"partitionkey"`
|
||||||
|
@ -60,6 +61,12 @@ var sampleConfig = `
|
||||||
#profile = ""
|
#profile = ""
|
||||||
#shared_credential_file = ""
|
#shared_credential_file = ""
|
||||||
|
|
||||||
|
## Endpoint to make request against, the correct endpoint is automatically
|
||||||
|
## determined and this option should only be set if you wish to override the
|
||||||
|
## default.
|
||||||
|
## ex: endpoint_url = "http://localhost:8000"
|
||||||
|
# endpoint_url = ""
|
||||||
|
|
||||||
## Kinesis StreamName must exist prior to starting telegraf.
|
## Kinesis StreamName must exist prior to starting telegraf.
|
||||||
streamname = "StreamName"
|
streamname = "StreamName"
|
||||||
## DEPRECATED: PartitionKey as used for sharding data.
|
## DEPRECATED: PartitionKey as used for sharding data.
|
||||||
|
@ -133,6 +140,7 @@ func (k *KinesisOutput) Connect() error {
|
||||||
Profile: k.Profile,
|
Profile: k.Profile,
|
||||||
Filename: k.Filename,
|
Filename: k.Filename,
|
||||||
Token: k.Token,
|
Token: k.Token,
|
||||||
|
EndpointURL: k.EndpointURL,
|
||||||
}
|
}
|
||||||
configProvider := credentialConfig.Credentials()
|
configProvider := credentialConfig.Credentials()
|
||||||
svc := kinesis.New(configProvider)
|
svc := kinesis.New(configProvider)
|
||||||
|
|
Loading…
Reference in New Issue