question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

DynamoDB: can't change a Table from "Pay Per Request" to "Provisioned"

See original GitHub issue

description 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:open
  • Created 2 years ago
  • Comments:14 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
mrgarcia1998commented, Jan 11, 2022

I was able to work around this issue by using the CfnGlobalTable class rather than the Table class.

Ensure your table’s RemovalPolicy is set to RETAINED 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 a CfnGlobalTable object rather than a Table 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.

0reactions
grant-dcommented, Sep 6, 2022

I was able to work around this issue by using the CfnGlobalTable class rather than the Table class.

None of my proposals above worked. I eventually had to do this too.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Considerations when changing read/write Capacity Mode
When you update a table from on-demand to provisioned mode: If you're using the console, DynamoDB recommends enabling auto scaling with the following...
Read more >
What happens to the data in an existing DynamoDB table ...
Right now the billing mode is set to PROVISIONED with auto scaling enabled. I am planning to change the billing mode to PAY_PER_REQUEST....
Read more >
Read/write capacity mode - Amazon DynamoDB - 亚马逊云科技
DynamoDB on -demand offers pay-per-request pricing for read and write requests so ... You can use auto scaling to adjust your table's provisioned...
Read more >
AWS DynamoDB Pay-Per-Request Billing Mode And On ...
Go to AWS Console and open up your DynamoDB table. Open Capacity Tab and look for Read/write capacity mode . Change Provisioned to...
Read more >
DynamoDB On-Demand Scaling vs Provisioned with Auto ...
This also brings a change in the cost structure for DynamoDB. ... DynamoDB will not scale your table provisioned capacity below this value....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found