Skip to content

Conversation

@idivanshu
Copy link
Contributor

closes #628
This PR adds support for configuring AWS KMS server-side encryption (serverSideEncryption, kmsKeyId) when using the MOVE action in S3 Trigger and Copy tasks.

Some S3 buckets enforce encryption with policies that deny uploads missing SSE headers.
This enhancement enables Kestra flows to move files into such buckets without failure.

Summary
Adds serverSideEncryption and kmsKeyId to the moveTo configuration.

Updates Copy task to apply SSE-KMS headers during copy operations.

Updates S3Service.performAction() to support SSE-KMS for MOVE actions triggered by S3 events.

Fully compatible with existing flows (non-breaking).

Validated using real AWS buckets enforcing encryption policies.

Example Flow (Validated)
id: test_s3_kms_move
namespace: local.test

tasks:

  • id: move
    type: io.kestra.plugin.aws.s3.Copy
    region: "us-east-1"
    accessKeyId: "{{ secret('AWS_KEY') }}"
    secretKeyId: "{{ secret('AWS_SECRET') }}"

    from:
    bucket: "kestra-test-src-bucket"
    key: "input/test.txt"

    to:
    bucket: "kestra-cfn-test-1"
    key: "moved/test.txt"
    serverSideEncryption: AWS_KMS
    kmsKeyId: "{{ secret('KMS_KEY_ARN') }}"

    delete: true

This flow successfully writes into a bucket that rejects unencrypted uploads (explicit deny).

Testing

Manually tested using Kestra UI with plugin JAR

MOVE + SSE-KMS verified end-to-end

Adds support for `serverSideEncryption` and `kmsKeyId` in S3 MOVE actions
inside the Trigger and Copy operations. This enables workflows to move files
into buckets that enforce encryption policies requiring SSE-KMS. Includes
schema updates, parameter handling, and correct wiring inside S3Service
performAction().
@kestrabot kestrabot bot added this to Pull Requests Dec 7, 2025
@github-project-automation github-project-automation bot moved this to To review in Pull Requests Dec 7, 2025
@MilosPaunovic MilosPaunovic added area/plugin Plugin-related issue or feature request kind/external Pull requests raised by community contributors labels Dec 8, 2025
@MilosPaunovic MilosPaunovic requested review from a team and Malaydewangan09 December 8, 2025 07:03
@Malaydewangan09
Copy link
Member

@idivanshu, could you please add some unit tests for this? Thanks! 🙏

…n tests

- Removed deprecated @PluginProperty annotations from Copy.CopyObject fields
- Added runWithServerSideEncryption and runWithKmsKey tests to CopyTest
@idivanshu
Copy link
Contributor Author

@idivanshu, could you please add some unit tests for this? Thanks! 🙏

added tests

builder.serverSideEncryption(renderedSse);

if (renderedSse == ServerSideEncryption.AWS_KMS && this.to.kmsKeyId != null) {
String renderedKmsKeyId = runContext.render(this.to.kmsKeyId).as(String.class).orElse(null);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
String renderedKmsKeyId = runContext.render(this.to.kmsKeyId).as(String.class).orElse(null);
String rKmsKeyId = runContext.render(this.to.kmsKeyId).as(String.class).orElse(null);

Copy link
Member

@Malaydewangan09 Malaydewangan09 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, @idivanshu, just a last nitpick!

title = "Server side encryption to apply to the target object.",
description = "Example: AES256 or AWS_KMS"
)
private Property<ServerSideEncryption> serverSideEncryption;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets extract this to our own ENUM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/plugin Plugin-related issue or feature request kind/external Pull requests raised by community contributors

Projects

Status: To review

Development

Successfully merging this pull request may close these issues.

S3 Trigger - KMS key usage on moveTo

3 participants