Skip to content

feat: add ReplicaKey support for KMS key replication#112

Open
sandeepbathina wants to merge 13 commits intoaws-controllers-k8s:mainfrom
sandeepbathina:replica_key
Open

feat: add ReplicaKey support for KMS key replication#112
sandeepbathina wants to merge 13 commits intoaws-controllers-k8s:mainfrom
sandeepbathina:replica_key

Conversation

@sandeepbathina
Copy link
Copy Markdown

Issue #, if available:
aws-controllers-k8s/community#2664

Description of changes:
Add support for ReplicaKey resource to enable multi-region key management

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

@ack-prow
Copy link
Copy Markdown

ack-prow Bot commented Oct 28, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: sandeepbathina
Once this PR has been reviewed and has the lgtm label, please assign michaelhtm for approval by writing /assign @michaelhtm in a comment. For more information see the Kubernetes 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 requested review from a-hilaly and jlbutler October 28, 2025 16:49
@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 Oct 28, 2025
@ack-prow
Copy link
Copy Markdown

ack-prow Bot commented Oct 28, 2025

Hi @sandeepbathina. 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/test-infra repository.

@knottnt
Copy link
Copy Markdown

knottnt commented Oct 28, 2025

/ok-to-test

@ack-prow ack-prow Bot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Oct 28, 2025
@sandeepbathina
Copy link
Copy Markdown
Author

/retest

@sandeepbathina
Copy link
Copy Markdown
Author

/retest

4 similar comments
@sandeepbathina
Copy link
Copy Markdown
Author

/retest

@sandeepbathina
Copy link
Copy Markdown
Author

/retest

@sandeepbathina
Copy link
Copy Markdown
Author

/retest

@sandeepbathina
Copy link
Copy Markdown
Author

/retest

Copy link
Copy Markdown

@knottnt knottnt left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution @sandeepbathina!

Comment thread apis/v1alpha1/generator.yaml Outdated
find_operation:
custom_method_name: customFind
update_operation:
custom_method_name: updateNotSupported
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Q: Do ReplicaKeys support updating tags?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Similarly, from the ReplicateKey documentation it sounds like the Policy field is not replicated from the primary key. Does the PutKeyPolicy operation apply to replica keys as well?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yes, PutKeyPolicy works on replica keys. Added support for policy updates via customUpdate


Regex Pattern: `^[\u0009\u000A\u000D\u0020-\u00FF]+$`
type: string
replicaTags:
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This seems to be duplicating the spec.tags field. If this is due to a mismatch between the input and output field name we may want to configure a rename of the output field in the generator.yaml.

Docs on using field renames

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed! added output field rename in generator.yaml to avoid duplication.

format: date-time
type: string
type: object
replicaPolicy:
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This seems to be duplicating the spec.policy field. May need to rename the output field here as well.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed by adding output field rename.

class TestReplicaKey:
"""Test suite for ReplicaKey resource"""

def test_create_delete_replica_key(self, simple_replica_key):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This test should also check the state of the AWS resource out of band from ACK to validate that desired state is being correctly propagated. There should be a kms_client pytest fixture defined in tests/e2e/conftest.py.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thanks! added out of band validation using replica_kms_client which validates the AWS resource state directly. Used replica_kms_client instead of the kms_client fixture because the replica key exists in a different region. Let me know if I need to follow any other approach.

@knottnt
Copy link
Copy Markdown

knottnt commented Nov 10, 2025

/hold

@ack-prow ack-prow Bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 10, 2025
Copy link
Copy Markdown

@knottnt knottnt left a comment

Choose a reason for hiding this comment

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

@sandeepbathina Thanks for the contribution. Testing these changes locally I'm seeing some unexpected behavior with the Read, Update, and Delete calls interacting with the primary key instead of the replica.

build_date: "2025-10-31T03:59:17Z"
build_hash: eaabefb6bd7b2be8a1baf4478f22b3310e6921c8
go_version: go1.25.1
version: v0.52.0-6-geaabefb-dirty
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

It looks like there were some changes made to the code generator in the most recent build. If they aren't needed could you rebuild with a clean version of the code-generator?


var resp *svcsdk.ReplicateKeyOutput
_ = resp
resp, err = rm.sdkapi.ReplicateKey(ctx, input)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Looking at the documentation for ReplicateKey I think the way that API interacts with AWS regions require some extra work and possibly some runtime/code-generation improvements to properly model the replica key as its own resource. ReplicateKey needs to be called against the same region as the primary key. However, the resulting region is created in another AWS region. This means that the Read, Update, and Delete calls need to performed in the replica region. So, the ACK controller needs configure it's SDK client region specified by Spec.replicaRegion for these operations.

Testing this PR locally I'm seeing the Create operation successfully replicate the specified primary key. However, other operations continue to interact with the primary key. This appears to happen because the replica and primary keys share the same KeyID.

@ack-prow
Copy link
Copy Markdown

ack-prow Bot commented Feb 20, 2026

@sandeepbathina: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
kms-verify-attribution eb4057e link false /test kms-verify-attribution
kms-verify-code-gen eb4057e link false /test kms-verify-code-gen
kms-crd-compat-check eb4057e link true /test kms-crd-compat-check

Full PR test history. Your PR dashboard.

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/test-infra repository. I understand the commands that are listed here.

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

Labels

do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. ok-to-test Indicates a non-member PR verified by an org member that is safe to test.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants