Skip to content

feat: add settable retention period and encryption to Stream - #89

Open
michaelhtm wants to merge 1 commit into
aws-controllers-k8s:mainfrom
michaelhtm:feat/add-retention-encryption-to-stream
Open

michaelhtm wants to merge 1 commit into
aws-controllers-k8s:mainfrom
michaelhtm:feat/add-retention-encryption-to-stream

Conversation

@michaelhtm

Copy link
Copy Markdown
Member

Description of changes:
Retention period and KMS encryption are not part of CreateStream, so they
are exposed as settable Spec inputs (desiredRetentionPeriodHours,
desiredEncryptionType, encryptionKeyARN) applied via Increase/Decrease
StreamRetentionPeriod and Start/StopStreamEncryption in the update path. The
observed values remain in Status (retentionPeriodHours, encryptionType,
keyID). A KMS key ARN is required so the observed key matches the desired
value and the stream is not re-encrypted on every reconcile.

Resolves aws-controllers-k8s/community#2420

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@ack-prow
ack-prow Bot requested review from a-hilaly and sapphirew June 24, 2026 20:16
@ack-prow

ack-prow Bot commented Jun 24, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: michaelhtm

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ack-prow ack-prow Bot added the approved label Jun 24, 2026
@michaelhtm
michaelhtm force-pushed the feat/add-retention-encryption-to-stream branch from 878be2b to 8440de9 Compare June 24, 2026 21:01
Retention period and KMS encryption are not part of CreateStream, so they
are exposed as settable Spec inputs (desiredRetentionPeriodHours,
desiredEncryptionType, encryptionKeyARN) applied via Increase/Decrease
StreamRetentionPeriod and Start/StopStreamEncryption in the update path. The
observed values remain in Status (retentionPeriodHours, encryptionType,
keyID). A KMS key ARN is required so the observed key matches the desired
value and the stream is not re-encrypted on every reconcile.

Resolves aws-controllers-k8s/community#2420
@michaelhtm
michaelhtm force-pushed the feat/add-retention-encryption-to-stream branch from 8440de9 to 5016638 Compare June 24, 2026 22:20
@michaelhtm

Copy link
Copy Markdown
Member Author

/label release/minor

@ack-prow ack-prow Bot added the release/minor Indicates this PR should trigger a minor version release on merge. label Jun 26, 2026
# DesiredEncryptionType is KMS. A key *ARN* is required (aliases are
# rejected in the update hook) so the observed Status.KeyID matches the
# desired value and the controller does not re-encrypt on every reconcile.
EncryptionKeyARN:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should we label this as KMS key reference?

return ackerr.NewTerminalError(fmt.Errorf(
"encryptionKeyARN is required when desiredEncryptionType is KMS"))
}
if !strings.HasPrefix(*desired.ko.Spec.EncryptionKeyARN, "arn:") {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Q: What's the reason for performing this check in the controller instead of letting the AWS API perform the validation?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Also if EncryptionKeyARN should in fact not be an ARN it seems like we should change the name to EncryptionKeyID.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

EncryptionKeyARN needs to be in ARN format. Kinesis accepts EncryptionKeyID/Alias, but describe returns the ARN. This will cause a continuous drift. As a fix, we instead just validate the user will pass the kmsARN at all times

*desired.ko.Spec.DesiredEncryptionType == string(svcsdktypes.EncryptionTypeKms) {
if desired.ko.Spec.EncryptionKeyARN == nil {
return ackerr.NewTerminalError(fmt.Errorf(
"encryptionKeyARN is required when desiredEncryptionType is KMS"))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Q: Does Kinesis setup a default KMS key that the encryption type could apply to or is the KMS key always set by the user?



@dataclass
class KMS(Bootstrappable):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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


stream.wait_until_deleted(stream_name)

def test_retention_and_encryption(self):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In addition to checking that update reaches AWS it would be good to validate that the AWS resource returns to a synced state after each spec change.

@purkhusid

Copy link
Copy Markdown

Would be pretty great to get this in the next release if possible. Kinesis in ACK is very barebones at the moment.

@SIDN-Tim

Copy link
Copy Markdown

We are also waiting on the streamEncryption setting

@purkhusid

Copy link
Copy Markdown

Any chance this could get reviewed and merged?

@purkhusid

Copy link
Copy Markdown

Any chance that we could get this one and #91 looked at? The Kinesis controller is pretty much unusable since it is missing almost every configuration propery of a Kinesis stream.

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

Labels

approved release/minor Indicates this PR should trigger a minor version release on merge.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ACK Kinesis Controller - Missing fields from controller spec

5 participants