I've seen this site about DynamoDB On-demand and I updated my tables, created by CloudFormation, to On-demand. Now, when I try to update my Stack, I get this error:
One or more parameter values were invalid: Neither ReadCapacityUnits nor WriteCapacityUnits can be specified when BillingMode is PAY_PER_REQUEST
Is there a way to set DynamoDB Read/write capacity mode to On-demand on CloudFormation?
EDIT:
I've updated to On-demand on AWS Console.
EDIT 2:
My template:
DynamoDBUsersTable: Type: AWS::DynamoDB::Table Description: Users table Properties: TableName: !Sub ${StackName}-users-table AttributeDefinitions: - AttributeName: userId AttributeType: S KeySchema: - AttributeName: userId KeyType: HASH ProvisionedThroughput: ReadCapacityUnits: 10 WriteCapacityUnits: 10
Thank you.
If you need to write an item that is larger than 1 KB, DynamoDB must consume additional write capacity units. Transactional write requests require 2 write capacity units to perform one write per second for items up to 1 KB. The total number of write capacity units required depends on the item size.
When you purchase reserved capacity, you must designate an AWS Region, quantity, and term. You will be charged (1) a one-time upfront fee, and (2) an hourly fee for each hour during the term based on the amount of DynamoDB reserved capacity you purchase.
There are two selectable capacity modes in DynamoDB: Provisioned and On-Demand. While On-demand is perfect for unpredictable workloads with sudden spikes of traffic, the provisioned mode is cheaper and better suited for workloads with predictable traffic.
You need to add BillingMode: PAY_PER_REQUEST
to properties and remove ProvisionedThroughput
both from table properties and from all GlobalSecondaryIndexes
if they specified. So finally your template have to look like:
DynamoDBUsersTable: Type: AWS::DynamoDB::Table Description: Users table Properties: TableName: !Sub ${StackName}-users-table BillingMode: PAY_PER_REQUEST AttributeDefinitions: - AttributeName: userId AttributeType: S KeySchema: - AttributeName: userId KeyType: HASH
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With