aws / aws/aws-cdk

s3tables: make tableBucketName optional on TableBucket L2

Open
#37,747 1 comment 0 reactions 0 assignees View on GitHub
@aws-cdk/aws-s3tables-alpha effort/small p2
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
2d 3h
Merged PRs (30d)
83

Description

### Describe the feature

In `@aws-cdk/aws-s3tables-alpha`, `TableBucket` requires `tableBucketName` as a mandatory prop. This is inconsistent with `aws-s3.Bucket` and most other CDK L2s, where the resource name is optional and CDK (or CloudFormation) generates a unique name when omitted.

I would like `tableBucketName` to become optional. When omitted, CDK should auto-generate a unique name from the stack name + construct path that satisfies the [S3 Tables naming rules](https://docs.aws.amazon.com/AmazonS3/latest/userguide/s3-tables-buckets-naming.html#table-buckets-naming-rules) (3–63 chars, lowercase letters / digits / hyphens, alphanumeric edges).

### Use Case

Most CDK users do not care about the exact physical name of a table bucket — they just want a uniquely named bucket they can reference via the L2 instance. Forcing every caller to invent a unique name (and maintain global uniqueness across deployments) is friction not present in `aws-s3.Bucket`. Making the name optional enables ergonomic patterns like:

```ts
new TableBucket(this, 'MyBucket');
```

…matching the rest of the construct library.

### Proposed Solution

Make `TableBucketProps.tableBucketName` optional. Internally, when the user does not provide a name, generate one via `Names.uniqueResourceName(this, { maxLength: 63, allowedSpecialCharacters: '-', separator: '-' }).toLowerCase()` wrapped in `Lazy.string`, and pass `this.physicalName` to the underlying `CfnTableBucket`. This is the same pattern already used by:

- `aws-elasticloadbalancingv2.TrustStore` (L1 name required, L2 optional)
- `aws-cloudfront.RealtimeLogConfig`
- `aws-cloudfront.KeyValueStore`

The L1 (`AWS::S3Tables::TableBucket`) requires `TableBucketName` per CFN spec, so we cannot delegate to CloudFormation the way `aws-s3.Bucket` does — name generation must happen on the CDK side, but is fully internal.

### Other Information

- Backwards compatible: existing user code that passes `tableBucketName` continues to work unchanged.
- No feature flag needed: the change relaxes a requirement, never rejects previously accepted input.
- `@aws-cdk/aws-s3tables-alpha` is an alpha module so even breaking changes would be permitted (this one is not breaking).

### Acknowledgements

- [x] I may be able to implement this feature request
- [ ] This feature might incur a breaking change

### CDK version used

2.x (alpha module)

### Environment details (OS name and version, etc.)

n/a

Contributor guide

Open the contributing guide

Research direction

Start at the TableBucket and TableBucketProps entry points in @aws-cdk/aws-s3tables-alpha, then compare the named-resource L2 patterns cited in the issue: TrustStore, RealtimeLogConfig, and KeyValueStore. Done means explicit names still work, omitted names are generated within the stated S3 Tables constraints, and the package’s relevant tests pass.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
cloud, infrastructure
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
74/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.