Skip to content

Commit

Permalink
Move logic to awss3 input
Browse files Browse the repository at this point in the history
  • Loading branch information
bhapas committed Aug 7, 2023
1 parent 892904b commit b5dfa9f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
11 changes: 11 additions & 0 deletions x-pack/filebeat/input/awss3/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
11 changes: 0 additions & 11 deletions x-pack/libbeat/common/aws/credentials.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit b5dfa9f

Please sign in to comment.