Skip to content

Commit e8e4813

Browse files
authored
Fix init process s3 getBucketLocation issue (#942)
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
1 parent e498099 commit e8e4813

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

init/fluent_bit_init_process.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,9 @@ func getS3ConfigFile(userInput string) string {
273273
bucketName := bucketAndFile[0]
274274
s3FilePath := bucketAndFile[1]
275275

276+
// TODO: migrate to s3:HeadBucket and use BucketRegion
277+
// https://docs.aws.amazon.com/AmazonS3/latest/API/API_HeadBucket.html
278+
// https://pkg.go.dev/github.com/aws/aws-sdk-go-v2/service/s3#Client.HeadBucket
276279
// get bucket region
277280
input := &s3.GetBucketLocationInput{
278281
Bucket: aws.String(bucketName),
@@ -286,9 +289,13 @@ func getS3ConfigFile(userInput string) string {
286289

287290
bucketRegion := string(output.LocationConstraint)
288291
// Buckets in Region us-east-1 have a LocationConstraint of null
289-
// https://docs.aws.amazon.com/sdk-for-go/api/service/s3/#GetBucketLocationOutput
290-
if bucketRegion == "" {
292+
// Buckets in Region eu-west-1 have a LocationConstraint of EU
293+
// https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketLocation.html#API_GetBucketLocation_ResponseSyntax
294+
switch bucketRegion {
295+
case "":
291296
bucketRegion = "us-east-1"
297+
case "EU":
298+
bucketRegion = "eu-west-1"
292299
}
293300

294301
// create a downloader

0 commit comments

Comments
 (0)