Skip to content

Commit

Permalink
back compat example
Browse files Browse the repository at this point in the history
  • Loading branch information
strawgate committed May 24, 2024
1 parent e0280b5 commit ac5418e
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions x-pack/filebeat/input/awss3/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,29 @@ type s3Input struct {
func newInput(config config, store beater.StateStore) (*s3Input, error) {
awsConfig, err := awscommon.InitializeAWSConfig(config.AWSConfig)

if config.AWSConfig.Endpoint != "" {
endpointUri, err := url.Parse(config.AWSConfig.Endpoint)

if err != nil {
// Log the error and continue with the default endpoint
fmt.Printf("Failed to parse the endpoint: %v", err)

Check failure on line 78 in x-pack/filebeat/input/awss3/input.go

View workflow job for this annotation

GitHub Actions / lint (windows)

use of `fmt.Printf` forbidden by pattern `fmt.Print.*` (forbidigo)
}

// For backwards compat, if the endpoint does not start with S3, we will use the endpoint resolver to all SDK requests through this endpoint
if !strings.HasPrefix(endpointUri.Hostname(), "s3") {
// Get the resolver from the endpoint url
awsConfig.EndpointResolverWithOptions = awssdk.EndpointResolverWithOptionsFunc(func(service, region string, options ...interface{}) (awssdk.Endpoint, error) {
return awssdk.Endpoint{
PartitionID: "aws",
Source: awssdk.EndpointSourceCustom,
URL: config.AWSConfig.Endpoint,
SigningRegion: awsConfig.Region,
HostnameImmutable: true,
}, nil
})
}
}

// 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) {

Expand Down Expand Up @@ -196,6 +219,8 @@ func (in *s3Input) Run(inputContext v2.Context, pipeline beat.Pipeline) error {

func (in *s3Input) createSQSReceiver(ctx v2.Context, pipeline beat.Pipeline) (*sqsReader, error) {

// parse the Endpoint as a uri and extract the domain

sqsAPI := &awsSQSAPI{
client: sqs.NewFromConfig(in.awsConfig, func(o *sqs.Options) {
if in.config.AWSConfig.FIPSEnabled {
Expand Down

0 comments on commit ac5418e

Please sign in to comment.