-
Notifications
You must be signed in to change notification settings - Fork 251
/
Copy pathindex.ts
158 lines (148 loc) · 6.34 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
/**
* Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
* with the License. A copy of the License is located at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES
* OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/
import * as lambda from '@aws-cdk/aws-lambda';
import * as elasticsearch from '@aws-cdk/aws-elasticsearch';
import * as iam from '@aws-cdk/aws-iam';
import { DynamoEventSourceProps } from '@aws-cdk/aws-lambda-event-sources';
import { DynamoDBStreamToLambdaProps, DynamoDBStreamToLambda } from '@aws-solutions-constructs/aws-dynamodb-stream-lambda';
import { LambdaToElasticSearchAndKibanaProps, LambdaToElasticSearchAndKibana } from '@aws-solutions-constructs/aws-lambda-elasticsearch-kibana';
import * as dynamodb from '@aws-cdk/aws-dynamodb';
import * as cognito from '@aws-cdk/aws-cognito';
import * as cloudwatch from '@aws-cdk/aws-cloudwatch';
import { Construct } from '@aws-cdk/core';
import * as sqs from '@aws-cdk/aws-sqs';
import * as defaults from '@aws-solutions-constructs/core';
/**
* @summary The properties for the DynamoDBStreamToLambdaToElastciSearchAndKibana Construct
*/
export interface DynamoDBStreamToLambdaToElasticSearchAndKibanaProps {
/**
* Existing instance of Lambda Function object, providing both this and `lambdaFunctionProps` will cause an error.
*
* @default - None
*/
readonly existingLambdaObj?: lambda.Function,
/**
* User provided props to override the default props for the Lambda function.
*
* @default - Default props are used
*/
readonly lambdaFunctionProps?: lambda.FunctionProps,
/**
* Optional user provided props to override the default props
*
* @default - Default props are used
*/
readonly dynamoTableProps?: dynamodb.TableProps,
/**
* Existing instance of DynamoDB table object, providing both this and `dynamoTableProps` will cause an error.
*
* @default - None
*/
readonly existingTableInterface?: dynamodb.ITable,
/**
* Optional user provided props to override the default props
*
* @default - Default props are used
*/
readonly dynamoEventSourceProps?: DynamoEventSourceProps,
/**
* Optional user provided props to override the default props for the API Gateway.
*
* @default - Default props are used
*/
readonly esDomainProps?: elasticsearch.CfnDomainProps,
/**
* Cognito & ES Domain Name
*
* @default - None
*/
readonly domainName: string,
/**
* Optional Cognito Domain Name, if provided it will be used for Cognito Domain, and domainName will be used for the Elasticsearch Domain
*
* @default - None
*/
readonly cognitoDomainName?: string,
/**
* Whether to deploy a SQS dead letter queue when a data record reaches the Maximum Retry Attempts or Maximum Record Age,
* its metadata like shard ID and stream ARN will be sent to an SQS queue.
*
* @default - true.
*/
readonly deploySqsDlqQueue?: boolean,
/**
* Optional user provided properties for the SQS dead letter queue
*
* @default - Default props are used
*/
readonly sqsDlqQueueProps?: sqs.QueueProps,
/**
* Whether to create recommended CloudWatch alarms
*
* @default - Alarms are created
*/
readonly createCloudWatchAlarms?: boolean
}
export class DynamoDBStreamToLambdaToElasticSearchAndKibana extends Construct {
private dynamoDBStreamToLambda: DynamoDBStreamToLambda;
private lambdaToElasticSearchAndKibana: LambdaToElasticSearchAndKibana;
public readonly lambdaFunction: lambda.Function;
public readonly dynamoTableInterface: dynamodb.ITable;
public readonly dynamoTable?: dynamodb.Table;
public readonly userPool: cognito.UserPool;
public readonly userPoolClient: cognito.UserPoolClient;
public readonly identityPool: cognito.CfnIdentityPool;
public readonly elasticsearchDomain: elasticsearch.CfnDomain;
public readonly elasticsearchRole: iam.Role;
public readonly cloudwatchAlarms?: cloudwatch.Alarm[];
/**
* @summary Constructs a new instance of the LambdaToDynamoDB class.
* @param {cdk.App} scope - represents the scope for all the resources.
* @param {string} id - this is a a scope-unique id.
* @param {DynamoDBStreamToLambdaToElasticSearchAndKibanaProps} props - user provided props for the construct
* @since 0.8.0
* @access public
*/
constructor(scope: Construct, id: string, props: DynamoDBStreamToLambdaToElasticSearchAndKibanaProps) {
super(scope, id);
defaults.CheckProps(props);
const _props1: DynamoDBStreamToLambdaProps = {
existingLambdaObj: props.existingLambdaObj,
lambdaFunctionProps: props.lambdaFunctionProps,
dynamoEventSourceProps: props.dynamoEventSourceProps,
dynamoTableProps: props.dynamoTableProps,
existingTableInterface: props.existingTableInterface,
deploySqsDlqQueue: props.deploySqsDlqQueue,
sqsDlqQueueProps: props.sqsDlqQueueProps
};
this.dynamoDBStreamToLambda = new DynamoDBStreamToLambda(this, 'DynamoDBStreamToLambda', _props1);
this.lambdaFunction = this.dynamoDBStreamToLambda.lambdaFunction;
const _props2: LambdaToElasticSearchAndKibanaProps = {
existingLambdaObj: this.lambdaFunction,
domainName: props.domainName,
esDomainProps: props.esDomainProps,
cognitoDomainName: props.cognitoDomainName,
createCloudWatchAlarms: props.createCloudWatchAlarms
};
this.lambdaToElasticSearchAndKibana = new LambdaToElasticSearchAndKibana(this, 'LambdaToElasticSearch', _props2);
this.dynamoTable = this.dynamoDBStreamToLambda.dynamoTable;
this.dynamoTableInterface = this.dynamoDBStreamToLambda.dynamoTableInterface;
this.userPool = this.lambdaToElasticSearchAndKibana.userPool;
this.userPoolClient = this.lambdaToElasticSearchAndKibana.userPoolClient;
this.identityPool = this.lambdaToElasticSearchAndKibana.identityPool;
this.elasticsearchDomain = this.lambdaToElasticSearchAndKibana.elasticsearchDomain;
this.elasticsearchRole = this.lambdaToElasticSearchAndKibana.elasticsearchRole;
this.cloudwatchAlarms = this.lambdaToElasticSearchAndKibana.cloudwatchAlarms;
}
}