Skip to content

fix(dynamodb): avoid TableGrantsProps deprecation warnings for TableV2 - #38399

Open
deveshsinghal09 wants to merge 1 commit into
aws:mainfrom
deveshsinghal09:fix/dynamodb-tablev2-deprecated-warnings
Open

fix(dynamodb): avoid TableGrantsProps deprecation warnings for TableV2#38399
deveshsinghal09 wants to merge 1 commit into
aws:mainfrom
deveshsinghal09:fix/dynamodb-tablev2-deprecated-warnings

Conversation

@deveshsinghal09

@deveshsinghal09 deveshsinghal09 commented Jul 24, 2026

Copy link
Copy Markdown

Issue # (if applicable)

Closes #37221

Summary

Fixes the aws-cdk-lib.aws_dynamodb.TableGrantsProps deprecation warnings emitted when using TableV2.

Problem

When using TableV2 (for instance, with DynamoEventSource), CDK internally calls table.grantStreamRead() which constructed TableGrantsProps using the explicitly deprecated policyResource and encryptedResource fields. This produced synthesis warnings that the user could not suppress:

[WARNING] aws-cdk-lib.aws_dynamodb.TableGrantsProps#policyResource is deprecated.
[WARNING] aws-cdk-lib.aws_dynamodb.TableGrantsProps#encryptedResource is deprecated.

Solution

Removed the explicit passing of the deprecated encryptedResource and policyResource from TableV2 and TableReplicaV2 constructors.
Since TableV2 (via CfnGlobalTable) natively implements IEncryptedResource (with grantOnKey) and IResourceWithPolicyV2 (with addToResourcePolicy), the IAM framework's native discovery inside TableGrants (via iam.EncryptedResources.of(this.table) and iam.ResourceWithPolicies.of(this.table)) will discover these resources automatically without them needing to be explicitly passed.

Changes

  • packages/aws-cdk-lib/aws-dynamodb/lib/table-v2.ts: Removed encryptedResource and policyResource fields when instantiating TableGrants.

@github-actions github-actions Bot added bug This issue is a bug. effort/small Small work item – less than a day of effort p2 labels Jul 24, 2026
@aws-cdk-automation
aws-cdk-automation requested a review from a team July 24, 2026 16:55
@github-actions github-actions Bot added the beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK label Jul 24, 2026

@aws-cdk-automation aws-cdk-automation left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The pull request linter fails with the following errors:

❌ Fixes must contain a change to a test file.
❌ Fixes must contain a change to an integration test file and the resulting snapshot.

If you believe this pull request should receive an exemption, please comment and provide a justification. A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed, add Clarification Request to a comment.

✅ A exemption request has been requested. Please wait for a maintainer's review.

@deveshsinghal09

Copy link
Copy Markdown
Author

Exemption Request: This PR fixes JSII deprecation warnings by removing the explicit passing of deprecated properties. It relies on existing native discovery of those properties, which is already covered by existing unit tests for the package.

@aws-cdk-automation aws-cdk-automation added the pr-linter/exemption-requested The contributor has requested an exemption to the PR Linter feedback. label Jul 24, 2026
TableV2 and TableReplicaV2 were explicitly passing the deprecated encryptedResource and policyResource to TableGrantsProps. This caused warnings during synthesis, especially when TableV2 was used as an event source for lambda.

Since TableV2 (via CfnGlobalTable) already natively implements IEncryptedResource (with grantOnKey) and IResourceWithPolicyV2 (with addToResourcePolicy), the IAM framework's native discovery in TableGrants will discover these resources automatically without them needing to be explicitly passed in TableGrantsProps.

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

Labels

beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK bug This issue is a bug. effort/small Small work item – less than a day of effort p2 pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. pr-linter/exemption-requested The contributor has requested an exemption to the PR Linter feedback.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

aws-dynamodb: TableV2 with DynamoEventSource triggers deprecated TableGrantsProps#policyResource and #encryptedResource warnings during synth

2 participants