AWS DynamoDB Construct Library
Add a DynamoDB table to your stack like so:
import dynamodb = require('@aws-cdk/aws-dynamodb');
const defaultTable = new dynamodb.Table(stack, 'TableName');
const customTable = new dynamodb.Table(stack, 'CustomTable', {
readCapacity: readUnits,
writeCapacity: writeUnits,
tableName: 'MyTableName'
})
Setup Auto Scaling for DynamoDB Table
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/
Setup via Constructor
import dynamodb = require('@aws-cdk/aws-dynamodb');
const customTable = new dynamodb.Table(stack, 'CustomTable', {
readCapacity: readUnits,
writeCapacity: writeUnits,
tableName: 'MyTableName',
readAutoScaling: {
minCapacity: 500,
maxCapacity: 5000,
targetValue: 75.0,
scaleInCooldown: 30,
scaleOutCooldown: 30,
scalingPolicyName: 'MyAwesomeReadPolicyName'
},
writeAutoScaling: {
minCapacity: 50,
maxCapacity: 500,
targetValue: 50.0,
scaleInCooldown: 10,
scaleOutCooldown: 10,
scalingPolicyName: 'MyAwesomeWritePolicyName'
},
});
Setup via addAutoScaling
import dynamodb = require('@aws-cdk/aws-dynamodb');
const customTable = new dynamodb.Table(stack, 'CustomTable', {
readCapacity: readUnits,
writeCapacity: writeUnits,
tableName: 'MyTableName'
});
table.addReadAutoScaling({
minCapacity: 500,
maxCapacity: 5000,
targetValue: 75.0,
scaleInCooldown: 30,
scaleOutCooldown: 30,
scalingPolicyName: 'MyAwesomeReadPolicyName'
});
table.addWriteAutoScaling({
minCapacity: 50,
maxCapacity: 500,
targetValue: 50.0,
scaleInCooldown: 10,
scaleOutCooldown: 10,
scalingPolicyName: 'MyAwesomeWritePolicyName'
});