From e621d201bc64af205fa366e16a916bdb907e5ed3 Mon Sep 17 00:00:00 2001 From: Shelby Hagman Date: Mon, 23 Jun 2025 20:28:45 +0000 Subject: [PATCH] Fix init process s3 getBucketLocation issue For eu-west-1 region s3:GetBucketLocation returns EU for LocationConstraint which is not currently handled. This change adds a check to convert EU --> eu-west-1. Fixes #929 --- init/fluent_bit_init_process.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/init/fluent_bit_init_process.go b/init/fluent_bit_init_process.go index 1ba05b62d..a388856b4 100644 --- a/init/fluent_bit_init_process.go +++ b/init/fluent_bit_init_process.go @@ -225,6 +225,9 @@ func getS3ConfigFile(userInput string) string { bucketName := bucketAndFile[0] s3FilePath := bucketAndFile[1] + // TODO: migrate to s3:HeadBucket and use BucketRegion + // https://docs.aws.amazon.com/AmazonS3/latest/API/API_HeadBucket.html + // https://pkg.go.dev/github.com/aws/aws-sdk-go-v2/service/s3#Client.HeadBucket // get bucket region input := &s3.GetBucketLocationInput{ Bucket: aws.String(bucketName), @@ -238,9 +241,13 @@ func getS3ConfigFile(userInput string) string { bucketRegion := string(output.LocationConstraint) // Buckets in Region us-east-1 have a LocationConstraint of null - // https://docs.aws.amazon.com/sdk-for-go/api/service/s3/#GetBucketLocationOutput - if bucketRegion == "" { + // Buckets in Region eu-west-1 have a LocationConstraint of EU + // https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketLocation.html#API_GetBucketLocation_ResponseSyntax + switch bucketRegion { + case "": bucketRegion = "us-east-1" + case "EU": + bucketRegion = "eu-west-1" } // create a downloader