File tree Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -604,7 +604,7 @@ export interface BucketProps {
604
604
* If you choose KMS, you can specify a KMS key via `encryptionKey`. If
605
605
* encryption key is not specified, a key will automatically be created.
606
606
*
607
- * @default BucketEncryption. Unencrypted
607
+ * @default - `Kms` if `encryptionKey` is specified, or ` Unencrypted` otherwise.
608
608
*/
609
609
readonly encryption ?: BucketEncryption ;
610
610
@@ -934,8 +934,11 @@ export class Bucket extends BucketBase {
934
934
encryptionKey ?: kms . IKey
935
935
} {
936
936
937
- // default to unencrypted.
938
- const encryptionType = props . encryption || BucketEncryption . Unencrypted ;
937
+ // default based on whether encryptionKey is specified
938
+ let encryptionType = props . encryption ;
939
+ if ( encryptionType === undefined ) {
940
+ encryptionType = props . encryptionKey ? BucketEncryption . Kms : BucketEncryption . Unencrypted ;
941
+ }
939
942
940
943
// if encryption key is set, encryption must be set to KMS.
941
944
if ( encryptionType !== BucketEncryption . Kms && props . encryptionKey ) {
Original file line number Diff line number Diff line change @@ -1370,4 +1370,14 @@ export = {
1370
1370
} ) ;
1371
1371
test . done ( ) ;
1372
1372
} ,
1373
+
1374
+ 'if a kms key is specified, it implies bucket is encrypted with kms (dah)' ( test : Test ) {
1375
+ // GIVEN
1376
+ const stack = new Stack ( ) ;
1377
+ const key = new kms . Key ( stack , 'k' ) ;
1378
+
1379
+ // THEN
1380
+ new Bucket ( stack , 'b' , { encryptionKey : key } ) ;
1381
+ test . done ( ) ;
1382
+ }
1373
1383
} ;
You can’t perform that action at this time.
0 commit comments