Skip to content

Conversation

xuxey
Copy link
Contributor

@xuxey xuxey commented Aug 12, 2025

Issue # (if applicable)

Related to #33054

Reason for this change

This PR includes backward-compatible changes being made to add L2 support for the CfnTable and CfnTablePolicy constructs with a consistent user interface, recommended defaults, and in-built validations for managing Table level IAM resource policies.

Description of changes

New L2 Construct: TablePolicy: defines an underlying CfnTablePolicy resource

New methods added to Table construct:

  • addToResourcePolicy: Attaches a policy statement to the Table's IAM policy
  • grantRead: Grants read access to the table for the given principal
  • grantWrite: Grants write access to the table for the given principal
  • grantReadWrite: Grants read and write access to the table for the given principal

Describe any new or updated permissions being added

Method IAM Actions Description
table.grantRead s3tables:Get* Grants read permission to S3 Table
table.grantWrite s3tables:PutTableData
s3tables:UpdateTableMetadataLocation
s3tables:RenameTable
Grants write permission to S3 Table
table.grantReadWrite s3tables:Get*
s3tables:PutTableData
s3tables:UpdateTableMetadataLocation
s3tables:CreateTable
Grants read and write permissions to S3 Table

Description of how you validated changes

  • Unit tests
  • Passing Integration tests with snapshots and assertions via API calls

Checklist


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

@github-actions github-actions bot added the p2 label Aug 12, 2025
@aws-cdk-automation aws-cdk-automation requested a review from a team August 12, 2025 18:48
@github-actions github-actions bot added the repeat-contributor [Pilot] contributed between 3-5 PRs to the CDK label Aug 12, 2025
@xuxey xuxey changed the title feat(s3-tables) Add TablePolicy support to L2 construct library feat(aws-s3tables-alpha): Add TablePolicy support to L2 construct library Aug 12, 2025
Copy link
Collaborator

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

Choose a reason for hiding this comment

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

(This review is outdated)

@xuxey xuxey changed the title feat(aws-s3tables-alpha): Add TablePolicy support to L2 construct library feat(s3tables-alpha): add TablePolicy support to L2 construct library Aug 12, 2025
@aws-cdk-automation aws-cdk-automation dismissed their stale review August 12, 2025 18:54

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

@xuxey xuxey marked this pull request as ready for review August 12, 2025 20:46
});
});

it('creates IAM policies for a role', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

For all the tests which add read/write permissions to the table, can we have a test which check that the role/user policy is affected inline in the cfn templates ? The addition of read/write permissions should affect the role/user policies by adding the S3 tables based policies

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These tests already check for the identity policy on the principal resource, and resource policy is only added as a fallback option. This behavior is documented more here: https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_iam.Grant.html#static-addwbrtowbrprincipalwbrorwbrresourceoptions

@kumvprat kumvprat added the needs-security-review Related to feature or issues that needs security review label Aug 18, 2025
Copy link
Contributor

mergify bot commented Aug 20, 2025

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

Copy link
Contributor

mergify bot commented Aug 20, 2025

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify mergify bot merged commit 2741dfb into aws:main Aug 20, 2025
18 checks passed
Copy link
Contributor

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 20, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs-security-review Related to feature or issues that needs security review p2 repeat-contributor [Pilot] contributed between 3-5 PRs to the CDK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants