DynamoDB: can't change a Table from "Pay Per Request" to "Provisioned"
See original GitHub issuedescription of the bug:
I created a DynamoDB table via CDK in the past with the on-demand capacity and now want to change it to be of type provisioned. I added the CDK TypeScript code to change the billing mode to be provisioned and to add auto-scaling write and read capacity and when trying to deploy this, I get the following error:
4:15:27 PM | UPDATE_FAILED | AWS::DynamoDB::Table | PrivateTableName1234
The provisioned throughput for the table will not change.
The requested value equals the current value.
Current ReadCapacityUnits provisioned for the table: 5.
Requested ReadCapacityUnits: 5.
Current WriteCapacityUnits provisioned for the table: 5.
Requested WriteCapacityUnits: 5.
Refer to the Amazon DynamoDB Developer Guide for current limits and how to request higher limits.
(Service: AmazonDynamoDBv2; Status Code: 400; Error Code: ValidationException; Request ID: ###; Proxy: null)
new Table (/private_path/node_modules/monocdk/lib/aws-dynamodb/lib/table.js:456:22)
\_ new DynamoResourceBundle (/private_path/dist/lib/globalResources/dynamoResourceBundle.js:19:42)
\_ new GlobalStack (/private_path/dist/lib/stack/globalStack.js:14:38)
\_ addGlobalStack (/private_path/dist/lib/app.js:66:25)
\_ /private_path/dist/lib/app.js:37:16
\_ Array.map (<anonymous>)
\_ /private_path/dist/lib/app.js:36:55
\_ Array.forEach (<anonymous>)
\_ Object.<anonymous> (/private_path/dist/lib/app.js:34:29)
\_ Module._compile (internal/modules/cjs/loader.js:1085:14)
\_ Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
\_ Module.load (internal/modules/cjs/loader.js:950:32)
\_ Function.Module._load (internal/modules/cjs/loader.js:790:14)
\_ Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
\_ internal/main/run_main_module.js:17:47
❌ My-Stack-Name failed: Error: The stack named My-Stack-Name failed to deploy: UPDATE_ROLLBACK_COMPLETE
at Object.waitForStackDeploy (/another_private_path/build/private/cdk-cli/node_modules/aws-cdk/lib/api/util/cloudformation.ts:307:11)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at Object.deployStack (/another_private_path/build/private/cdk-cli/node_modules/aws-cdk/lib/api/deploy-stack.ts:294:26)
at CdkToolkit.deploy (/another_private_path/build/private/cdk-cli/node_modules/aws-cdk/lib/cdk-toolkit.ts:180:24)
at initCommandLine (/another_private_path/build/private/cdk-cli/node_modules/aws-cdk/bin/cdk.ts:212:9)
The stack named My-Stack-Name failed to deploy: UPDATE_ROLLBACK_COMPLETE
› Error: Failed to run application build system.
BUILD FAILED
*** command 'cdk-build' with arguments 'cdk deploy My-Stack-Name' exited with return code '1'
Reproduction Steps
Using the following code:
const table = new Table(stack, tableName, {
partitionKey: {name: partitionKey, type: AttributeType.STRING},
sortKey: {name: sortKey, type: AttributeType.STRING},
tableName: tableName,
pointInTimeRecovery: true,
replicationRegions: [AwsRegion.PDX, AwsRegion.DUB],
billingMode: BillingMode.PROVISIONED
});
table.autoScaleWriteCapacity({
minCapacity: 5,
maxCapacity: 10
}).scaleOnUtilization({targetUtilizationPercent: 75});
table.autoScaleReadCapacity({
minCapacity: 5,
maxCapacity: 10
}).scaleOnUtilization({targetUtilizationPercent: 75});
And running the following command:
cdk deploy My-Stack-Name
What did you expect to happen?
The table to be updated to be billing type provisioned and to have the corresponding min/max read/write auto-scaling units.
What actually happened?
The process throws the error listed above and:
- The billing mode does successfully change to Provisioned
- The auto-scaling min/max units are not updated
Environment
- CDK CLI Version : 1.110.0
- Framework Version:
- Node.js Version: v12.22.1
- OS : Linux
- Language (Version): Typescript 4.0.5
Other
I found a similar issue in the past so I tried to make sure I was using all the most updated versions of everything I could to include any bugfixes that were already merged in for this issue in the past: https://github.com/crossplane/provider-aws/issues/464
This is 🐛 Bug Report
Issue Analytics
- State:
- Created 2 years ago
- Comments:14 (7 by maintainers)
I was able to work around this issue by using the
CfnGlobalTable
class rather than theTable
class.Ensure your table’s
RemovalPolicy
is set toRETAINED
so it doesn’t get deleted, remove the Table object from your CDK code, and deploy the changes. This will remove the table from the Cloudformation template but NOT from your account. Now, add back your table in CDK but instead as aCfnGlobalTable
object rather than aTable
object. Ensure everything is the same (table name,BillingMode
settings, etc.) except remove any global replicas for now, and build the code. Grab the template file when you build the CDK code and import this template into Cloudformation using the AWS console. This process will find the existing table that is still in your account and add it back as a GlobalTable.Go back to your CDK code and add any changes you needed to, as now the
CfnGlobalTable
is much easier to work with. If your table has global replicas, add them back one at a time per build in CDK as Cloudformation doesn’t support adding more than one region at a time per deployment. Now all future changes you need to make in CDK are easier to make and deploy to Cloudformation.None of my proposals above worked. I eventually had to do this too.