Skip to content

Commit

Permalink
feat: add acl support into s3 output
Browse files Browse the repository at this point in the history
  • Loading branch information
aosti committed Jun 24, 2024
1 parent 1b86d91 commit ac4c399
Showing 1 changed file with 19 additions and 0 deletions.
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

0 comments on commit ac4c399

Please sign in to comment.