From 8a00439d80f9d42185e53e1947f8c75b4c8811bd Mon Sep 17 00:00:00 2001 From: "dom.lee" Date: Mon, 16 Sep 2024 23:35:54 +0100 Subject: [PATCH] Add checksum_algorithm to aws_s3 output Signed-off-by: Mihai Todor --- CHANGELOG.md | 6 ++++++ .../components/pages/outputs/aws_s3.adoc | 17 +++++++++++++++++ internal/impl/aws/output_s3.go | 15 +++++++++++++++ 3 files changed, 38 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a281b5a86..99f1eabe18 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,12 @@ Changelog All notable changes to this project will be documented in this file. +## 4.38.0 - TBD + +### Added + +- Field `checksum_algorithm` added to the `aws_s3` output. (@dom-lee-naimuri) + ## 4.37.0 - 2024-09-26 ### Added diff --git a/docs/modules/components/pages/outputs/aws_s3.adoc b/docs/modules/components/pages/outputs/aws_s3.adoc index 799777b6ef..2c9fd5af8d 100644 --- a/docs/modules/components/pages/outputs/aws_s3.adoc +++ b/docs/modules/components/pages/outputs/aws_s3.adoc @@ -77,6 +77,7 @@ output: exclude_prefixes: [] storage_class: STANDARD kms_key_id: "" + checksum_algorithm: "" server_side_encryption: "" force_path_style_urls: false max_in_flight: 64 @@ -329,6 +330,22 @@ An optional server side encryption key. *Default*: `""` +=== `checksum_algorithm` + +The algorithm used to create the checksum for each object. + + +*Type*: `string` + +*Default*: `""` + +Options: +`CRC32` +, `CRC32C` +, `SHA1` +, `SHA256` +. + === `server_side_encryption` An optional server side encryption algorithm. diff --git a/internal/impl/aws/output_s3.go b/internal/impl/aws/output_s3.go index b375b382cd..e3f901e6ef 100644 --- a/internal/impl/aws/output_s3.go +++ b/internal/impl/aws/output_s3.go @@ -40,6 +40,7 @@ const ( s3oFieldForcePathStyleURLs = "force_path_style_urls" s3oFieldPath = "path" s3oFieldTags = "tags" + s3oFieldChecksumAlgorithm = "checksum_algorithm" s3oFieldContentType = "content_type" s3oFieldContentEncoding = "content_encoding" s3oFieldCacheControl = "cache_control" @@ -68,6 +69,7 @@ type s3oConfig struct { ContentType *service.InterpolatedString ContentEncoding *service.InterpolatedString CacheControl *service.InterpolatedString + ChecksumAlgorithm string ContentDisposition *service.InterpolatedString ContentLanguage *service.InterpolatedString ContentMD5 *service.InterpolatedString @@ -126,6 +128,9 @@ func s3oConfigFromParsed(pConf *service.ParsedConfig) (conf s3oConfig, err error if conf.ContentMD5, err = pConf.FieldInterpolatedString(s3oFieldContentMD5); err != nil { return } + if conf.ChecksumAlgorithm, err = pConf.FieldString(s3oFieldChecksumAlgorithm); err != nil { + return + } if conf.WebsiteRedirectLocation, err = pConf.FieldInterpolatedString(s3oFieldWebsiteRedirectLocation); err != nil { return } @@ -270,6 +275,12 @@ output: Description("An optional server side encryption key."). Default(""). Advanced(), + service.NewStringEnumField(s3oFieldChecksumAlgorithm, + "CRC32", "CRC32C", "SHA1", "SHA256", + ). + Description("The algorithm used to create the checksum for each object."). + Default(""). + Advanced(), service.NewStringField(s3oFieldServerSideEncryption). Description("An optional server side encryption algorithm."). Version("3.63.0"). @@ -448,6 +459,10 @@ func (a *amazonS3Writer) WriteBatch(wctx context.Context, msg service.MessageBat uploadInput.SSEKMSKeyId = &a.conf.KMSKeyID } + if a.conf.ChecksumAlgorithm != "" { + uploadInput.ChecksumAlgorithm = types.ChecksumAlgorithm(a.conf.ChecksumAlgorithm) + } + // NOTE: This overrides the ServerSideEncryption set above. We need this to preserve // backwards compatibility, where it is allowed to only set kms_key_id in the config and // the ServerSideEncryption value of "aws:kms" is implied.