Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in AWS by (19.1k points)

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?

I've updated to On-demand on AWS Console.

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

1 Answer

0 votes
by (44.4k points)

BillingMode: PAY_PER_REQUEST should be added to properties and then ProvisionedThroughput should be removed from both table properties and all GlobalSecondaryIndexes where they are specified. Your template should look something like this:

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

Related questions

Want to get 50% Hike on your Salary?

Learn how we helped 50,000+ professionals like you !

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...