You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(s3-tables): add KMS support for TableBucket L2 construct (#34281)
### Reason for this change
This adds support for encryption settings for TableBucket including providing KMS keys for server side encryption.
### Description of changes
L1 reference: [CfnTableBucket#encryptionConfiguration](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_s3tables.CfnTableBucket.html#encryptionconfiguration)
Backwards compatible changes were made to the TableBucket construct in the following places:
- TableBucketProps now include optional fields `encryption` and `encryptionKey`
- grant methods now provide permissions to the bucket encryptionKey, if applicable
- A new KMS key is created if the user provides KMS encryptionType but no key
- Updated README with rosetta support
#### Usage
```ts
// Provide a user defined KMS Key:
const key = new kms.Key(scope, 'UserKey', {});
const encryptedBucket = new TableBucket(scope, 'EncryptedTableBucket', {
tableBucketName: 'table-bucket-1',
encryption: TableBucketEncryption.KMS,
encryptionKey: key,
});
// This account principal will also receive kms:Decrypt access to the KMS key
encryptedBucket.grantRead(new iam.AccountPrincipal('123456789012'), '*');
// If no key is provided, one will be created automatically
const encryptedBucketAuto = new TableBucket(scope, 'EncryptedTableBucketAuto', {
tableBucketName: 'table-bucket-2',
encryption: TableBucketEncryption.KMS,
});
// Use S3 managed server side encryption (default)
const encryptedBucketDefault = new TableBucket(scope, 'EncryptedTableBucketDefault', {
tableBucketName: 'table-bucket-3',
encryption: TableBucketEncryption.S3_MANAGED,
});
```
### Describe any new or updated permissions being added
These permissions were added for KMS support:
```ts
export const KEY_READ_ACCESS = [
'kms:Decrypt',
];
export const KEY_WRITE_ACCESS = [
'kms:Decrypt',
'kms:GenerateDataKey*',
];
```
When grant methods are used, these policies are applied to the principal for the TableBucket's encryption key. For example, giving read access to an encrypted bucket without giving decrypt permissions to the bucket key will not be sufficient permissions for the principal to read the bucket data.
### Description of how you validated changes
- Added unit test coverage for all possible scenarios of bucket encryption config, as well as all grant methods for each valid encryption config.
- Added integration tests with snapshot and assertions. The assertions are currently disabled due to the aws-sdk version not supporting `GetTableBucketEncryptionCommand` but will be included once resolved.
### Checklist
- [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)
----
*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
encryption: TableBucketEncryption.S3_MANAGED, // Uses AES-256 encryption by default
96
+
});
97
+
```
98
+
99
+
When using KMS encryption (`TableBucketEncryption.KMS`), if no encryption key is provided, CDK will automatically create a new KMS key for the table bucket with necessary permissions.
100
+
101
+
```ts
102
+
// If no key is provided, one will be created automatically
0 commit comments