From 3c7a89de6edaf7a1910bf716419dbe5568d79374 Mon Sep 17 00:00:00 2001 From: Ryan Allan <4126720+sudo-ryan@users.noreply.github.com> Date: Wed, 19 May 2021 23:42:02 +0100 Subject: [PATCH] feat(dynamodb): add ability to enable contributor insights on Table (#14742) Resolve https://github.com/aws/aws-cdk/issues/11626 *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- packages/@aws-cdk/aws-dynamodb/lib/table.ts | 8 ++++++++ packages/@aws-cdk/aws-dynamodb/test/dynamodb.test.ts | 2 ++ 2 files changed, 10 insertions(+) diff --git a/packages/@aws-cdk/aws-dynamodb/lib/table.ts b/packages/@aws-cdk/aws-dynamodb/lib/table.ts index 776159b110e27..7894994c98b36 100644 --- a/packages/@aws-cdk/aws-dynamodb/lib/table.ts +++ b/packages/@aws-cdk/aws-dynamodb/lib/table.ts @@ -224,6 +224,13 @@ export interface TableOptions { * @default Duration.minutes(30) */ readonly replicationTimeout?: Duration; + + /** + * Whether CloudWatch contributor insights is enabled. + * + * @default false + */ + readonly contributorInsightsEnabled?: boolean; } /** @@ -1114,6 +1121,7 @@ export class Table extends TableBase { sseSpecification, streamSpecification, timeToLiveSpecification: props.timeToLiveAttribute ? { attributeName: props.timeToLiveAttribute, enabled: true } : undefined, + contributorInsightsSpecification: props.contributorInsightsEnabled !== undefined ? { enabled: props.contributorInsightsEnabled } : undefined, }); this.table.applyRemovalPolicy(props.removalPolicy); diff --git a/packages/@aws-cdk/aws-dynamodb/test/dynamodb.test.ts b/packages/@aws-cdk/aws-dynamodb/test/dynamodb.test.ts index 31fb1d682d674..74d18e2dd28e3 100644 --- a/packages/@aws-cdk/aws-dynamodb/test/dynamodb.test.ts +++ b/packages/@aws-cdk/aws-dynamodb/test/dynamodb.test.ts @@ -330,6 +330,7 @@ test('when specifying every property', () => { timeToLiveAttribute: 'timeToLive', partitionKey: TABLE_PARTITION_KEY, sortKey: TABLE_SORT_KEY, + contributorInsightsEnabled: true, }); Tags.of(table).add('Environment', 'Production'); @@ -353,6 +354,7 @@ test('when specifying every property', () => { TableName: 'MyTable', Tags: [{ Key: 'Environment', Value: 'Production' }], TimeToLiveSpecification: { AttributeName: 'timeToLive', Enabled: true }, + ContributorInsightsSpecification: { Enabled: true }, }, ); });