Skip to content

Commit

Permalink
fix(dynamodb): cannot change serverSideEncryption from true to false
Browse files Browse the repository at this point in the history
When a table was deployed with `serverSideEncryption` set to `true` (by
requesting `AWS_MANAGED` or `CUSTOM` server side encryption), it was not
possible to switch back to `DEFAULT` as this could drop the
`serverSideEncryption` configuration altogether, which CloudFormation
will not allow.

This changes makes `Table` continue to not set the
`serverSideEncryption` configuration if nothing was configured (the user
chose the implicit default behavior), but to actually set the value
explicitly to `false` if the user *explicitly* requests `DEFAULT`
encryption.

This makes it possible to flip away from `AWS_MANAGED` and `CUSTOM`
encryption to the cheaper alternative that is `DEFAULT`.

Fixes #8286
  • Loading branch information
RomainMuller committed Jun 9, 2020
1 parent ed6f763 commit e7a6427
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/@aws-cdk/aws-dynamodb/lib/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1334,8 +1334,8 @@ export class Table extends TableBase {
encryptionType = props.encryptionKey != null
// If there is a configured encyptionKey, the encryption is implicitly CUSTOMER_MANAGED
? TableEncryption.CUSTOMER_MANAGED
// Otherwise, if severSideEncryption is enabled, it's AWS_MANAGED; else DEFAULT
: props.serverSideEncryption ? TableEncryption.AWS_MANAGED : TableEncryption.DEFAULT;
// Otherwise, if severSideEncryption is enabled, it's AWS_MANAGED; else undefined (do not set anything)
: props.serverSideEncryption ? TableEncryption.AWS_MANAGED : undefined;
}

if (encryptionType !== TableEncryption.CUSTOMER_MANAGED && props.encryptionKey) {
Expand Down Expand Up @@ -1363,6 +1363,9 @@ export class Table extends TableBase {
return { sseSpecification: { sseEnabled: true } };

case TableEncryption.DEFAULT:
return { sseSpecification: { sseEnabled: false } };

case undefined:
// Not specifying "sseEnabled: false" here because it would cause phony changes to existing stacks.
return { sseSpecification: undefined };

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,9 @@
"ProvisionedThroughput": {
"ReadCapacityUnits": 5,
"WriteCapacityUnits": 5
},
"SSESpecification": {
"SSEEnabled": false
}
},
"UpdateReplacePolicy": "Delete",
Expand Down

0 comments on commit e7a6427

Please sign in to comment.