From 37e2ea9586191397d79b7c2688b99d2a3199fa0c Mon Sep 17 00:00:00 2001 From: Wesley Pettit Date: Mon, 10 Apr 2023 22:26:32 -0700 Subject: [PATCH] Revert "Revert "init: fix S3 ARN parsing #617"" This reverts commit 760bfed37ebc1e3ed0fe7c03a36e0a2c774c0656. --- init/fluent_bit_init_process.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/init/fluent_bit_init_process.go b/init/fluent_bit_init_process.go index afff69863..b65161d41 100644 --- a/init/fluent_bit_init_process.go +++ b/init/fluent_bit_init_process.go @@ -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] Could not parse 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] Could not parse arn: %s\n", userInput) } bucketName := bucketAndFile[0]