Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot change DynamoDB serverSideEncryption from true to false #8286

Closed
kennu opened this issue May 31, 2020 · 9 comments · Fixed by #8450
Closed

Cannot change DynamoDB serverSideEncryption from true to false #8286

kennu opened this issue May 31, 2020 · 9 comments · Fixed by #8450
Assignees
Labels
@aws-cdk/aws-dynamodb Related to Amazon DynamoDB bug This issue is a bug. effort/medium Medium work item – several days of effort in-progress This issue is being actively worked on. p2

Comments

@kennu
Copy link

kennu commented May 31, 2020

When you have already deployed a DynamoDB table with serverSideEncryption: true, you cannot change it to false. Changing it to false results in a CloudFormation deploy error. This most likely happens because AWS CDK removes the underlying CloudFormation property SSESpecification / SSEEnabled instead of setting it to false at https://github.com/aws/aws-cdk/blob/master/packages/%40aws-cdk/aws-dynamodb/lib/table.ts#L1355

I have successfully changed the CloudFormation property SSESpecification / SSEEnabled: true to false when using CloudFormation directly. And I also get the same error if I try to remove the property completely.

I think AWS CDK needs some way to configure DynamoDB Tables so that the SSESpecification / SSEEnabled: false property is included in the CloudFormation stack.

PS: The reason to change serverSideEncryption to false is that it results in DEFAULT encryption being used, which doesn't cost anything. When serverSideEncryption is true, the mode is KMS - AWS managed CMK and AWS charges you for it. At least that's what the DynamoDB console says.

Reproduction Steps

  1. Deploy a DynamoDB table with serverSideEncryption: true
  2. Change it to serverSideEncryption: false and try to deploy the update

Error Log

CloudFormation error when deploying update:

At least one of ProvisionedThroughput, BillingMode, UpdateStreamEnabled, GlobalSecondaryIndexUpdates or SSESpecification or ReplicaUpdates is required (Service: AmazonDynamoDBv2; Status Code: 400; Error Code: ValidationException

Environment

  • CLI Version : 1.42.0 (build 3b64241)
  • Framework Version: 1.42.0
  • OS : Linux
  • Language : TypeScript

Other


This is 🐛 Bug Report

@kennu kennu added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels May 31, 2020
@SomayaB SomayaB added the @aws-cdk/aws-dynamodb Related to Amazon DynamoDB label Jun 1, 2020
@RomainMuller
Copy link
Contributor

Oh in my previous works there I tried to specifically avoid setting the key (because changing that property is documented to cause "some interruption"). It's pretty unfortunate that removing the key causes breakage, especially since for recent tables, "not specified" defaults to false.

@RomainMuller RomainMuller added p1 p2 and removed needs-triage This issue or PR still needs to be triaged. p1 labels Jun 9, 2020
@kennu
Copy link
Author

kennu commented Jun 9, 2020

It is definitely a good idea to originally not set the key at all. Unfortunately in my case I have a lot of tables that have set the key to true, which I'm now trying to set to false.

@RomainMuller
Copy link
Contributor

@kennu - I wonder if we can have it not set when the default is in use, and set to false when the user was explicit about it. That seems consistent with intent and would get you out of trouble, right?

RomainMuller added a commit that referenced this issue Jun 9, 2020
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
@kennu
Copy link
Author

kennu commented Jun 9, 2020

That sounds good to me, mirroring how it works in CloudFormation.

@SomayaB SomayaB added the in-progress This issue is being actively worked on. label Jun 11, 2020
@jogold
Copy link
Contributor

jogold commented Jun 17, 2020

Has this CF behavior been updated in v15.1.0 maybe? https://github.com/aws/aws-cdk/blob/50f4a21f1b103910f029328d84347c5bfa0c7d56/packages/%40aws-cdk/cfnspec/CHANGELOG.md

  • AWS::DynamoDB::Table SSESpecification.UpdateType (changed)
    • Old: Conditional
    • New: Mutable

@RomainMuller
Copy link
Contributor

@kennu - would you be able to verify?

@kennu
Copy link
Author

kennu commented Jun 25, 2020

Hmm... What should I be checking? Latest AWS CDK 1.47.0 still removes the {"SSEEnabled":true} attribute and gives the same "At least one of..." error on deployment if I set serverSideEncryption to false.

@RomainMuller RomainMuller added the effort/medium Medium work item – several days of effort label Aug 11, 2020
@SomayaB SomayaB assigned skinny85 and unassigned RomainMuller Aug 20, 2020
@qchero
Copy link

qchero commented Sep 14, 2020

The other question is why the removal of SSESpecification cause issues? SSESpecification is an optional key. Setting it
with SSEEnabled: false or removing it has the same effect.

The error message doesn't make sense, because ProvisionedThroughput or BillingMode is still there.

At least one of ProvisionedThroughput, BillingMode, UpdateStreamEnabled, GlobalSecondaryIndexUpdates or SSESpecification or ReplicaUpdates is required (Service: AmazonDynamoDBv2; Status Code: 400; Error Code: ValidationException

Is this a bug in DynamoDB CloudFormation?

@mergify mergify bot closed this as completed in #8450 Sep 21, 2020
mergify bot pushed a commit that referenced this issue Sep 21, 2020
…8450)

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


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@kennu
Copy link
Author

kennu commented Dec 9, 2020

I finally realized how this works. I replaced this:

      serverSideEncryption: true,

with this:

      encryption: TableEncryption.DEFAULT,

And now I'm able to restore the default encryption mode for my tables. Thanks for fixing it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-dynamodb Related to Amazon DynamoDB bug This issue is a bug. effort/medium Medium work item – several days of effort in-progress This issue is being actively worked on. p2
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants