0
0
AWScloud~30 mins

DynamoDB capacity modes (on-demand, provisioned) in AWS - Mini Project: Build & Apply

Choose your learning style9 modes available
DynamoDB Capacity Modes Setup
📖 Scenario: You are setting up a DynamoDB table for a new application. You need to create the table with initial data and then configure its capacity mode to handle traffic efficiently.
🎯 Goal: Build a DynamoDB table configuration with initial attributes and set its capacity mode to either on-demand or provisioned.
📋 What You'll Learn
Create a DynamoDB table named Users with a primary key UserId of type string.
Add a configuration variable capacity_mode to select between PAY_PER_REQUEST (on-demand) and PROVISIONED modes.
If capacity_mode is PROVISIONED, configure ReadCapacityUnits and WriteCapacityUnits with exact values.
Complete the table creation configuration including the capacity mode settings.
💡 Why This Matters
🌍 Real World
DynamoDB capacity modes help manage costs and performance for applications with varying traffic patterns.
💼 Career
Understanding how to configure DynamoDB tables with correct capacity modes is essential for cloud engineers and developers working with AWS.
Progress0 / 4 steps
1
Create DynamoDB table data structure
Create a dictionary called table_definition with the following keys and values exactly: TableName set to 'Users', KeySchema as a list with one dictionary having AttributeName as 'UserId' and KeyType as 'HASH', and AttributeDefinitions as a list with one dictionary having AttributeName as 'UserId' and AttributeType as 'S'.
AWS
Need a hint?

Use a dictionary with keys TableName, KeySchema, and AttributeDefinitions exactly as described.

2
Add capacity mode configuration variable
Add a variable called capacity_mode and set it to the string 'PAY_PER_REQUEST' to represent on-demand capacity mode.
AWS
Need a hint?

Set capacity_mode exactly to 'PAY_PER_REQUEST' to select on-demand mode.

3
Add provisioned capacity settings conditionally
Add a conditional block that checks if capacity_mode equals 'PROVISIONED'. Inside this block, add a key ProvisionedThroughput to table_definition with a dictionary value containing ReadCapacityUnits set to 5 and WriteCapacityUnits set to 5.
AWS
Need a hint?

Use an if statement to add ProvisionedThroughput only when capacity_mode is 'PROVISIONED'.

4
Complete table creation configuration with capacity mode
Add a key BillingMode to table_definition and set its value to the current capacity_mode variable.
AWS
Need a hint?

Assign capacity_mode to the BillingMode key in table_definition.