From 9a42833184ef83b1cc4cd37d737f8d06ec43a4ff Mon Sep 17 00:00:00 2001 From: kaiyan-sheng Date: Mon, 11 Nov 2024 09:54:39 -0700 Subject: [PATCH 1/2] [aws] Set region in config from GetBucketLocation API call (#41572) This PR sets the region of the S3 bucket as the region in AWS config to make API calls. (cherry picked from commit 076ea50b314499ac91cc21c7f4d26be32c8cf901) --- CHANGELOG.next.asciidoc | 2 ++ x-pack/filebeat/input/awss3/s3.go | 12 ++++++------ x-pack/filebeat/input/awss3/s3_input.go | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.next.asciidoc b/CHANGELOG.next.asciidoc index 066dbb8036c..081bc34b52c 100644 --- a/CHANGELOG.next.asciidoc +++ b/CHANGELOG.next.asciidoc @@ -168,6 +168,8 @@ https://github.com/elastic/beats/compare/v8.8.1\...main[Check the HEAD diff] - Log bad handshake details when websocket connection fails {pull}41300[41300] - Improve modification time handling for entities and entity deletion logic in the Active Directory entityanalytics input. {pull}41179[41179] - Journald input now can read events from all boots {issue}41083[41083] {pull}41244[41244] +- Fix double encoding of client_secret in the Entity Analytics input's Azure Active Directory provider {pull}41393[41393] +- Fix aws region in aws-s3 input s3 polling mode. {pull}41572[41572] - Fix errors in SQS host resolution in the `aws-s3` input when using custom (non-AWS) endpoints. {pull}41504[41504] - The azure-eventhub input now correctly reports its status to the Elastic Agent on fatal errors {pull}41469[41469] diff --git a/x-pack/filebeat/input/awss3/s3.go b/x-pack/filebeat/input/awss3/s3.go index a4865022850..fabc1b2f1dd 100644 --- a/x-pack/filebeat/input/awss3/s3.go +++ b/x-pack/filebeat/input/awss3/s3.go @@ -16,16 +16,16 @@ import ( "github.com/elastic/beats/v7/libbeat/beat" ) -func createS3API(ctx context.Context, config config, awsConfig awssdk.Config) (*awsS3API, error) { - s3Client := s3.NewFromConfig(awsConfig, config.s3ConfigModifier) - regionName, err := getRegionForBucket(ctx, s3Client, config.getBucketName()) +func (in *s3PollerInput) createS3API(ctx context.Context) (*awsS3API, error) { + s3Client := s3.NewFromConfig(in.awsConfig, in.config.s3ConfigModifier) + regionName, err := getRegionForBucket(ctx, s3Client, in.config.getBucketName()) if err != nil { return nil, fmt.Errorf("failed to get AWS region for bucket: %w", err) } // Can this really happen? - if regionName != awsConfig.Region { - awsConfig.Region = regionName - s3Client = s3.NewFromConfig(awsConfig, config.s3ConfigModifier) + if regionName != in.awsConfig.Region { + in.awsConfig.Region = regionName + s3Client = s3.NewFromConfig(in.awsConfig, in.config.s3ConfigModifier) } return newAWSs3API(s3Client), nil diff --git a/x-pack/filebeat/input/awss3/s3_input.go b/x-pack/filebeat/input/awss3/s3_input.go index c3a83c284a2..6775a1be033 100644 --- a/x-pack/filebeat/input/awss3/s3_input.go +++ b/x-pack/filebeat/input/awss3/s3_input.go @@ -73,7 +73,7 @@ func (in *s3PollerInput) Run( defer in.states.Close() ctx := v2.GoContextFromCanceler(inputContext.Cancelation) - in.s3, err = createS3API(ctx, in.config, in.awsConfig) + in.s3, err = in.createS3API(ctx) if err != nil { return fmt.Errorf("failed to create S3 API: %w", err) } From 3b3b66e72eda2a3290d535edc1fcd811820c43d3 Mon Sep 17 00:00:00 2001 From: kaiyan-sheng Date: Mon, 11 Nov 2024 10:41:13 -0700 Subject: [PATCH 2/2] Update CHANGELOG.next.asciidoc --- CHANGELOG.next.asciidoc | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.next.asciidoc b/CHANGELOG.next.asciidoc index 081bc34b52c..06450f5ecd4 100644 --- a/CHANGELOG.next.asciidoc +++ b/CHANGELOG.next.asciidoc @@ -168,7 +168,6 @@ https://github.com/elastic/beats/compare/v8.8.1\...main[Check the HEAD diff] - Log bad handshake details when websocket connection fails {pull}41300[41300] - Improve modification time handling for entities and entity deletion logic in the Active Directory entityanalytics input. {pull}41179[41179] - Journald input now can read events from all boots {issue}41083[41083] {pull}41244[41244] -- Fix double encoding of client_secret in the Entity Analytics input's Azure Active Directory provider {pull}41393[41393] - Fix aws region in aws-s3 input s3 polling mode. {pull}41572[41572] - Fix errors in SQS host resolution in the `aws-s3` input when using custom (non-AWS) endpoints. {pull}41504[41504] - The azure-eventhub input now correctly reports its status to the Elastic Agent on fatal errors {pull}41469[41469]