Skip to content

Add checksum_algorithm to aws_s3 output #2907

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 17 additions & 0 deletions docs/modules/components/pages/outputs/aws_s3.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
15 changes: 15 additions & 0 deletions internal/impl/aws/output_s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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").
Expand Down Expand Up @@ -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.
Expand Down
Loading