From b5dfa9f4d844c4049f80ffbdccc180730c4014bd Mon Sep 17 00:00:00 2001 From: Bharat Pasupula Date: Mon, 7 Aug 2023 10:04:17 +0200 Subject: [PATCH] Move logic to awss3 input --- x-pack/filebeat/input/awss3/input.go | 11 +++++++++++ x-pack/libbeat/common/aws/credentials.go | 11 ----------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/x-pack/filebeat/input/awss3/input.go b/x-pack/filebeat/input/awss3/input.go index c50b4bb4c42d..013703832a32 100644 --- a/x-pack/filebeat/input/awss3/input.go +++ b/x-pack/filebeat/input/awss3/input.go @@ -69,6 +69,17 @@ type s3Input struct { func newInput(config config, store beater.StateStore) (*s3Input, error) { awsConfig, err := awscommon.InitializeAWSConfig(config.AWSConfig) + + if config.AWSConfig.Endpoint != "" { + // Add a custom endpointResolver to the awsConfig so that all the requests are routed to this endpoint + awsConfig.EndpointResolverWithOptions = awssdk.EndpointResolverWithOptionsFunc(func(service, region string, options ...interface{}) (awssdk.Endpoint, error) { + return awssdk.Endpoint{ + URL: config.AWSConfig.Endpoint, + SigningRegion: awsConfig.Region, + }, nil + }) + } + if err != nil { return nil, fmt.Errorf("failed to initialize AWS credentials: %w", err) } diff --git a/x-pack/libbeat/common/aws/credentials.go b/x-pack/libbeat/common/aws/credentials.go index d09ccd8ba733..b4961fbd6cc5 100644 --- a/x-pack/libbeat/common/aws/credentials.go +++ b/x-pack/libbeat/common/aws/credentials.go @@ -56,17 +56,6 @@ func InitializeAWSConfig(beatsConfig ConfigAWS) (awssdk.Config, error) { } } - if beatsConfig.Endpoint != "" { - // Add a custom endpointResolver to the awsConfig so that all the requests are routed to this endpoint - awsConfig.EndpointResolverWithOptions = awssdk.EndpointResolverWithOptionsFunc(func(service, region string, options ...interface{}) (awssdk.Endpoint, error) { - return awssdk.Endpoint{ - PartitionID: "aws", - URL: beatsConfig.Endpoint, - SigningRegion: awsConfig.Region, - }, nil - }) - } - // Assume IAM role if iam_role config parameter is given if beatsConfig.RoleArn != "" { addAssumeRoleProviderToAwsConfig(beatsConfig, &awsConfig)