Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support DynamoDB PITR #701

Merged
merged 1 commit into from
Sep 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions packages/@aws-cdk/aws-dynamodb/lib/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ export interface TableProps {
*/
tableName?: string;

/**
* Whether point-in-time recovery is enabled.
* @default undefined, point-in-time recovery is disabled
*/
pitrEnabled?: boolean;

/**
* Whether server-side encryption is enabled.
* @default undefined, server-side encryption is disabled
Expand Down Expand Up @@ -122,6 +128,7 @@ export class Table extends Construct {
tableName: props.tableName,
keySchema: this.keySchema,
attributeDefinitions: this.attributeDefinitions,
pointInTimeRecoverySpecification: props.pitrEnabled ? { pointInTimeRecoveryEnabled: props.pitrEnabled } : undefined,
provisionedThroughput: { readCapacityUnits, writeCapacityUnits },
sseSpecification: props.sseEnabled ? { sseEnabled: props.sseEnabled } : undefined,
streamSpecification: props.streamSpecification ? { streamViewType: props.streamSpecification } : undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
"AttributeType": "N"
}
],
"PointInTimeRecoverySpecification": {
"PointInTimeRecoveryEnabled": true
},
"SSESpecification": {
"SSEEnabled": true
},
Expand Down
1 change: 1 addition & 0 deletions packages/@aws-cdk/aws-dynamodb/test/integ.dynamodb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const app = new App(process.argv);
const stack = new Stack(app, 'aws-cdk-dynamodb');

const table = new Table(stack, 'Table', {
pitrEnabled: true,
sseEnabled: true,
streamSpecification: StreamViewType.KeysOnly,
ttlAttributeName: 'timeToLive'
Expand Down
30 changes: 30 additions & 0 deletions packages/@aws-cdk/aws-dynamodb/test/test.dynamodb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,34 @@ export = {

test.done();
},
'point-in-time recovery is not enabled'(test: Test) {
const app = new TestApp();
new Table(app.stack, 'MyTable')
.addPartitionKey('partitionKey', KeyAttributeType.Binary)
.addSortKey('sortKey', KeyAttributeType.Number);
const template = app.synthesizeTemplate();

test.deepEqual(template, {
Resources: {
MyTable794EDED1: {
Type: 'AWS::DynamoDB::Table',
Properties: {
AttributeDefinitions: [
{ AttributeName: 'partitionKey', AttributeType: 'B' },
{ AttributeName: 'sortKey', AttributeType: 'N' }
],
KeySchema: [
{ AttributeName: 'partitionKey', KeyType: 'HASH' },
{ AttributeName: 'sortKey', KeyType: 'RANGE' }
],
ProvisionedThroughput: { ReadCapacityUnits: 5, WriteCapacityUnits: 5 },
}
}
}
});

test.done();
},
'server-side encryption is not enabled'(test: Test) {
const app = new TestApp();
new Table(app.stack, 'MyTable')
Expand Down Expand Up @@ -257,6 +285,7 @@ export = {
tableName: 'MyTable',
readCapacity: 42,
writeCapacity: 1337,
pitrEnabled: true,
sseEnabled: true,
streamSpecification: StreamViewType.KeysOnly,
ttlAttributeName: 'timeToLive'
Expand All @@ -282,6 +311,7 @@ export = {
ReadCapacityUnits: 42,
WriteCapacityUnits: 1337
},
PointInTimeRecoverySpecification: { PointInTimeRecoveryEnabled: true },
SSESpecification: { SSEEnabled: true },
StreamSpecification: { StreamViewType: 'KEYS_ONLY' },
TableName: 'MyTable',
Expand Down