@mapbox/cloudfriend 8.1.0 → 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/changelog.md CHANGED
@@ -1,5 +1,9 @@
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
9
  - Allow `FilterCriteria` property to be defined for Stream Lambda shortcuts
@@ -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
 
@@ -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.&lt;String&gt;</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
@@ -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: 14
143
+ RetentionInDays: LogRetentionInDays
142
144
  }
143
145
  },
144
146
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mapbox/cloudfriend",
3
- "version": "8.1.0",
3
+ "version": "8.2.0",
4
4
  "description": "Helper functions for assembling CloudFormation templates in JavaScript",
5
5
  "main": "index.js",
6
6
  "engines": {
@@ -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": 14
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
- "sg-12345"
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
+ }
@@ -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(