Skip to main content

CDK Constructs for AWS DynamoDB

Project description

Amazon DynamoDB Construct Library


Stability: Stable


Here is a minimal deployable DynamoDB table definition:

# Example may have issues. See
import aws_cdk.aws_dynamodb as dynamodb

table = dynamodb.Table(self, "Table",
    partition_key={"name": "id", "type": dynamodb.AttributeType.STRING}


When a table is defined, you must define it's schema using the partitionKey (required) and sortKey (optional) properties.

Billing Mode

DynamoDB supports two billing modes:

  • PROVISIONED - the default mode where the table and global secondary indexes have configured read and write capacity.
  • PAY_PER_REQUEST - on-demand pricing and scaling. You only pay for what you use and there is no read and write capacity for the table or its global secondary indexes.
# Example may have issues. See
import aws_cdk.aws_dynamodb as dynamodb

table = dynamodb.Table(self, "Table",
    partition_key={"name": "id", "type": dynamodb.AttributeType.STRING},

Further reading:

Configure AutoScaling for your table

You can have DynamoDB automatically raise and lower the read and write capacities of your table by setting up autoscaling. You can use this to either keep your tables at a desired utilization level, or by scaling up and down at preconfigured times of the day:

Auto-scaling is only relevant for tables with the billing mode, PROVISIONED.

# Example may have issues. See
read_scaling = table.auto_scale_read_capacity(min_capacity=1, max_capacity=50)


    schedule=appscaling.Schedule.cron(hour="8", minute="0"),

    schedule=appscaling.Schedule.cron(hour="20", minute="0"),

Further reading:

Amazon DynamoDB Global Tables

Please see the @aws-cdk/aws-dynamodb-global package.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for, version 1.15.0
Filename, size File type Python version Upload date Hashes
Filename, size aws_cdk.aws_dynamodb-1.15.0-py3-none-any.whl (96.1 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size (98.8 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page