Amazon DynamoDB Construct Library
Here is a minimal deployable DynamoDB table definition:
import dynamodb = require('@aws-cdk/aws-dynamodb');
const table = new dynamodb.Table(this, 'Table', {
partitionKey: { name: 'id', type: dynamodb.AttributeType.STRING }
});
Keys
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.
import dynamodb = require('@aws-cdk/aws-dynamodb');
const table = new dynamodb.Table(this, 'Table', {
partitionKey: { name: 'id', type: dynamodb.AttributeType.STRING },
billingMode: dynamodb.BillingMode.PAY_PER_REQUEST
});
Further reading:
https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.ReadWriteCapacityMode.
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 of configuring autoscaling
Further reading:
https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/AutoScaling.html
https://aws.amazon.com/blogs/database/how-to-use-aws-cloudformation-to-configure-auto-scaling-for-amazon-dynamodb-tables-and-indexes/
Amazon DynamoDB Global Tables
Please see the @aws-cdk/aws-dynamodb-global
package.
1.0.0 (2019-07-09)
General Availability of the AWS Cloud Development Kit!! πππ₯π₯πΎπΎ
We are excited to announce the 1.0.0 release of the AWS CDK β
including GA support for TypeScript, JavaScript, and Python!
We want to thank all of our early customers, and the hundreds of contributors,
for all the help and support in making this release a reality.
Thank you for the patience to deal with the many, many breaking changes that happened along the way.
This product would not be what it is today if it weren't for all the feedback,
diligent issue reporting (bugs, missing features, unclear documentation, etc.),
and code contributions from the community.
Special thanks go out to a few of our most prolific contributors who went above and beyond to help improve the CDK:
1.0.0 is a huge milestone for us, but it's still only the beginning!
We are excited to continue evolving the CDK, to introduce support for new languages and capabilities,
and to continue working closely with the open-source community.
Bug Fixes
- cli: output message when successfully synthesizing multiple stacks (#3259) (0c30f12)
- python: Make sure stack name in the init template does not contain illegal characters (#3261) (7d22b2c)