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

refactor(dynamodb): API cleanups #2905

Merged
merged 4 commits into from
Jun 18, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
22 changes: 11 additions & 11 deletions packages/@aws-cdk/aws-dynamodb/lib/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,28 +85,28 @@ export interface TableOptions {

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

/**
* Whether server-side encryption with an AWS managed customer master key is enabled.
* @default undefined, server-side encryption is enabled with an AWS owned customer master key
* @default - server-side encryption is enabled with an AWS owned customer master key
*/
readonly sseEnabled?: boolean;
readonly serverSideEncryption?: boolean;
eladb marked this conversation as resolved.
Show resolved Hide resolved

/**
* The name of TTL attribute.
* @default undefined, TTL is disabled
* @default - TTL is disabled
*/
readonly ttlAttributeName?: string;
readonly timeToLiveAttribute?: string;

/**
* When an item in the table is modified, StreamViewType determines what information
* is written to the stream for this table. Valid values for StreamViewType are:
* @default undefined, streams are disabled
*/
readonly streamSpecification?: StreamViewType;
readonly stream?: StreamViewType;
}

export interface TableProps extends TableOptions {
Expand Down Expand Up @@ -235,15 +235,15 @@ export class Table extends Resource {
attributeDefinitions: this.attributeDefinitions,
globalSecondaryIndexes: Lazy.anyValue({ produce: () => this.globalSecondaryIndexes }, { omitEmptyArray: true }),
localSecondaryIndexes: Lazy.anyValue({ produce: () => this.localSecondaryIndexes }, { omitEmptyArray: true }),
pointInTimeRecoverySpecification: props.pitrEnabled ? { pointInTimeRecoveryEnabled: props.pitrEnabled } : undefined,
pointInTimeRecoverySpecification: props.pointInTimeRecovery ? { pointInTimeRecoveryEnabled: props.pointInTimeRecovery } : undefined,
billingMode: this.billingMode === BillingMode.PayPerRequest ? this.billingMode : undefined,
provisionedThroughput: props.billingMode === BillingMode.PayPerRequest ? undefined : {
readCapacityUnits: props.readCapacity || 5,
writeCapacityUnits: props.writeCapacity || 5
},
sseSpecification: props.sseEnabled ? { sseEnabled: props.sseEnabled } : undefined,
streamSpecification: props.streamSpecification ? { streamViewType: props.streamSpecification } : undefined,
timeToLiveSpecification: props.ttlAttributeName ? { attributeName: props.ttlAttributeName, enabled: true } : undefined
sseSpecification: props.serverSideEncryption ? { sseEnabled: props.serverSideEncryption } : undefined,
streamSpecification: props.stream ? { streamViewType: props.stream } : undefined,
timeToLiveSpecification: props.timeToLiveAttribute ? { attributeName: props.timeToLiveAttribute, enabled: true } : undefined
});

if (props.tableName) { this.node.addMetadata('aws:cdk:hasPhysicalName', props.tableName); }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ new Table(stack, TABLE, {
});

const tableWithGlobalAndLocalSecondaryIndex = new Table(stack, TABLE_WITH_GLOBAL_AND_LOCAL_SECONDARY_INDEX, {
pitrEnabled: true,
sseEnabled: true,
streamSpecification: StreamViewType.KeysOnly,
pointInTimeRecovery: true,
serverSideEncryption: true,
stream: StreamViewType.KeysOnly,
billingMode: BillingMode.PayPerRequest,
ttlAttributeName: 'timeToLive',
timeToLiveAttribute: 'timeToLive',
partitionKey: TABLE_PARTITION_KEY,
sortKey: TABLE_SORT_KEY
});
Expand Down
8 changes: 4 additions & 4 deletions packages/@aws-cdk/aws-dynamodb/test/integ.dynamodb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ const table = new Table(stack, TABLE, {
});

const tableWithGlobalAndLocalSecondaryIndex = new Table(stack, TABLE_WITH_GLOBAL_AND_LOCAL_SECONDARY_INDEX, {
pitrEnabled: true,
sseEnabled: true,
streamSpecification: StreamViewType.KeysOnly,
ttlAttributeName: 'timeToLive',
pointInTimeRecovery: true,
serverSideEncryption: true,
stream: StreamViewType.KeysOnly,
timeToLiveAttribute: 'timeToLive',
partitionKey: TABLE_PARTITION_KEY,
sortKey: TABLE_SORT_KEY
});
Expand Down
16 changes: 8 additions & 8 deletions packages/@aws-cdk/aws-dynamodb/test/test.dynamodb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ export = {
tableName: TABLE_NAME,
readCapacity: 42,
writeCapacity: 1337,
streamSpecification: StreamViewType.NewAndOldImages,
stream: StreamViewType.NewAndOldImages,
partitionKey: TABLE_PARTITION_KEY,
sortKey: TABLE_SORT_KEY
});
Expand Down Expand Up @@ -251,7 +251,7 @@ export = {
tableName: TABLE_NAME,
readCapacity: 42,
writeCapacity: 1337,
streamSpecification: StreamViewType.NewImage,
stream: StreamViewType.NewImage,
partitionKey: TABLE_PARTITION_KEY,
sortKey: TABLE_SORT_KEY
});
Expand Down Expand Up @@ -281,7 +281,7 @@ export = {
tableName: TABLE_NAME,
readCapacity: 42,
writeCapacity: 1337,
streamSpecification: StreamViewType.OldImage,
stream: StreamViewType.OldImage,
partitionKey: TABLE_PARTITION_KEY,
sortKey: TABLE_SORT_KEY
});
Expand Down Expand Up @@ -311,11 +311,11 @@ export = {
tableName: TABLE_NAME,
readCapacity: 42,
writeCapacity: 1337,
pitrEnabled: true,
sseEnabled: true,
pointInTimeRecovery: true,
serverSideEncryption: true,
billingMode: BillingMode.Provisioned,
streamSpecification: StreamViewType.KeysOnly,
ttlAttributeName: 'timeToLive',
stream: StreamViewType.KeysOnly,
timeToLiveAttribute: 'timeToLive',
partitionKey: TABLE_PARTITION_KEY,
sortKey: TABLE_SORT_KEY,
});
Expand Down Expand Up @@ -1179,7 +1179,7 @@ export = {
name: 'id',
type: AttributeType.String
},
streamSpecification: StreamViewType.NewImage
stream: StreamViewType.NewImage
});
const user = new iam.User(stack, 'user');

Expand Down