@aws-solutions-constructs/aws-lambda-kinesisstreams 2.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintignore +5 -0
- package/.jsii +3655 -0
- package/README.md +121 -0
- package/architecture.png +0 -0
- package/lib/index.d.ts +90 -0
- package/lib/index.js +64 -0
- package/package.json +92 -0
- package/test/integ.existingLambda.d.ts +13 -0
- package/test/integ.existingLambda.expected.json +232 -0
- package/test/integ.existingLambda.js +31 -0
- package/test/integ.existingStream.d.ts +13 -0
- package/test/integ.existingStream.expected.json +231 -0
- package/test/integ.existingStream.js +37 -0
- package/test/integ.existingStreamWithCmk.d.ts +13 -0
- package/test/integ.existingStreamWithCmk.expected.json +300 -0
- package/test/integ.existingStreamWithCmk.js +39 -0
- package/test/integ.existingVpc.d.ts +13 -0
- package/test/integ.existingVpc.expected.json +1068 -0
- package/test/integ.existingVpc.js +34 -0
- package/test/integ.newStreamFromProps.d.ts +13 -0
- package/test/integ.newStreamFromProps.expected.json +231 -0
- package/test/integ.newStreamFromProps.js +34 -0
- package/test/integ.newVpc.d.ts +13 -0
- package/test/integ.newVpc.expected.json +674 -0
- package/test/integ.newVpc.js +31 -0
- package/test/integ.newVpcFromProps.d.ts +13 -0
- package/test/integ.newVpcFromProps.expected.json +560 -0
- package/test/integ.newVpcFromProps.js +34 -0
- package/test/integ.noArguments.d.ts +13 -0
- package/test/integ.noArguments.expected.json +232 -0
- package/test/integ.noArguments.js +30 -0
- package/test/lambda/index.mjs +15 -0
- package/test/lambda-kinesisstream.test.d.ts +13 -0
- package/test/lambda-kinesisstream.test.js +472 -0
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
{
|
|
2
|
+
"Resources": {
|
|
3
|
+
"testlambdakinesisstreamsLambdaFunctionServiceRole95206CF3": {
|
|
4
|
+
"Type": "AWS::IAM::Role",
|
|
5
|
+
"Properties": {
|
|
6
|
+
"AssumeRolePolicyDocument": {
|
|
7
|
+
"Statement": [
|
|
8
|
+
{
|
|
9
|
+
"Action": "sts:AssumeRole",
|
|
10
|
+
"Effect": "Allow",
|
|
11
|
+
"Principal": {
|
|
12
|
+
"Service": "lambda.amazonaws.com"
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
],
|
|
16
|
+
"Version": "2012-10-17"
|
|
17
|
+
},
|
|
18
|
+
"Policies": [
|
|
19
|
+
{
|
|
20
|
+
"PolicyDocument": {
|
|
21
|
+
"Statement": [
|
|
22
|
+
{
|
|
23
|
+
"Action": [
|
|
24
|
+
"logs:CreateLogGroup",
|
|
25
|
+
"logs:CreateLogStream",
|
|
26
|
+
"logs:PutLogEvents"
|
|
27
|
+
],
|
|
28
|
+
"Effect": "Allow",
|
|
29
|
+
"Resource": {
|
|
30
|
+
"Fn::Join": [
|
|
31
|
+
"",
|
|
32
|
+
[
|
|
33
|
+
"arn:",
|
|
34
|
+
{
|
|
35
|
+
"Ref": "AWS::Partition"
|
|
36
|
+
},
|
|
37
|
+
":logs:",
|
|
38
|
+
{
|
|
39
|
+
"Ref": "AWS::Region"
|
|
40
|
+
},
|
|
41
|
+
":",
|
|
42
|
+
{
|
|
43
|
+
"Ref": "AWS::AccountId"
|
|
44
|
+
},
|
|
45
|
+
":log-group:/aws/lambda/*"
|
|
46
|
+
]
|
|
47
|
+
]
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
],
|
|
51
|
+
"Version": "2012-10-17"
|
|
52
|
+
},
|
|
53
|
+
"PolicyName": "LambdaFunctionServiceRolePolicy"
|
|
54
|
+
}
|
|
55
|
+
]
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
"testlambdakinesisstreamsLambdaFunctionServiceRoleDefaultPolicyED972043": {
|
|
59
|
+
"Type": "AWS::IAM::Policy",
|
|
60
|
+
"Properties": {
|
|
61
|
+
"PolicyDocument": {
|
|
62
|
+
"Statement": [
|
|
63
|
+
{
|
|
64
|
+
"Action": [
|
|
65
|
+
"xray:PutTraceSegments",
|
|
66
|
+
"xray:PutTelemetryRecords"
|
|
67
|
+
],
|
|
68
|
+
"Effect": "Allow",
|
|
69
|
+
"Resource": "*"
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"Action": [
|
|
73
|
+
"kinesis:ListShards",
|
|
74
|
+
"kinesis:PutRecord",
|
|
75
|
+
"kinesis:PutRecords"
|
|
76
|
+
],
|
|
77
|
+
"Effect": "Allow",
|
|
78
|
+
"Resource": {
|
|
79
|
+
"Fn::GetAtt": [
|
|
80
|
+
"testlambdakinesisstreamsKinesisStream11A82116",
|
|
81
|
+
"Arn"
|
|
82
|
+
]
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
],
|
|
86
|
+
"Version": "2012-10-17"
|
|
87
|
+
},
|
|
88
|
+
"PolicyName": "testlambdakinesisstreamsLambdaFunctionServiceRoleDefaultPolicyED972043",
|
|
89
|
+
"Roles": [
|
|
90
|
+
{
|
|
91
|
+
"Ref": "testlambdakinesisstreamsLambdaFunctionServiceRole95206CF3"
|
|
92
|
+
}
|
|
93
|
+
]
|
|
94
|
+
},
|
|
95
|
+
"Metadata": {
|
|
96
|
+
"cfn_nag": {
|
|
97
|
+
"rules_to_suppress": [
|
|
98
|
+
{
|
|
99
|
+
"id": "W12",
|
|
100
|
+
"reason": "Lambda needs the following minimum required permissions to send trace data to X-Ray and access ENIs in a VPC."
|
|
101
|
+
}
|
|
102
|
+
]
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
"testlambdakinesisstreamsLambdaFunction4348B6E4": {
|
|
107
|
+
"Type": "AWS::Lambda::Function",
|
|
108
|
+
"Properties": {
|
|
109
|
+
"Code": {
|
|
110
|
+
"S3Bucket": {
|
|
111
|
+
"Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
|
|
112
|
+
},
|
|
113
|
+
"S3Key": "c7dc0cc1b24bda1d2a5345f61897eee32184906649fdb1de93853c512e129dbf.zip"
|
|
114
|
+
},
|
|
115
|
+
"Role": {
|
|
116
|
+
"Fn::GetAtt": [
|
|
117
|
+
"testlambdakinesisstreamsLambdaFunctionServiceRole95206CF3",
|
|
118
|
+
"Arn"
|
|
119
|
+
]
|
|
120
|
+
},
|
|
121
|
+
"Environment": {
|
|
122
|
+
"Variables": {
|
|
123
|
+
"KINESIS_DATASTREAM_NAME": {
|
|
124
|
+
"Ref": "testlambdakinesisstreamsKinesisStream11A82116"
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
"Handler": "index.handler",
|
|
129
|
+
"Runtime": "nodejs18.x",
|
|
130
|
+
"TracingConfig": {
|
|
131
|
+
"Mode": "Active"
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
"DependsOn": [
|
|
135
|
+
"testlambdakinesisstreamsLambdaFunctionServiceRoleDefaultPolicyED972043",
|
|
136
|
+
"testlambdakinesisstreamsLambdaFunctionServiceRole95206CF3"
|
|
137
|
+
],
|
|
138
|
+
"Metadata": {
|
|
139
|
+
"cfn_nag": {
|
|
140
|
+
"rules_to_suppress": [
|
|
141
|
+
{
|
|
142
|
+
"id": "W58",
|
|
143
|
+
"reason": "Lambda functions has the required permission to write CloudWatch Logs. It uses custom policy instead of arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole with tighter permissions."
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
"id": "W89",
|
|
147
|
+
"reason": "This is not a rule for the general case, just for specific use cases/industries"
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
"id": "W92",
|
|
151
|
+
"reason": "Impossible for us to define the correct concurrency for clients"
|
|
152
|
+
}
|
|
153
|
+
]
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
"testlambdakinesisstreamsKinesisStream11A82116": {
|
|
158
|
+
"Type": "AWS::Kinesis::Stream",
|
|
159
|
+
"Properties": {
|
|
160
|
+
"RetentionPeriodHours": 24,
|
|
161
|
+
"ShardCount": 1,
|
|
162
|
+
"StreamEncryption": {
|
|
163
|
+
"EncryptionType": "KMS",
|
|
164
|
+
"KeyId": "alias/aws/kinesis"
|
|
165
|
+
},
|
|
166
|
+
"StreamModeDetails": {
|
|
167
|
+
"StreamMode": "PROVISIONED"
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
},
|
|
171
|
+
"testlambdakinesisstreamsKinesisStreamGetRecordsIteratorAgeAlarmC4A0FF00": {
|
|
172
|
+
"Type": "AWS::CloudWatch::Alarm",
|
|
173
|
+
"Properties": {
|
|
174
|
+
"ComparisonOperator": "GreaterThanOrEqualToThreshold",
|
|
175
|
+
"EvaluationPeriods": 1,
|
|
176
|
+
"AlarmDescription": "Consumer Record Processing Falling Behind, there is risk for data loss due to record expiration.",
|
|
177
|
+
"MetricName": "GetRecords.IteratorAgeMilliseconds",
|
|
178
|
+
"Namespace": "AWS/Kinesis",
|
|
179
|
+
"Period": 300,
|
|
180
|
+
"Statistic": "Maximum",
|
|
181
|
+
"Threshold": 43200000
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
"testlambdakinesisstreamsKinesisStreamReadProvisionedThroughputExceededAlarm9732E188": {
|
|
185
|
+
"Type": "AWS::CloudWatch::Alarm",
|
|
186
|
+
"Properties": {
|
|
187
|
+
"ComparisonOperator": "GreaterThanThreshold",
|
|
188
|
+
"EvaluationPeriods": 1,
|
|
189
|
+
"AlarmDescription": "Consumer Application is Reading at a Slower Rate Than Expected.",
|
|
190
|
+
"MetricName": "ReadProvisionedThroughputExceeded",
|
|
191
|
+
"Namespace": "AWS/Kinesis",
|
|
192
|
+
"Period": 300,
|
|
193
|
+
"Statistic": "Average",
|
|
194
|
+
"Threshold": 0
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
},
|
|
198
|
+
"Parameters": {
|
|
199
|
+
"BootstrapVersion": {
|
|
200
|
+
"Type": "AWS::SSM::Parameter::Value<String>",
|
|
201
|
+
"Default": "/cdk-bootstrap/hnb659fds/version",
|
|
202
|
+
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
|
|
203
|
+
}
|
|
204
|
+
},
|
|
205
|
+
"Rules": {
|
|
206
|
+
"CheckBootstrapVersion": {
|
|
207
|
+
"Assertions": [
|
|
208
|
+
{
|
|
209
|
+
"Assert": {
|
|
210
|
+
"Fn::Not": [
|
|
211
|
+
{
|
|
212
|
+
"Fn::Contains": [
|
|
213
|
+
[
|
|
214
|
+
"1",
|
|
215
|
+
"2",
|
|
216
|
+
"3",
|
|
217
|
+
"4",
|
|
218
|
+
"5"
|
|
219
|
+
],
|
|
220
|
+
{
|
|
221
|
+
"Ref": "BootstrapVersion"
|
|
222
|
+
}
|
|
223
|
+
]
|
|
224
|
+
}
|
|
225
|
+
]
|
|
226
|
+
},
|
|
227
|
+
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
|
|
228
|
+
}
|
|
229
|
+
]
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
|
|
6
|
+
* with the License. A copy of the License is located at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES
|
|
11
|
+
* OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions
|
|
12
|
+
* and limitations under the License.
|
|
13
|
+
*/
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
/// !cdk-integ *
|
|
16
|
+
const aws_cdk_lib_1 = require("aws-cdk-lib");
|
|
17
|
+
const lib_1 = require("../lib");
|
|
18
|
+
const core_1 = require("@aws-solutions-constructs/core");
|
|
19
|
+
const lambda = require("aws-cdk-lib/aws-lambda");
|
|
20
|
+
const app = new aws_cdk_lib_1.App();
|
|
21
|
+
const stack = new aws_cdk_lib_1.Stack(app, core_1.generateIntegStackName(__filename));
|
|
22
|
+
new lib_1.LambdaToKinesisStreams(stack, 'test-lambda-kinesisstreams', {
|
|
23
|
+
lambdaFunctionProps: {
|
|
24
|
+
code: lambda.Code.fromAsset(`${__dirname}/lambda`),
|
|
25
|
+
runtime: lambda.Runtime.NODEJS_18_X,
|
|
26
|
+
handler: 'index.handler'
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
app.synth();
|
|
30
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW50ZWcubm9Bcmd1bWVudHMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJpbnRlZy5ub0FyZ3VtZW50cy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUE7Ozs7Ozs7Ozs7O0dBV0c7O0FBRUgsZ0JBQWdCO0FBQ2hCLDZDQUF5QztBQUN6QyxnQ0FBZ0Q7QUFDaEQseURBQXdFO0FBQ3hFLGlEQUFpRDtBQUVqRCxNQUFNLEdBQUcsR0FBRyxJQUFJLGlCQUFHLEVBQUUsQ0FBQztBQUN0QixNQUFNLEtBQUssR0FBRyxJQUFJLG1CQUFLLENBQUMsR0FBRyxFQUFFLDZCQUFzQixDQUFDLFVBQVUsQ0FBQyxDQUFDLENBQUM7QUFFakUsSUFBSSw0QkFBc0IsQ0FBQyxLQUFLLEVBQUUsNEJBQTRCLEVBQUU7SUFDOUQsbUJBQW1CLEVBQUU7UUFDbkIsSUFBSSxFQUFFLE1BQU0sQ0FBQyxJQUFJLENBQUMsU0FBUyxDQUFDLEdBQUcsU0FBUyxTQUFTLENBQUM7UUFDbEQsT0FBTyxFQ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JkYVRvS2luZXNpc1N0cmVhbXMgfSBmcm9tIFwiLi4vbGliXCI7XG5pbXBvcnQgeyBnZW5lcmF0ZUludGVnU3RhY2tOYW1lIH0gZnJvbSAnQGF3cy1zb2x1dGlvbnMtY29uc3RydWN0cy9jb3JlJztcbmltcG9ydCAqIGFzIGxhbWJkYSBmcm9tICdhd3MtY2RrLWxpYi9hd3MtbGFtYmRhJztcblxuY29uc3QgYXBwID0gbmV3IEFwcCgpO1xuY29uc3Qgc3RhY2sgPSBuZXcgU3RhY2soYXBwLCBnZW5lcmF0ZUludGVnU3RhY2tOYW1lKF9fZmlsZW5hbWUpKTtcblxubmV3IExhbWJkYVRvS2luZXNpc1N0cmVhbXMoc3RhY2ssICd0ZXN0LWxhbWJkYS1raW5lc2lzc3RyZWFtcycsIHtcbiAgbGFtYmRhRnVuY3Rpb25Qcm9wczoge1xuICAgIGNvZGU6IGxhbWJkYS5Db2RlLmZyb21Bc3NldChgJHtfX2Rpcm5hbWV9L2xhbWJkYWApLFxuICAgIHJ1bnRpbWU6IGxhbWJkYS5SdW50aW1lLk5PREVKU18xOF9YLFxuICAgIGhhbmRsZXI6ICdpbmRleC5oYW5kbGVyJ1xuICB9LFxufSk7XG5cbmFwcC5zeW50aCgpO1xuIl19
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { KinesisClient, PutRecordCommand } from "@aws-sdk/client-kinesis";
|
|
2
|
+
|
|
3
|
+
const kinesis = new KinesisClient({ region: process.env.REGION });
|
|
4
|
+
const streamName = process.env.KINESIS_DATASTREAM_NAME;
|
|
5
|
+
|
|
6
|
+
export const handler = async(event) => {
|
|
7
|
+
|
|
8
|
+
const result = await kinesis.send(new PutRecordCommand({
|
|
9
|
+
StreamName: streamName,
|
|
10
|
+
Data: Buffer.from('hello from solutions constructs'),
|
|
11
|
+
PartitionKey: '1'
|
|
12
|
+
}));
|
|
13
|
+
|
|
14
|
+
console.log(JSON.stringify(result));
|
|
15
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
|
|
5
|
+
* with the License. A copy of the License is located at
|
|
6
|
+
*
|
|
7
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES
|
|
10
|
+
* OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions
|
|
11
|
+
* and limitations under the License.
|
|
12
|
+
*/
|
|
13
|
+
import '@aws-cdk/assert/jest';
|