- Newest
- Most votes
- Most comments
You must make CDK aware of seedCapacity before making the change:
https://github.com/aws/aws-cdk/issues/27735
table = new TableV2(this, props.tableName, { partitionKey: { name: props.partitionId, type: AttributeType.STRING }, sortKey: { name: props.sortId!, type: AttributeType.STRING }, removalPolicy: cdk.RemovalPolicy.DESTROY, billing: Billing.provisioned({ readCapacity: Capacity.autoscaled({maxCapacity: 25600, seedCapacity: 25600 }), writeCapacity: Capacity.autoscaled({ maxCapacity: 1600, seedCapacity: 1600}) }), // warmThroughput: { // readUnitsPerSecond: 25600, // writeUnitsPerSecond: 6400 // }, // billing: Billing.onDemand({ // maxReadRequestUnits: 25600, // maxWriteRequestUnits: 6400 // }), dynamoStream: StreamViewType.NEW_AND_OLD_IMAGES });
Then when you deploy, it will have knowledge of the capacity to set in-case of roll-back. Then deploy to on-demand:
table = new TableV2(this, props.tableName, { partitionKey: { name: props.partitionId, type: AttributeType.STRING }, sortKey: { name: props.sortId!, type: AttributeType.STRING }, removalPolicy: cdk.RemovalPolicy.DESTROY, warmThroughput: { readUnitsPerSecond: 25600, writeUnitsPerSecond: 6400 }, billing: Billing.onDemand({ maxReadRequestUnits: 25600, maxWriteRequestUnits: 6400 }), dynamoStream: StreamViewType.NEW_AND_OLD_IMAGES });
Also, you should be aware that warmThroughput and maxRead/WriteRequestUnits do no serve the same purpose.
When switching a DynamoDB table from provisioned capacity mode with autoscaling to on-demand mode using CDK, you need to specify a seedCapacity for each autoscaled resource. This is required so that CloudFormation can properly roll back if needed.
To fix your issue, you should modify your code to include the seedCapacity parameter in your on-demand configuration:
table = new TableV2(this, props.tableName, { partitionKey: { name: props.partitionId, type: AttributeType.STRING }, sortKey: { name: props.sortId!, type: AttributeType.STRING }, removalPolicy: cdk.RemovalPolicy.DESTROY, billing: Billing.onDemand({ maxReadRequestUnits: 25600, maxWriteRequestUnits: 6400, seedCapacity: { readCapacityUnits: 5, // Set an appropriate seed value writeCapacityUnits: 5 // Set an appropriate seed value } }), dynamoStream: StreamViewType.NEW_AND_OLD_IMAGES });
The seedCapacity parameter is crucial when changing from provisioned to on-demand mode or vice versa. It provides CloudFormation with the necessary information to handle the transition between capacity modes and ensures that if a rollback is needed, it has the appropriate capacity values to revert to.
When switching from provisioned to on-demand mode, it's also worth noting that:
- If you were using the console previously, auto scaling settings would be deleted
- If using CDK/CloudFormation, your previous auto scaling settings need to be preserved through the
seedCapacityparameter - The table will continue to deliver throughput consistent with the previously provisioned capacity during the transition
Sources
aws-cdk-lib.aws_dynamodb module · AWS CDK
Considerations when switching capacity modes in DynamoDB - Amazon DynamoDB
answered a year ago
Relevant content
asked 5 years ago
asked 7 years ago
- AWS OFFICIALUpdated 6 months ago
- AWS OFFICIALUpdated a year ago

This is actively wrong as
seedCapacityparameter does not exist on DynamoDBTableV2class.