Skip to content

Commit

Permalink
fixing dynamo tag implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
moofish32 committed Jan 16, 2019
1 parent 419a701 commit 0a0d010
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
9 changes: 1 addition & 8 deletions packages/@aws-cdk/aws-dynamodb/lib/table.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import appscaling = require('@aws-cdk/aws-applicationautoscaling');
import iam = require('@aws-cdk/aws-iam');
import cdk = require('@aws-cdk/cdk');
import { Construct, TagManager, Tags, Token } from '@aws-cdk/cdk';
import { Construct, Token } from '@aws-cdk/cdk';
import { CfnTable } from './dynamodb.generated';
import { EnableScalingProps, IScalableTableAttribute } from './scalable-attribute-api';
import { ScalableTableAttribute } from './scalable-table-attribute';
Expand Down Expand Up @@ -88,12 +88,6 @@ export interface TableProps {
*/
streamSpecification?: StreamViewType;

/**
* The AWS resource tags to associate with the table.
* @default undefined
*/
tags?: Tags;

/**
* The name of TTL attribute.
* @default undefined, TTL is disabled
Expand Down Expand Up @@ -216,7 +210,6 @@ export class Table extends Construct {
},
sseSpecification: props.sseEnabled ? { sseEnabled: props.sseEnabled } : undefined,
streamSpecification: props.streamSpecification ? { streamViewType: props.streamSpecification } : undefined,
tags: new TagManager(this, { initialTags: props.tags }),
timeToLiveSpecification: props.ttlAttributeName ? { attributeName: props.ttlAttributeName, enabled: true } : undefined
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { App, Stack } from '@aws-cdk/cdk';
import { App, Stack, Tag } from '@aws-cdk/cdk';
import { Attribute, AttributeType, BillingMode, ProjectionType, StreamViewType, Table } from '../lib';

// CDK parameters
Expand Down Expand Up @@ -48,11 +48,12 @@ const tableWithGlobalAndLocalSecondaryIndex = new Table(stack, TABLE_WITH_GLOBAL
pitrEnabled: true,
sseEnabled: true,
streamSpecification: StreamViewType.KeysOnly,
tags: { Environment: 'Production' },
billingMode: BillingMode.PayPerRequest,
ttlAttributeName: 'timeToLive'
});

tableWithGlobalAndLocalSecondaryIndex.apply(new Tag('Environment', 'Production'));

tableWithGlobalAndLocalSecondaryIndex.addPartitionKey(TABLE_PARTITION_KEY);
tableWithGlobalAndLocalSecondaryIndex.addSortKey(TABLE_SORT_KEY);
tableWithGlobalAndLocalSecondaryIndex.addGlobalSecondaryIndex({
Expand Down
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-dynamodb/test/integ.dynamodb.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { App, Stack } from '@aws-cdk/cdk';
import { App, Stack, Tag } from '@aws-cdk/cdk';
import { Attribute, AttributeType, ProjectionType, StreamViewType, Table } from '../lib';

// CDK parameters
Expand Down Expand Up @@ -47,10 +47,10 @@ const tableWithGlobalAndLocalSecondaryIndex = new Table(stack, TABLE_WITH_GLOBAL
pitrEnabled: true,
sseEnabled: true,
streamSpecification: StreamViewType.KeysOnly,
tags: { Environment: 'Production' },
ttlAttributeName: 'timeToLive'
});

tableWithGlobalAndLocalSecondaryIndex.apply(new Tag('Environment', 'Production'));
tableWithGlobalAndLocalSecondaryIndex.addPartitionKey(TABLE_PARTITION_KEY);
tableWithGlobalAndLocalSecondaryIndex.addSortKey(TABLE_SORT_KEY);
tableWithGlobalAndLocalSecondaryIndex.addGlobalSecondaryIndex({
Expand Down
12 changes: 9 additions & 3 deletions packages/@aws-cdk/aws-dynamodb/test/test.dynamodb.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect, haveResource } from '@aws-cdk/assert';
import iam = require('@aws-cdk/aws-iam');
import { App, Stack } from '@aws-cdk/cdk';
import { App, Stack, Tag } from '@aws-cdk/cdk';
import { Test } from 'nodeunit';
import {
Attribute,
Expand Down Expand Up @@ -391,11 +391,11 @@ export = {
sseEnabled: true,
billingMode: BillingMode.Provisioned,
streamSpecification: StreamViewType.KeysOnly,
tags: { Environment: 'Production' },
ttlAttributeName: 'timeToLive'
});
table.addPartitionKey(TABLE_PARTITION_KEY);
table.addSortKey(TABLE_SORT_KEY);
table.apply(new Tag('Environment', 'Production'));
const template = app.synthesizeTemplate();

test.deepEqual(template, {
Expand Down Expand Up @@ -1357,12 +1357,18 @@ export = {
},
};

class TestStack extends Stack {
public testInvokeAspects() {
this.invokeAspects();
}
}
class TestApp {
private readonly app = new App();
// tslint:disable-next-line:member-ordering
public readonly stack: Stack = new Stack(this.app, STACK_NAME);
public readonly stack: TestStack = new TestStack(this.app, STACK_NAME);

public synthesizeTemplate() {
this.stack.testInvokeAspects();
return this.app.synthesizeStack(this.stack.name).template;
}
}
Expand Down

0 comments on commit 0a0d010

Please sign in to comment.