docs(s3,kms): replace object-literal IResourceWithPolicyV2 example with named class - #38461
Open
AmariahAK wants to merge 1 commit into
Open
docs(s3,kms): replace object-literal IResourceWithPolicyV2 example with named class#38461AmariahAK wants to merge 1 commit into
AmariahAK wants to merge 1 commit into
Conversation
aws-cdk-automation
requested changes
Jul 31, 2026
aws-cdk-automation
left a comment
Collaborator
There was a problem hiding this comment.
The pull request linter fails with the following errors:
❌ The title prefix of this pull request must be one of "feat|fix|build|chore|ci|docs|style|refactor|perf|test|revert"
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.
|
@AmariahAK - for cleanliness, instead of a merge from main, could you rebase instead and push (force with lease) a single squashed commit? |
AmariahAK
force-pushed
the
docs/s3-kms-replace-object-literal
branch
from
August 2, 2026 11:51
91fdb32 to
868d325
Compare
…th named class The object-literal pattern with inline methods in the forResource() return value does not translate across jsii/rosetta to non-TypeScript languages (Ruby, Python, Java, C#, Go). Replace it with a proper MyResourceWithPolicy class that implements IResourceWithPolicyV2, matching the existing CfnBucketWithPolicy and CfnKeyWithPolicy patterns in default-traits.ts. closes aws#38452 Co-authored-by: atlarix-agent <agent@atlarix.dev>
AmariahAK
force-pushed
the
docs/s3-kms-replace-object-literal
branch
from
August 2, 2026 12:10
79fe45c to
ac26af6
Compare
Author
|
@omarqureshi should be good now |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Closes #38452
Reason for this change
The
IResourcePolicyFactory/IResourceWithPolicyV2usage example in the S3and KMS READMEs used a TypeScript object-literal-with-inline-method pattern
for the return value of
forResource():While this satisfies the structural interface in TypeScript, jsii/Rosetta
cannot translate anonymous objects with methods to other languages. The
generated Ruby docs showed an inline
definside a hash, Python had rawfunction bodies inside dicts, and Java produced
Map.of()with a brokenmethod body. See the full breakdown in #38452.
Description of changes
Updated the
nofixturecode blocks in both READMEs to use a proper namedclass
MyResourceWithPolicythat explicitly implementsIResourceWithPolicyV2:packages/aws-cdk-lib/aws-s3/README.md— replaced object-literal withMyResourceWithPolicyclasspackages/aws-cdk-lib/aws-kms/README.md— identical fix, adapted forAWS::KMS::KeyBoth now follow the same class-based pattern as
CfnBucketWithPolicyandCfnKeyWithPolicyin their respectivedefault-traits.tssource files.Additional imports added:
AddToResourcePolicyResult(fromaws-cdk-lib/aws-iam) andResourceEnvironment(fromaws-cdk-lib/interfaces). Removed unusedIConstructimport.Note: this is NOT the full fix for #38452. This PR only addresses the
README examples. The Rosetta transpiler itself still has bugs in the C#,
Golang, and Java targets (e.g.
resource = resource;self-assignment in C#,incorrect pointer usage in Go, missing
getEnv()in Java) that will need aseparate PR in the Rosetta codebase. See @omarqureshi's analysis in the issue
for details on those remaining transpiler issues.
Describe any new or updated permissions being added
None — documentation-only change.
Description of how you validated changes
CfnBucketWithPolicyand
CfnKeyWithPolicyimplementations indefault-traits.tsexactlyAddToResourcePolicyResult,ResourceEnvironment,IResourceWithPolicyV2,IResourcePolicyFactory,PolicyStatement,ResourceWithPolicies) are exported from theirrespective modules
idiomatic Ruby, Python, and Java for the class-based pattern
yarn rosetta:extract --strict) should be runon a machine with ≥16GB RAM to verify cross-language translation before
merge
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license