Skip to content

Commit 774b75c

Browse files
committed
PR feedback
1 parent 8ff9b21 commit 774b75c

File tree

4 files changed

+11
-14
lines changed

4 files changed

+11
-14
lines changed

source/patterns/@aws-solutions-constructs/aws-dynamodb-stream-lambda-elasticsearch-kibana/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ _Parameters_
7474
| **Name** | **Type** | **Description** |
7575
|:-------------|:----------------|-----------------|
7676
|dynamoTableInterface|[`dynamodb.ITable`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-dynamodb.ITable.html)|Returns an instance of dynamodb.ITable created by the construct|
77-
|dynamoTable?|[`dynamodb.Table`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-dynamodb.Table.html)|Returns an instance of dynamodb.Table created by the construct|
77+
|dynamoTable?|[`dynamodb.Table`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-dynamodb.Table.html)|Returns an instance of dynamodb.Table created by the construct. IMPORTANT: If existingTableInterface was provided in Pattern Construct Props, this property will be `undefined`|
7878
|lambdaFunction|[`lambda.Function`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-lambda.Function.html)|Returns an instance of lambda.Function created by the construct|
7979
|userPool|[`cognito.UserPool`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-cognito.UserPool.html)|Returns an instance of cognito.UserPool created by the construct|
8080
|userPoolClient|[`cognito.UserPoolClient`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-cognito.UserPoolClient.html)|Returns an instance of cognito.UserPoolClient created by the construct|

source/patterns/@aws-solutions-constructs/aws-dynamodb-stream-lambda/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ _Parameters_
6666
| **Name** | **Type** | **Description** |
6767
|:-------------|:----------------|-----------------|
6868
|dynamoTableInterface|[`dynamodb.ITable`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-dynamodb.ITable.html)|Returns an instance of dynamodb.ITable created by the construct|
69-
|dynamoTable?|[`dynamodb.Table`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-dynamodb.Table.html)|Returns an instance of dynamodb.Table created by the construct|
69+
|dynamoTable?|[`dynamodb.Table`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-dynamodb.Table.html)|Returns an instance of dynamodb.Table created by the construct. IMPORTANT: If existingTableInterface was provided in Pattern Construct Props, this property will be `undefined`|
7070
|lambdaFunction|[`lambda.Function`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-lambda.Function.html)|Returns an instance of lambda.Function created by the construct|
7171

7272
## Lambda Function

source/patterns/@aws-solutions-constructs/aws-dynamodb-stream-lambda/lib/index.ts

+3-8
Original file line numberDiff line numberDiff line change
@@ -89,25 +89,20 @@ export class DynamoDBStreamToLambda extends Construct {
8989
lambdaFunctionProps: props.lambdaFunctionProps
9090
});
9191

92-
const table: dynamodb.ITable = defaults.buildDynamoDBTableWithStream(this, {
92+
[this.dynamoTableInterface, this.dynamoTable] = defaults.buildDynamoDBTableWithStream(this, {
9393
dynamoTableProps: props.dynamoTableProps,
9494
existingTableInterface: props.existingTableInterface
9595
});
9696

97-
this.dynamoTableInterface = table;
98-
if (!props.existingTableInterface) {
99-
this.dynamoTable = table as dynamodb.Table;
100-
}
101-
10297
// Grant DynamoDB Stream read perimssion for lambda function
103-
table.grantStreamRead(this.lambdaFunction.grantPrincipal);
98+
this.dynamoTableInterface.grantStreamRead(this.lambdaFunction.grantPrincipal);
10499

105100
// Add the Lambda event source mapping
106101
const eventSourceProps = defaults.DynamoEventSourceProps(this, {
107102
eventSourceProps: props.dynamoEventSourceProps,
108103
deploySqsDlqQueue: props.deploySqsDlqQueue,
109104
sqsDlqQueueProps: props.sqsDlqQueueProps
110105
});
111-
this.lambdaFunction.addEventSource(new DynamoEventSource(table, eventSourceProps));
106+
this.lambdaFunction.addEventSource(new DynamoEventSource(this.dynamoTableInterface, eventSourceProps));
112107
}
113108
}

source/patterns/@aws-solutions-constructs/core/lib/dynamodb-table-helper.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -63,18 +63,20 @@ export function buildDynamoDBTable(scope: cdk.Construct, props: BuildDynamoDBTab
6363
}
6464
}
6565

66-
export function buildDynamoDBTableWithStream(scope: cdk.Construct, props: BuildDynamoDBTableWithStreamProps): dynamodb.Table | dynamodb.ITable {
66+
export function buildDynamoDBTableWithStream(scope: cdk.Construct, props: BuildDynamoDBTableWithStreamProps): [dynamodb.ITable, dynamodb.Table?] {
6767
// Conditional DynamoDB Table creation
6868
if (!props.existingTableInterface) {
6969
// Set the default props for DynamoDB table
7070
if (props.dynamoTableProps) {
7171
const dynamoTableProps = overrideProps(DefaultTableWithStreamProps, props.dynamoTableProps);
72-
return new dynamodb.Table(scope, 'DynamoTable', dynamoTableProps);
72+
const dynamoTable: dynamodb.Table = new dynamodb.Table(scope, 'DynamoTable', dynamoTableProps);
73+
return [dynamoTable as dynamodb.ITable, dynamoTable];
7374
} else {
74-
return new dynamodb.Table(scope, 'DynamoTable', DefaultTableWithStreamProps);
75+
const dynamoTable: dynamodb.Table = new dynamodb.Table(scope, 'DynamoTable', DefaultTableWithStreamProps);
76+
return [dynamoTable as dynamodb.ITable, dynamoTable];
7577
}
7678
} else {
77-
return props.existingTableInterface;
79+
return [props.existingTableInterface, undefined];
7880
}
7981
}
8082

0 commit comments

Comments
 (0)