Skip to content

Add streamResourcePolicy - #176

Open
purkhusid wants to merge 1 commit into
aws-controllers-k8s:mainfrom
purkhusid:feat/add-stream-resource-policy
Open

Add streamResourcePolicy#176
purkhusid wants to merge 1 commit into
aws-controllers-k8s:mainfrom
purkhusid:feat/add-stream-resource-policy

Conversation

@purkhusid

Copy link
Copy Markdown

What?

Fixes aws-controllers-k8s/community#2948

How?

Add a new streamResourcePolicy attribute to the Table CRD.

I would have preferred adding the property to the streamSpecification but I couldn't figure out how to add a custom nested field.

@ack-prow
ack-prow Bot requested review from a-hilaly and knottnt July 1, 2026 16:33
@ack-prow

ack-prow Bot commented Jul 1, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: purkhusid
Once this PR has been reviewed and has the lgtm label, please assign gustavodiaz7722 for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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 needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Jul 1, 2026
@ack-prow

ack-prow Bot commented Jul 1, 2026

Copy link
Copy Markdown

Hi @purkhusid. Thanks for your PR.

I'm waiting for a aws-controllers-k8s member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

## What?
Fixes aws-controllers-k8s/community#2948

## How?
Add a new `streamResourcePolicy` attribute to the Table CRD.

I would have preferred adding the property to the `streamSpecification` but I couldn't figure out how to add a custom nested field.
@purkhusid
purkhusid force-pushed the feat/add-stream-resource-policy branch from f487729 to 3eb4a86 Compare July 1, 2026 16:34
@knottnt knottnt self-assigned this Jul 2, 2026
@purkhusid

Copy link
Copy Markdown
Author

I'm running this patch in our clusters and it is working as expected. Would greatly appreciate a review.

@knottnt knottnt left a comment

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.

Thanks @purkhusid. Left a few comments.

Comment on lines +215 to +216
// Stream policy is desired but the stream ARN isn't available yet;
// requeue until DynamoDB Streams is enabled and the stream exists.

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: If the user hasn't enabled a stream for the table will this cause the table to perpetually requeue? Wondering if we should validate that spec.streamSpecificationEnabled is true when StreamResourcePolicy is not nil.

Comment thread generator.yaml
operation: PutResourcePolicy
path: Policy
compare:
is_ignored: true

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.

We've actually added an is_iam_policy config to instruct the code-generator to inject delta comparison logic similar to the compareResourcePolicyDocument hook. I believe you should be able to use that config here and for ResourcePolicy and remove the custom comparison hooks.

Suggested change
is_ignored: true
is_iam_policy: true

streamResourcePolicyDeferred := false
if delta.DifferentAt("Spec.StreamResourcePolicy") {
if latest.ko.Status.LatestStreamARN != nil && *latest.ko.Status.LatestStreamARN != "" {
if err = rm.syncStreamResourcePolicy(ctx, desired, latest); err != nil {

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: When disabling the stream for an existing table should we defer removal of the stream's resource policy until after the stream has been disabled? If we remove the resource policy before disabling the stream and then the controller fails to disable to stream we'd leave the resource in an exposed state.

Comment thread generator.yaml
# PutResourcePolicy against the stream ARN (Status.LatestStreamARN).
# There is no native input field for a stream policy, so this is a
# custom field synced entirely through hooks.
StreamResourcePolicy:

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.

It looks like the from config currently only supports top level fields. However, I believe the below could be used to inject the field into the `Spec.StreamSpecification object.

StreamSpecification.ResourcePolicy:
    type: "*string"
    set:
       - ignore: "all"

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.

The above would no longer inject the description from the API model for PutResourcePolicy, but we could use documentation.yaml to add a description for the field. You can find an example of that file in the rds-controller here.

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

Labels

needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[dynamodb] Allow resource policy for DynamoDB streams

2 participants