feat(s3tables): make tableBucketName optional on TableBucket#37749
Open
badmintoncryer wants to merge 4 commits into
Open
feat(s3tables): make tableBucketName optional on TableBucket#37749badmintoncryer wants to merge 4 commits into
badmintoncryer wants to merge 4 commits into
Conversation
Aligns the `TableBucket` L2 with `aws-s3.Bucket` and most other CDK L2s where the resource name is optional. When `tableBucketName` is not provided, CDK now generates a unique name from the stack name and construct path that satisfies the S3 Tables naming rules (3-63 chars, lowercase letters/digits/hyphens, alphanumeric edges). The underlying `AWS::S3Tables::TableBucket` requires `TableBucketName` in the CFN spec, so name generation happens on the CDK side via `Names.uniqueResourceName` wrapped in `Lazy.string`, mirroring the pattern already used by `TrustStore`, `RealtimeLogConfig`, and `KeyValueStore`. Backwards compatible: existing code passing `tableBucketName` is unaffected. closes aws#37747
Contributor
|
|
||||||||||||||
Contributor
|
|
||||||||||||||
Mix the optional-name note inline as a comment on the tableBucketName field (drops the standalone paragraph and the extra auto-named example). Drop unit tests that asserted naming-rule regex, no-throw, and the cross-env ARN path — those are covered by the integ assertion and the existing distinct-name test.
…ross renames Address review feedback on aws#37747: clarify in the README and the `tableBucketName` JSDoc that the auto-generated name derives from the construct path, so renaming the stack or construct produces a different name and replaces the bucket. Users who need a stable identifier should pass `tableBucketName` explicitly.
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.
Issue # (if applicable)
Closes #37747.
Reason for this change
@aws-cdk/aws-s3tables-alpha'sTableBucketrequirestableBucketNameas a mandatory prop, which is inconsistent withaws-s3.Bucketand the majority of CDK L2 constructs where the resource name is optional. Forcing every caller to invent a globally-unique name is friction that does not exist forBucketand other comparable resources.Description of changes
TableBucketProps.tableBucketNameis nowstring?(optional). Existing code that passestableBucketNameis unaffected.tableBucketName, the constructor generates a unique name via:autonamedteststack-autonamedbucket-ab3a2b45.CfnTableBucketnow receivesthis.physicalName(instead ofprops.tableBucketName), so user-supplied and auto-generated paths are unified. This is the same pattern asaws-s3.Bucket(bucketName: this.physicalName).Why
Lazy.string+Names.uniqueResourceNameand notPhysicalName.GENERATE_IF_NEEDED?AWS::S3Tables::TableBucketrequiresTableBucketNameper the CFN spec (seecdk.requiredValidatorin the generated L1).PhysicalName.GENERATE_IF_NEEDEDonly triggersgeneratePhysicalName()for cross-environment references; for same-env usage it leaves the name asundefined, which fails L1 synthesis. We therefore need eager generation. TheLazy.string + Names.uniqueResourceNamepattern is exactly what other L2s in this situation use:aws-elasticloadbalancingv2.TrustStorepackages/aws-cdk-lib/aws-elasticloadbalancingv2/lib/alb/trust-store.tsaws-cloudfront.RealtimeLogConfigpackages/aws-cdk-lib/aws-cloudfront/lib/realtime-log-config.tsaws-cloudfront.KeyValueStorepackages/aws-cdk-lib/aws-cloudfront/lib/key-value-store.tsDescribe any new or updated permissions being added
None.
Description of how you validated changes
Add both unit and integ tests.
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license