Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions init/fluent_bit_init_process.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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":
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be worth adding unit tests that covers "EU" and a few other regions as well. WDYT?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy for this to be done as a follow up but probably safer to have some form of unit testing for this if possible imo

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll see about a follow-up PR with added testing as it has become a bit of a mountain to rework the existing method to make it more testable.

bucketRegion = "eu-west-1"
}

// create a downloader
Expand Down