Skip to content
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

Add ACL support into s3 output #2678

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
19 changes: 19 additions & 0 deletions internal/impl/aws/output_s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const (
s3oFieldMetadata = "metadata"
s3oFieldStorageClass = "storage_class"
s3oFieldTimeout = "timeout"
s3oFieldACL = "acl"
s3oFieldKMSKeyID = "kms_key_id"
s3oFieldServerSideEncryption = "server_side_encryption"
s3oFieldBatching = "batching"
Expand All @@ -73,6 +74,7 @@ type s3oConfig struct {
Metadata *service.MetadataExcludeFilter
StorageClass *service.InterpolatedString
Timeout time.Duration
ACL *service.InterpolatedString
KMSKeyID string
ServerSideEncryption string
UsePathStyle bool
Expand Down Expand Up @@ -133,6 +135,9 @@ func s3oConfigFromParsed(pConf *service.ParsedConfig) (conf s3oConfig, err error
if conf.Timeout, err = pConf.FieldDuration(s3oFieldTimeout); err != nil {
return
}
if conf.ACL, err = pConf.FieldInterpolatedString(s3oFieldACL); err != nil {
return
}
if conf.KMSKeyID, err = pConf.FieldString(s3oFieldKMSKeyID); err != nil {
return
}
Expand Down Expand Up @@ -257,6 +262,11 @@ output:
Description("The storage class to set for each object.").
Default("STANDARD").
Advanced(),
service.NewInterpolatedStringEnumField(s3oFieldACL,
"private", "public-read", "public-read-write", "authenticated-read", "aws-exec-read", "bucket-owner-read", "bucket-owner-full-control").
Description("The canned ACL to set for each object.").
Default("").
Advanced(),
service.NewStringField(s3oFieldKMSKeyID).
Description("An optional server side encryption key.").
Default("").
Expand Down Expand Up @@ -426,6 +436,15 @@ func (a *amazonS3Writer) WriteBatch(wctx context.Context, msg service.MessageBat
uploadInput.Tagging = aws.String(strings.Join(tags, "&"))
}

acl, err := msg.TryInterpolatedString(i, a.conf.ACL)
if err != nil {
return fmt.Errorf("acl interpolation: %w", err)
}

if acl != "" {
uploadInput.ACL = types.ObjectCannedACL(acl)
}

if a.conf.KMSKeyID != "" {
uploadInput.ServerSideEncryption = types.ServerSideEncryptionAwsKms
uploadInput.SSEKMSKeyId = &a.conf.KMSKeyID
Expand Down