@mapbox/cloudfriend 8.1.0-dev.2 → 8.2.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/.github/workflows/test.yml +33 -0
- package/.nyc_output/3d263a21-c592-478a-a9b6-71ff681d5523.json +1 -0
- package/.nyc_output/be006597-158b-404c-aed6-72c7cce3e612.json +1 -0
- package/.nyc_output/processinfo/3d263a21-c592-478a-a9b6-71ff681d5523.json +1 -0
- package/.nyc_output/processinfo/be006597-158b-404c-aed6-72c7cce3e612.json +1 -0
- package/.nyc_output/processinfo/index.json +1 -1
- package/CODEOWNERS +1 -1
- package/changelog.md +13 -3
- package/lib/shortcuts/api.md +20 -2
- package/lib/shortcuts/lambda.js +4 -2
- package/lib/shortcuts/stream-lambda.js +19 -5
- package/package.json +1 -1
- package/test/fixtures/shortcuts/lambda-full.json +10 -29
- package/test/shortcuts.test.js +2 -34
- package/.idea/cloudfriend.iml +0 -12
- package/.idea/inspectionProfiles/Project_Default.xml +0 -6
- package/.idea/modules.xml +0 -8
- package/.idea/vcs.xml +0 -6
- package/.nyc_output/35aa325a-f140-4f80-9616-95761c59175e.json +0 -1
- package/.nyc_output/processinfo/35aa325a-f140-4f80-9616-95761c59175e.json +0 -1
- package/.travis.yml +0 -10
package/changelog.md
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 8.2.0
|
|
4
|
+
|
|
5
|
+
- Add `LogRetentionInDays` option to Lambda shortcuts
|
|
6
|
+
|
|
3
7
|
## 8.1.0
|
|
4
8
|
|
|
5
|
-
- Allow `FilterCriteria` property to be defined for Lambda shortcuts
|
|
9
|
+
- Allow `FilterCriteria` property to be defined for Stream Lambda shortcuts
|
|
6
10
|
|
|
7
11
|
## 8.0.0
|
|
8
12
|
|
|
@@ -25,7 +29,7 @@ When you make this update, you will no longer see a trigger on your scheduled la
|
|
|
25
29
|
## 7.1.0
|
|
26
30
|
|
|
27
31
|
- Add support for `Fn::ForEach`. With `Fn::ForEach`, you can replicate parts of your templates with minimal lines of code, as per the [official AWS announcement](https://aws.amazon.com/about-aws/whats-new/2023/07/accelerate-cloudformation-authoring-experience-looping-function/) and [the documentation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-foreach.html).
|
|
28
|
-
|
|
32
|
+
|
|
29
33
|
## v7.0.1
|
|
30
34
|
|
|
31
35
|
- Fixes `hookshot.Passthrough` and `hookshot.Github` shortcuts where inline code lambdas were using AWS SDK v2 while the lambda default runtime is `nodejs18.x`, by switching to AWS SDK v3.
|
|
@@ -47,23 +51,29 @@ When you make this update, you will no longer see a trigger on your scheduled la
|
|
|
47
51
|
- Dependency updates to avoid security vulnerabilities (minimist).
|
|
48
52
|
|
|
49
53
|
## v5.1.0
|
|
54
|
+
|
|
50
55
|
- Lambda shortcuts now support custom Docker images.
|
|
51
56
|
|
|
52
57
|
## v5.0.2
|
|
58
|
+
|
|
53
59
|
- Fixes handling custom access log formats in hookshot shortcuts.
|
|
54
60
|
|
|
55
61
|
## v5.0.1
|
|
62
|
+
|
|
56
63
|
- Improves data type mappings between Glue and Presto when using the `GluePrestoView` shortcut.
|
|
57
64
|
|
|
58
65
|
## v5.0.0
|
|
66
|
+
|
|
59
67
|
- The Lambda shortcuts now use `nodejs12.x` as the default runtime.
|
|
60
68
|
- There is no longer any constraint on the useable Lambda runtimes.
|
|
61
69
|
|
|
62
70
|
## v4.6.0
|
|
71
|
+
|
|
63
72
|
- Adds top-level `Rules` section support to `cf.merge`. Each key in `Rules` must have a unique name.
|
|
64
73
|
- Adds rule-specific intrinsic functions: `contains`, `eachMemberEquals`, `eachMemberIn`, `refAll`, `valueOf`, `valueOfAll`
|
|
65
74
|
|
|
66
75
|
## v4.5.1
|
|
76
|
+
|
|
67
77
|
- Fixes a bug present in v4.4.0 and v4.5.0 where Lambda shortcuts' Conditions were not passed to the generated IAM Roles.
|
|
68
78
|
|
|
69
79
|
## v4.5.0
|
|
@@ -174,7 +184,7 @@ When you make this update, you will no longer see a trigger on your scheduled la
|
|
|
174
184
|
## v2.8.0
|
|
175
185
|
|
|
176
186
|
- Allows Hookshot callers to bring their own webhook secret. This is used for
|
|
177
|
-
signature-verification in the `.Github()` case.
|
|
187
|
+
signature-verification in the `.Github()` case.
|
|
178
188
|
|
|
179
189
|
## v2.7.0
|
|
180
190
|
|
package/lib/shortcuts/api.md
CHANGED
|
@@ -422,6 +422,7 @@ Log Group, a Role, an Alarm on function errors, and the Lambda Function itself.
|
|
|
422
422
|
| [options.EvaluateLowSampleCountPercentile] | <code>String</code> | | See [AWS documentation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cw-alarm.html#cfn-cloudwatch-alarms-evaluatelowsamplecountpercentile). |
|
|
423
423
|
| [options.ExtendedStatistic] | <code>String</code> | | See [AWS documentation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cw-alarm.html#cfn-cloudwatch-alarms-extendedstatistic)] |
|
|
424
424
|
| [options.OKActions] | <code>Array.<String></code> | | See [AWS documentation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cw-alarm.html#cfn-cloudwatch-alarms-okactions). |
|
|
425
|
+
| [options.LogRetentionInDays] | <code>Number</code> | <code>14</code> | How long to retain CloudWatch logs for this Lambda function. See [AWS Documentation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-logs-loggroup.html) for allowed values. |
|
|
425
426
|
|
|
426
427
|
**Example**
|
|
427
428
|
```js
|
|
@@ -796,8 +797,25 @@ const lambda = new cf.shortcuts.StreamLambda({
|
|
|
796
797
|
S3Bucket: 'my-code-bucket',
|
|
797
798
|
S3Key: 'path/to/code.zip'
|
|
798
799
|
},
|
|
799
|
-
EventSourceArn: cf.getAtt('MyStream', 'Arn')
|
|
800
|
+
EventSourceArn: cf.getAtt('MyStream', 'Arn'),
|
|
800
801
|
});
|
|
801
802
|
|
|
802
|
-
|
|
803
|
+
// This lambda only gets invoked for 'INSERT' events for the DynamoDb event source
|
|
804
|
+
const lambdaWithFilterCriteria = new cf.shortcuts.StreamLambda({
|
|
805
|
+
LogicalName: 'MyLambdaWithFilterCriteria',
|
|
806
|
+
Code: {
|
|
807
|
+
S3Bucket: 'my-code-bucket',
|
|
808
|
+
S3Key: 'path/to/code.zip'
|
|
809
|
+
},
|
|
810
|
+
EventSourceArn: cf.getAtt('MyDynamoDbStream', 'Arn'),
|
|
811
|
+
FilterCriteria: {
|
|
812
|
+
Filters: [
|
|
813
|
+
{
|
|
814
|
+
Pattern: JSON.stringify({ eventName: ['INSERT'] }),
|
|
815
|
+
}
|
|
816
|
+
]
|
|
817
|
+
}
|
|
818
|
+
});
|
|
819
|
+
|
|
820
|
+
module.exports = cf.merge(myTemplate, lambda, lambdaWithFilterCriteria);
|
|
803
821
|
```
|
package/lib/shortcuts/lambda.js
CHANGED
|
@@ -46,6 +46,7 @@ const ServiceRole = require('./service-role');
|
|
|
46
46
|
* @param {String} [options.EvaluateLowSampleCountPercentile=undefined] - See [AWS documentation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cw-alarm.html#cfn-cloudwatch-alarms-evaluatelowsamplecountpercentile).
|
|
47
47
|
* @param {String} [options.ExtendedStatistic=undefined] - See [AWS documentation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cw-alarm.html#cfn-cloudwatch-alarms-extendedstatistic)]
|
|
48
48
|
* @param {Array<String>} [options.OKActions=undefined] - See [AWS documentation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cw-alarm.html#cfn-cloudwatch-alarms-okactions).
|
|
49
|
+
* @param {Number} [options.LogRetentionInDays=14] - How long to retain CloudWatch logs for this Lambda function. See [AWS Documentation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-logs-loggroup.html) for allowed values.
|
|
49
50
|
*
|
|
50
51
|
* @example
|
|
51
52
|
* const cf = require('@mapbox/cloudfriend');
|
|
@@ -104,7 +105,8 @@ class Lambda {
|
|
|
104
105
|
TreatMissingData = 'notBreaching',
|
|
105
106
|
EvaluateLowSampleCountPercentile,
|
|
106
107
|
ExtendedStatistic,
|
|
107
|
-
OKActions
|
|
108
|
+
OKActions,
|
|
109
|
+
LogRetentionInDays = 14
|
|
108
110
|
} = options;
|
|
109
111
|
|
|
110
112
|
if (options.EvaluationPeriods < Math.ceil(Timeout / Period))
|
|
@@ -138,7 +140,7 @@ class Lambda {
|
|
|
138
140
|
LogGroupName: {
|
|
139
141
|
'Fn::Sub': ['/aws/lambda/${name}', { name: FunctionName }]
|
|
140
142
|
},
|
|
141
|
-
RetentionInDays:
|
|
143
|
+
RetentionInDays: LogRetentionInDays
|
|
142
144
|
}
|
|
143
145
|
},
|
|
144
146
|
|
|
@@ -26,10 +26,27 @@ const Lambda = require('./lambda');
|
|
|
26
26
|
* S3Bucket: 'my-code-bucket',
|
|
27
27
|
* S3Key: 'path/to/code.zip'
|
|
28
28
|
* },
|
|
29
|
-
* EventSourceArn: cf.getAtt('MyStream', 'Arn')
|
|
29
|
+
* EventSourceArn: cf.getAtt('MyStream', 'Arn'),
|
|
30
30
|
* });
|
|
31
31
|
*
|
|
32
|
-
*
|
|
32
|
+
* // This lambda only gets invoked for 'INSERT' events for the DynamoDb event source
|
|
33
|
+
* const lambdaWithFilterCriteria = new cf.shortcuts.StreamLambda({
|
|
34
|
+
* LogicalName: 'MyLambdaWithFilterCriteria',
|
|
35
|
+
* Code: {
|
|
36
|
+
* S3Bucket: 'my-code-bucket',
|
|
37
|
+
* S3Key: 'path/to/code.zip'
|
|
38
|
+
* },
|
|
39
|
+
* EventSourceArn: cf.getAtt('MyDynamoDbStream', 'Arn'),
|
|
40
|
+
* FilterCriteria: {
|
|
41
|
+
* Filters: [
|
|
42
|
+
* {
|
|
43
|
+
* Pattern: JSON.stringify({ eventName: ['INSERT'] }),
|
|
44
|
+
* }
|
|
45
|
+
* ]
|
|
46
|
+
* }
|
|
47
|
+
* });
|
|
48
|
+
*
|
|
49
|
+
* module.exports = cf.merge(myTemplate, lambda, lambdaWithFilterCriteria);
|
|
33
50
|
*/
|
|
34
51
|
class StreamLambda extends Lambda {
|
|
35
52
|
constructor(options) {
|
|
@@ -68,9 +85,6 @@ class StreamLambda extends Lambda {
|
|
|
68
85
|
if (!(FilterCriteria.Filters && Array.isArray(FilterCriteria.Filters))){
|
|
69
86
|
throw new Error('`FilterCriteria` must contain property `Filter` of type array');
|
|
70
87
|
}
|
|
71
|
-
if (FilterCriteria.Filters.length > 5){
|
|
72
|
-
throw new Error('`FilterCriteria.Filter` cannot contain more than 5 items, you may request a quota increase with AWS support if required.');
|
|
73
|
-
}
|
|
74
88
|
for (const filter of FilterCriteria.Filters){
|
|
75
89
|
if (!filter.Pattern){
|
|
76
90
|
throw new Error('An object in `FilterCriteria.Filter` was missing the required property `Pattern`');
|
package/package.json
CHANGED
|
@@ -6,10 +6,7 @@
|
|
|
6
6
|
"Mappings": {},
|
|
7
7
|
"Conditions": {
|
|
8
8
|
"Always": {
|
|
9
|
-
"Fn::Equals": [
|
|
10
|
-
"1",
|
|
11
|
-
"1"
|
|
12
|
-
]
|
|
9
|
+
"Fn::Equals": ["1", "1"]
|
|
13
10
|
}
|
|
14
11
|
},
|
|
15
12
|
"Resources": {
|
|
@@ -28,7 +25,7 @@
|
|
|
28
25
|
}
|
|
29
26
|
]
|
|
30
27
|
},
|
|
31
|
-
"RetentionInDays":
|
|
28
|
+
"RetentionInDays": 30
|
|
32
29
|
}
|
|
33
30
|
},
|
|
34
31
|
"MyLambda": {
|
|
@@ -52,9 +49,7 @@
|
|
|
52
49
|
"FunctionName": "my-function",
|
|
53
50
|
"Handler": "index.something",
|
|
54
51
|
"KmsKeyArn": "arn:aws:kms:us-east-1:123456789012:key/fake",
|
|
55
|
-
"Layers": [
|
|
56
|
-
"arn:aws:fake:layer/abc"
|
|
57
|
-
],
|
|
52
|
+
"Layers": ["arn:aws:fake:layer/abc"],
|
|
58
53
|
"MemorySize": 512,
|
|
59
54
|
"ReservedConcurrentExecutions": 10,
|
|
60
55
|
"Runtime": "nodejs18.x",
|
|
@@ -63,12 +58,8 @@
|
|
|
63
58
|
"Mode": "Active"
|
|
64
59
|
},
|
|
65
60
|
"VpcConfig": {
|
|
66
|
-
"SecurityGroupIds": [
|
|
67
|
-
|
|
68
|
-
],
|
|
69
|
-
"SubnetIds": [
|
|
70
|
-
"fake"
|
|
71
|
-
]
|
|
61
|
+
"SecurityGroupIds": ["sg-12345"],
|
|
62
|
+
"SubnetIds": ["fake"]
|
|
72
63
|
},
|
|
73
64
|
"Tags": [
|
|
74
65
|
{
|
|
@@ -77,10 +68,7 @@
|
|
|
77
68
|
}
|
|
78
69
|
],
|
|
79
70
|
"Role": {
|
|
80
|
-
"Fn::GetAtt": [
|
|
81
|
-
"MyLambdaRole",
|
|
82
|
-
"Arn"
|
|
83
|
-
]
|
|
71
|
+
"Fn::GetAtt": ["MyLambdaRole", "Arn"]
|
|
84
72
|
}
|
|
85
73
|
}
|
|
86
74
|
},
|
|
@@ -90,9 +78,7 @@
|
|
|
90
78
|
"Properties": {
|
|
91
79
|
"AlarmName": "my-alarm",
|
|
92
80
|
"AlarmDescription": "some alarm",
|
|
93
|
-
"AlarmActions": [
|
|
94
|
-
"devnull@mapbox.com"
|
|
95
|
-
],
|
|
81
|
+
"AlarmActions": ["devnull@mapbox.com"],
|
|
96
82
|
"Period": 120,
|
|
97
83
|
"EvaluationPeriods": 2,
|
|
98
84
|
"DatapointsToAlarm": 1,
|
|
@@ -101,9 +87,7 @@
|
|
|
101
87
|
"ComparisonOperator": "LessThanThreshold",
|
|
102
88
|
"TreatMissingData": "breaching",
|
|
103
89
|
"EvaluateLowSampleCountPercentile": "ignore",
|
|
104
|
-
"OKActions": [
|
|
105
|
-
"devnull@mapbox.com"
|
|
106
|
-
],
|
|
90
|
+
"OKActions": ["devnull@mapbox.com"],
|
|
107
91
|
"Namespace": "AWS/Lambda",
|
|
108
92
|
"Dimensions": [
|
|
109
93
|
{
|
|
@@ -134,10 +118,7 @@
|
|
|
134
118
|
"Effect": "Allow",
|
|
135
119
|
"Action": "logs:*",
|
|
136
120
|
"Resource": {
|
|
137
|
-
"Fn::GetAtt": [
|
|
138
|
-
"MyLambdaLogs",
|
|
139
|
-
"Arn"
|
|
140
|
-
]
|
|
121
|
+
"Fn::GetAtt": ["MyLambdaLogs", "Arn"]
|
|
141
122
|
}
|
|
142
123
|
}
|
|
143
124
|
]
|
|
@@ -180,4 +161,4 @@
|
|
|
180
161
|
}
|
|
181
162
|
},
|
|
182
163
|
"Outputs": {}
|
|
183
|
-
}
|
|
164
|
+
}
|
package/test/shortcuts.test.js
CHANGED
|
@@ -190,7 +190,8 @@ test('[shortcuts] lambda', (assert) => {
|
|
|
190
190
|
TreatMissingData: 'breaching',
|
|
191
191
|
EvaluateLowSampleCountPercentile: 'ignore',
|
|
192
192
|
ExtendedStatistics: 'p100',
|
|
193
|
-
OKActions: ['devnull@mapbox.com']
|
|
193
|
+
OKActions: ['devnull@mapbox.com'],
|
|
194
|
+
LogRetentionInDays: 30
|
|
194
195
|
});
|
|
195
196
|
|
|
196
197
|
template = cf.merge(
|
|
@@ -538,39 +539,6 @@ test('[shortcuts] StreamLambda FilterCriteria', (assert) => {
|
|
|
538
539
|
}),
|
|
539
540
|
'`FilterCriteria` must contain property `Filter` of type array',
|
|
540
541
|
);
|
|
541
|
-
assert.throws(
|
|
542
|
-
() => new cf.shortcuts.StreamLambda({
|
|
543
|
-
LogicalName: 'MyLambda',
|
|
544
|
-
Code: {
|
|
545
|
-
S3Bucket: 'my-code-bucket',
|
|
546
|
-
S3Key: 'path/to/code.zip'
|
|
547
|
-
},
|
|
548
|
-
EventSourceArn: 'arn:aws:kinesis:us-east-1:123456789012:stream/fake',
|
|
549
|
-
FilterCriteria: {
|
|
550
|
-
Filters: [
|
|
551
|
-
{
|
|
552
|
-
Pattern: JSON.stringify({ eventName: ['1'] })
|
|
553
|
-
},
|
|
554
|
-
{
|
|
555
|
-
Pattern: JSON.stringify({ eventName: ['2'] })
|
|
556
|
-
},
|
|
557
|
-
{
|
|
558
|
-
Pattern: JSON.stringify({ eventName: ['3'] })
|
|
559
|
-
},
|
|
560
|
-
{
|
|
561
|
-
Pattern: JSON.stringify({ eventName: ['4'] })
|
|
562
|
-
},
|
|
563
|
-
{
|
|
564
|
-
Pattern: JSON.stringify({ eventName: ['5'] })
|
|
565
|
-
},
|
|
566
|
-
{
|
|
567
|
-
Pattern: JSON.stringify({ eventName: ['6'] })
|
|
568
|
-
}
|
|
569
|
-
]
|
|
570
|
-
}
|
|
571
|
-
}),
|
|
572
|
-
'`FilterCriteria.Filter` cannot contain more than 5 items, you may request a quota increase with AWS support if required.',
|
|
573
|
-
);
|
|
574
542
|
assert.throws(
|
|
575
543
|
() => new cf.shortcuts.StreamLambda({
|
|
576
544
|
LogicalName: 'MyLambda',
|
package/.idea/cloudfriend.iml
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<module type="WEB_MODULE" version="4">
|
|
3
|
-
<component name="NewModuleRootManager">
|
|
4
|
-
<content url="file://$MODULE_DIR$">
|
|
5
|
-
<excludeFolder url="file://$MODULE_DIR$/temp" />
|
|
6
|
-
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
|
|
7
|
-
<excludeFolder url="file://$MODULE_DIR$/tmp" />
|
|
8
|
-
</content>
|
|
9
|
-
<orderEntry type="inheritedJdk" />
|
|
10
|
-
<orderEntry type="sourceFolder" forTests="false" />
|
|
11
|
-
</component>
|
|
12
|
-
</module>
|
package/.idea/modules.xml
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<project version="4">
|
|
3
|
-
<component name="ProjectModuleManager">
|
|
4
|
-
<modules>
|
|
5
|
-
<module fileurl="file://$PROJECT_DIR$/.idea/cloudfriend.iml" filepath="$PROJECT_DIR$/.idea/cloudfriend.iml" />
|
|
6
|
-
</modules>
|
|
7
|
-
</component>
|
|
8
|
-
</project>
|