Skip to content

Commit

Permalink
init: fix S3 ARN parsing aws#617
Browse files Browse the repository at this point in the history
Signed-off-by: Wesley Pettit <[email protected]>
  • Loading branch information
PettitWesley committed Mar 31, 2023
1 parent 7913d6e commit 7a0873a
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions init/fluent_bit_init_process.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,17 +195,20 @@ func processConfigFile(path string) {
}
}

func getS3ConfigFile(arn string) string {
func getS3ConfigFile(userInput string) string {
// Preparation for downloading S3 config files
if !s3ClientCreated {
createS3Client()
}

// e.g. "arn:aws:s3:::user-bucket/s3_parser.conf"
arnBucketFile := arn[13:]
bucketAndFile := strings.SplitN(arnBucketFile, "/", 2)
s3ARN, err := arn.Parse(userInput)
if err != nil {
logrus.Fatalf("[FluentBit Init Process] Unrecognizable arn: %s\n", userInput)
}
bucketAndFile := strings.SplitN(s3ARN.Resource, "/", 2)
if len(bucketAndFile) != 2 {
logrus.Fatalf("[FluentBit Init Process] Unrecognizable arn: %s\n", arn)
logrus.Fatalf("[FluentBit Init Process] Unrecognizable arn: %s\n", userInput)
}

bucketName := bucketAndFile[0]
Expand Down

0 comments on commit 7a0873a

Please sign in to comment.