@ashishpandeyone/cdk-lambda-web-function 0.1.2 → 0.1.3

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/API.md CHANGED
@@ -55,6 +55,12 @@ new NodejsWebFunction(scope: Construct, id: string, props: NodejsWebFunctionProp
55
55
  | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.NodejsWebFunction.addEnvironment">addEnvironment</a></code> | Adds an environment variable. |
56
56
  | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.NodejsWebFunction.addToRolePolicy">addToRolePolicy</a></code> | Adds a statement to the execution role's policy. |
57
57
  | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.NodejsWebFunction.grantInvoke">grantInvoke</a></code> | Allows `grantee` to call the endpoint. |
58
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.NodejsWebFunction.metric">metric</a></code> | A metric of this function's execution environments in `AWS/Lambda/Web` (dimension `FunctionName`), across all endpoints. |
59
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.NodejsWebFunction.metricActiveTime">metricActiveTime</a></code> | Time the execution environments were active (`EnvironmentActiveTime`). |
60
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.NodejsWebFunction.metricConcurrentRequests">metricConcurrentRequests</a></code> | Requests an execution environment handled at once (`EnvironmentConcurrentRequests`), to compare with `maxConcurrencyPerEnvironment`. |
61
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.NodejsWebFunction.metricCpuTime">metricCpuTime</a></code> | CPU time the execution environments used (`EnvironmentCPUTime`). |
62
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.NodejsWebFunction.metricMaxMemoryUsage">metricMaxMemoryUsage</a></code> | Peak memory an execution environment used (`EnvironmentMaxMemoryUsage`); |
63
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.NodejsWebFunction.metricResponseBytes">metricResponseBytes</a></code> | Bytes sent in responses (`ResponseBytes`). |
58
64
 
59
65
  ---
60
66
 
@@ -204,6 +210,103 @@ Shortcut for `grants.invoke(grantee)`, as on `lambda.Function`.
204
210
 
205
211
  ---
206
212
 
213
+ ##### `metric` <a name="metric" id="@ashishpandeyone/cdk-lambda-web-function.NodejsWebFunction.metric"></a>
214
+
215
+ ```typescript
216
+ public metric(metricName: string, props?: MetricOptions): Metric
217
+ ```
218
+
219
+ A metric of this function's execution environments in `AWS/Lambda/Web` (dimension `FunctionName`), across all endpoints.
220
+
221
+ For request and error counts, use the endpoint's metrics (`fn.endpoint.metricRequests()`).
222
+
223
+ Metrics are published in the region that served the request: pass `region` for another serving region.
224
+ An alarm can only use metrics from its own stack's region.
225
+
226
+ ###### `metricName`<sup>Required</sup> <a name="metricName" id="@ashishpandeyone/cdk-lambda-web-function.NodejsWebFunction.metric.parameter.metricName"></a>
227
+
228
+ - *Type:* string
229
+
230
+ ---
231
+
232
+ ###### `props`<sup>Optional</sup> <a name="props" id="@ashishpandeyone/cdk-lambda-web-function.NodejsWebFunction.metric.parameter.props"></a>
233
+
234
+ - *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions
235
+
236
+ ---
237
+
238
+ ##### `metricActiveTime` <a name="metricActiveTime" id="@ashishpandeyone/cdk-lambda-web-function.NodejsWebFunction.metricActiveTime"></a>
239
+
240
+ ```typescript
241
+ public metricActiveTime(props?: MetricOptions): Metric
242
+ ```
243
+
244
+ Time the execution environments were active (`EnvironmentActiveTime`).
245
+
246
+ ###### `props`<sup>Optional</sup> <a name="props" id="@ashishpandeyone/cdk-lambda-web-function.NodejsWebFunction.metricActiveTime.parameter.props"></a>
247
+
248
+ - *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions
249
+
250
+ ---
251
+
252
+ ##### `metricConcurrentRequests` <a name="metricConcurrentRequests" id="@ashishpandeyone/cdk-lambda-web-function.NodejsWebFunction.metricConcurrentRequests"></a>
253
+
254
+ ```typescript
255
+ public metricConcurrentRequests(props?: MetricOptions): Metric
256
+ ```
257
+
258
+ Requests an execution environment handled at once (`EnvironmentConcurrentRequests`), to compare with `maxConcurrencyPerEnvironment`.
259
+
260
+ ###### `props`<sup>Optional</sup> <a name="props" id="@ashishpandeyone/cdk-lambda-web-function.NodejsWebFunction.metricConcurrentRequests.parameter.props"></a>
261
+
262
+ - *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions
263
+
264
+ ---
265
+
266
+ ##### `metricCpuTime` <a name="metricCpuTime" id="@ashishpandeyone/cdk-lambda-web-function.NodejsWebFunction.metricCpuTime"></a>
267
+
268
+ ```typescript
269
+ public metricCpuTime(props?: MetricOptions): Metric
270
+ ```
271
+
272
+ CPU time the execution environments used (`EnvironmentCPUTime`).
273
+
274
+ ###### `props`<sup>Optional</sup> <a name="props" id="@ashishpandeyone/cdk-lambda-web-function.NodejsWebFunction.metricCpuTime.parameter.props"></a>
275
+
276
+ - *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions
277
+
278
+ ---
279
+
280
+ ##### `metricMaxMemoryUsage` <a name="metricMaxMemoryUsage" id="@ashishpandeyone/cdk-lambda-web-function.NodejsWebFunction.metricMaxMemoryUsage"></a>
281
+
282
+ ```typescript
283
+ public metricMaxMemoryUsage(props?: MetricOptions): Metric
284
+ ```
285
+
286
+ Peak memory an execution environment used (`EnvironmentMaxMemoryUsage`);
287
+
288
+ each environment has 2 GB.
289
+
290
+ ###### `props`<sup>Optional</sup> <a name="props" id="@ashishpandeyone/cdk-lambda-web-function.NodejsWebFunction.metricMaxMemoryUsage.parameter.props"></a>
291
+
292
+ - *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions
293
+
294
+ ---
295
+
296
+ ##### `metricResponseBytes` <a name="metricResponseBytes" id="@ashishpandeyone/cdk-lambda-web-function.NodejsWebFunction.metricResponseBytes"></a>
297
+
298
+ ```typescript
299
+ public metricResponseBytes(props?: MetricOptions): Metric
300
+ ```
301
+
302
+ Bytes sent in responses (`ResponseBytes`).
303
+
304
+ ###### `props`<sup>Optional</sup> <a name="props" id="@ashishpandeyone/cdk-lambda-web-function.NodejsWebFunction.metricResponseBytes.parameter.props"></a>
305
+
306
+ - *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions
307
+
308
+ ---
309
+
207
310
  #### Static Functions <a name="Static Functions" id="Static Functions"></a>
208
311
 
209
312
  | **Name** | **Description** |
@@ -527,6 +630,12 @@ new WebFunction(scope: Construct, id: string, props: WebFunctionProps)
527
630
  | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunction.addEnvironment">addEnvironment</a></code> | Adds an environment variable. |
528
631
  | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunction.addToRolePolicy">addToRolePolicy</a></code> | Adds a statement to the execution role's policy. |
529
632
  | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunction.grantInvoke">grantInvoke</a></code> | Allows `grantee` to call the endpoint. |
633
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunction.metric">metric</a></code> | A metric of this function's execution environments in `AWS/Lambda/Web` (dimension `FunctionName`), across all endpoints. |
634
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunction.metricActiveTime">metricActiveTime</a></code> | Time the execution environments were active (`EnvironmentActiveTime`). |
635
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunction.metricConcurrentRequests">metricConcurrentRequests</a></code> | Requests an execution environment handled at once (`EnvironmentConcurrentRequests`), to compare with `maxConcurrencyPerEnvironment`. |
636
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunction.metricCpuTime">metricCpuTime</a></code> | CPU time the execution environments used (`EnvironmentCPUTime`). |
637
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunction.metricMaxMemoryUsage">metricMaxMemoryUsage</a></code> | Peak memory an execution environment used (`EnvironmentMaxMemoryUsage`); |
638
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunction.metricResponseBytes">metricResponseBytes</a></code> | Bytes sent in responses (`ResponseBytes`). |
530
639
 
531
640
  ---
532
641
 
@@ -676,6 +785,103 @@ Shortcut for `grants.invoke(grantee)`, as on `lambda.Function`.
676
785
 
677
786
  ---
678
787
 
788
+ ##### `metric` <a name="metric" id="@ashishpandeyone/cdk-lambda-web-function.WebFunction.metric"></a>
789
+
790
+ ```typescript
791
+ public metric(metricName: string, props?: MetricOptions): Metric
792
+ ```
793
+
794
+ A metric of this function's execution environments in `AWS/Lambda/Web` (dimension `FunctionName`), across all endpoints.
795
+
796
+ For request and error counts, use the endpoint's metrics (`fn.endpoint.metricRequests()`).
797
+
798
+ Metrics are published in the region that served the request: pass `region` for another serving region.
799
+ An alarm can only use metrics from its own stack's region.
800
+
801
+ ###### `metricName`<sup>Required</sup> <a name="metricName" id="@ashishpandeyone/cdk-lambda-web-function.WebFunction.metric.parameter.metricName"></a>
802
+
803
+ - *Type:* string
804
+
805
+ ---
806
+
807
+ ###### `props`<sup>Optional</sup> <a name="props" id="@ashishpandeyone/cdk-lambda-web-function.WebFunction.metric.parameter.props"></a>
808
+
809
+ - *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions
810
+
811
+ ---
812
+
813
+ ##### `metricActiveTime` <a name="metricActiveTime" id="@ashishpandeyone/cdk-lambda-web-function.WebFunction.metricActiveTime"></a>
814
+
815
+ ```typescript
816
+ public metricActiveTime(props?: MetricOptions): Metric
817
+ ```
818
+
819
+ Time the execution environments were active (`EnvironmentActiveTime`).
820
+
821
+ ###### `props`<sup>Optional</sup> <a name="props" id="@ashishpandeyone/cdk-lambda-web-function.WebFunction.metricActiveTime.parameter.props"></a>
822
+
823
+ - *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions
824
+
825
+ ---
826
+
827
+ ##### `metricConcurrentRequests` <a name="metricConcurrentRequests" id="@ashishpandeyone/cdk-lambda-web-function.WebFunction.metricConcurrentRequests"></a>
828
+
829
+ ```typescript
830
+ public metricConcurrentRequests(props?: MetricOptions): Metric
831
+ ```
832
+
833
+ Requests an execution environment handled at once (`EnvironmentConcurrentRequests`), to compare with `maxConcurrencyPerEnvironment`.
834
+
835
+ ###### `props`<sup>Optional</sup> <a name="props" id="@ashishpandeyone/cdk-lambda-web-function.WebFunction.metricConcurrentRequests.parameter.props"></a>
836
+
837
+ - *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions
838
+
839
+ ---
840
+
841
+ ##### `metricCpuTime` <a name="metricCpuTime" id="@ashishpandeyone/cdk-lambda-web-function.WebFunction.metricCpuTime"></a>
842
+
843
+ ```typescript
844
+ public metricCpuTime(props?: MetricOptions): Metric
845
+ ```
846
+
847
+ CPU time the execution environments used (`EnvironmentCPUTime`).
848
+
849
+ ###### `props`<sup>Optional</sup> <a name="props" id="@ashishpandeyone/cdk-lambda-web-function.WebFunction.metricCpuTime.parameter.props"></a>
850
+
851
+ - *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions
852
+
853
+ ---
854
+
855
+ ##### `metricMaxMemoryUsage` <a name="metricMaxMemoryUsage" id="@ashishpandeyone/cdk-lambda-web-function.WebFunction.metricMaxMemoryUsage"></a>
856
+
857
+ ```typescript
858
+ public metricMaxMemoryUsage(props?: MetricOptions): Metric
859
+ ```
860
+
861
+ Peak memory an execution environment used (`EnvironmentMaxMemoryUsage`);
862
+
863
+ each environment has 2 GB.
864
+
865
+ ###### `props`<sup>Optional</sup> <a name="props" id="@ashishpandeyone/cdk-lambda-web-function.WebFunction.metricMaxMemoryUsage.parameter.props"></a>
866
+
867
+ - *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions
868
+
869
+ ---
870
+
871
+ ##### `metricResponseBytes` <a name="metricResponseBytes" id="@ashishpandeyone/cdk-lambda-web-function.WebFunction.metricResponseBytes"></a>
872
+
873
+ ```typescript
874
+ public metricResponseBytes(props?: MetricOptions): Metric
875
+ ```
876
+
877
+ Bytes sent in responses (`ResponseBytes`).
878
+
879
+ ###### `props`<sup>Optional</sup> <a name="props" id="@ashishpandeyone/cdk-lambda-web-function.WebFunction.metricResponseBytes.parameter.props"></a>
880
+
881
+ - *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions
882
+
883
+ ---
884
+
679
885
  #### Static Functions <a name="Static Functions" id="Static Functions"></a>
680
886
 
681
887
  | **Name** | **Description** |
@@ -954,6 +1160,15 @@ Endpoints are created only through `WebFunction`, which owns their log groups in
954
1160
  | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.toString">toString</a></code> | Returns a string representation of this construct. |
955
1161
  | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.with">with</a></code> | Applies one or more mixins to this construct. |
956
1162
  | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.grantInvoke">grantInvoke</a></code> | Allows `grantee` to call this endpoint. |
1163
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.metric">metric</a></code> | A metric of this endpoint in `AWS/Lambda/Web` (dimensions `FunctionName` and `EndpointName`). |
1164
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.metricActiveEnvironments">metricActiveEnvironments</a></code> | Execution environments serving the endpoint (`EndpointActiveEnvironments`), to compare with `maxEnvironments`. |
1165
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.metricClientErrorRate">metricClientErrorRate</a></code> | The percentage of requests answered with a 4XX status (math expression; |
1166
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.metricClientErrors">metricClientErrors</a></code> | Requests answered with a 4XX status (`HTTPResponseStatusClass4XX`), including 429s from `rateLimit` and `maxEnvironments`. |
1167
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.metricEnvironmentThrottles">metricEnvironmentThrottles</a></code> | Requests rejected with 429 because the endpoint reached `maxEnvironments` (`EndpointActiveEnvironmentThrottles`). |
1168
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.metricRequests">metricRequests</a></code> | Requests the endpoint served (`ExecutedRequests`). |
1169
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.metricRequestThrottles">metricRequestThrottles</a></code> | Requests rejected with 429 because the endpoint reached its `rateLimit` (`EndpointRequestThrottles`). |
1170
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.metricServerErrorRate">metricServerErrorRate</a></code> | The percentage of requests answered with a 5XX status (math expression; |
1171
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.metricServerErrors">metricServerErrors</a></code> | Requests answered with a 5XX status (`HTTPResponseStatusClass5XX`). |
957
1172
  | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.regionalUrl">regionalUrl</a></code> | The URL of this endpoint in one region. |
958
1173
  | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.routeTraffic">routeTraffic</a></code> | Routes the endpoint to `revision` instead of the function's current revision, optionally sharing traffic with one more revision (`additionalRevisions`, which gets its weight; |
959
1174
 
@@ -1005,6 +1220,152 @@ Shortcut for `grants.invoke(grantee)`.
1005
1220
 
1006
1221
  ---
1007
1222
 
1223
+ ##### `metric` <a name="metric" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.metric"></a>
1224
+
1225
+ ```typescript
1226
+ public metric(metricName: string, props?: MetricOptions): Metric
1227
+ ```
1228
+
1229
+ A metric of this endpoint in `AWS/Lambda/Web` (dimensions `FunctionName` and `EndpointName`).
1230
+
1231
+ Metrics are published in the region that served the request: pass `region` for one of the endpoint's
1232
+ other regions. An alarm can only use metrics from its own stack's region.
1233
+
1234
+ ###### `metricName`<sup>Required</sup> <a name="metricName" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.metric.parameter.metricName"></a>
1235
+
1236
+ - *Type:* string
1237
+
1238
+ ---
1239
+
1240
+ ###### `props`<sup>Optional</sup> <a name="props" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.metric.parameter.props"></a>
1241
+
1242
+ - *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions
1243
+
1244
+ ---
1245
+
1246
+ ##### `metricActiveEnvironments` <a name="metricActiveEnvironments" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.metricActiveEnvironments"></a>
1247
+
1248
+ ```typescript
1249
+ public metricActiveEnvironments(props?: MetricOptions): Metric
1250
+ ```
1251
+
1252
+ Execution environments serving the endpoint (`EndpointActiveEnvironments`), to compare with `maxEnvironments`.
1253
+
1254
+ ###### `props`<sup>Optional</sup> <a name="props" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.metricActiveEnvironments.parameter.props"></a>
1255
+
1256
+ - *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions
1257
+
1258
+ ---
1259
+
1260
+ ##### `metricClientErrorRate` <a name="metricClientErrorRate" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.metricClientErrorRate"></a>
1261
+
1262
+ ```typescript
1263
+ public metricClientErrorRate(props?: MetricOptions): MathExpression
1264
+ ```
1265
+
1266
+ The percentage of requests answered with a 4XX status (math expression;
1267
+
1268
+ periods with no 4XX count as 0).
1269
+
1270
+ ###### `props`<sup>Optional</sup> <a name="props" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.metricClientErrorRate.parameter.props"></a>
1271
+
1272
+ - *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions
1273
+
1274
+ ---
1275
+
1276
+ ##### `metricClientErrors` <a name="metricClientErrors" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.metricClientErrors"></a>
1277
+
1278
+ ```typescript
1279
+ public metricClientErrors(props?: MetricOptions): Metric
1280
+ ```
1281
+
1282
+ Requests answered with a 4XX status (`HTTPResponseStatusClass4XX`), including 429s from `rateLimit` and `maxEnvironments`.
1283
+
1284
+ The metric only exists once it's non-zero, so alarms should treat missing data as not breaching.
1285
+
1286
+ ###### `props`<sup>Optional</sup> <a name="props" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.metricClientErrors.parameter.props"></a>
1287
+
1288
+ - *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions
1289
+
1290
+ ---
1291
+
1292
+ ##### `metricEnvironmentThrottles` <a name="metricEnvironmentThrottles" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.metricEnvironmentThrottles"></a>
1293
+
1294
+ ```typescript
1295
+ public metricEnvironmentThrottles(props?: MetricOptions): Metric
1296
+ ```
1297
+
1298
+ Requests rejected with 429 because the endpoint reached `maxEnvironments` (`EndpointActiveEnvironmentThrottles`).
1299
+
1300
+ ###### `props`<sup>Optional</sup> <a name="props" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.metricEnvironmentThrottles.parameter.props"></a>
1301
+
1302
+ - *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions
1303
+
1304
+ ---
1305
+
1306
+ ##### `metricRequests` <a name="metricRequests" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.metricRequests"></a>
1307
+
1308
+ ```typescript
1309
+ public metricRequests(props?: MetricOptions): Metric
1310
+ ```
1311
+
1312
+ Requests the endpoint served (`ExecutedRequests`).
1313
+
1314
+ There's no separate count of successful (2XX) responses.
1315
+
1316
+ ###### `props`<sup>Optional</sup> <a name="props" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.metricRequests.parameter.props"></a>
1317
+
1318
+ - *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions
1319
+
1320
+ ---
1321
+
1322
+ ##### `metricRequestThrottles` <a name="metricRequestThrottles" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.metricRequestThrottles"></a>
1323
+
1324
+ ```typescript
1325
+ public metricRequestThrottles(props?: MetricOptions): Metric
1326
+ ```
1327
+
1328
+ Requests rejected with 429 because the endpoint reached its `rateLimit` (`EndpointRequestThrottles`).
1329
+
1330
+ ###### `props`<sup>Optional</sup> <a name="props" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.metricRequestThrottles.parameter.props"></a>
1331
+
1332
+ - *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions
1333
+
1334
+ ---
1335
+
1336
+ ##### `metricServerErrorRate` <a name="metricServerErrorRate" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.metricServerErrorRate"></a>
1337
+
1338
+ ```typescript
1339
+ public metricServerErrorRate(props?: MetricOptions): MathExpression
1340
+ ```
1341
+
1342
+ The percentage of requests answered with a 5XX status (math expression;
1343
+
1344
+ periods with no 5XX count as 0).
1345
+
1346
+ ###### `props`<sup>Optional</sup> <a name="props" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.metricServerErrorRate.parameter.props"></a>
1347
+
1348
+ - *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions
1349
+
1350
+ ---
1351
+
1352
+ ##### `metricServerErrors` <a name="metricServerErrors" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.metricServerErrors"></a>
1353
+
1354
+ ```typescript
1355
+ public metricServerErrors(props?: MetricOptions): Metric
1356
+ ```
1357
+
1358
+ Requests answered with a 5XX status (`HTTPResponseStatusClass5XX`).
1359
+
1360
+ Includes the platform's 503s while the endpoint
1361
+ scales up for a sudden burst, not only your application's errors. The metric only exists once it's non-zero.
1362
+
1363
+ ###### `props`<sup>Optional</sup> <a name="props" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.metricServerErrors.parameter.props"></a>
1364
+
1365
+ - *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions
1366
+
1367
+ ---
1368
+
1008
1369
  ##### `regionalUrl` <a name="regionalUrl" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.regionalUrl"></a>
1009
1370
 
1010
1371
  ```typescript
@@ -1102,6 +1463,7 @@ Any object.
1102
1463
  | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.property.endpointType">endpointType</a></code> | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpointType">WebFunctionEndpointType</a></code> | Where the endpoint serves traffic from. |
1103
1464
  | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.property.grants">grants</a></code> | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionGrants">WebFunctionGrants</a></code> | Grants on this endpoint (e.g. `grants.invoke(principal)`). |
1104
1465
  | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.property.regions">regions</a></code> | <code>string[]</code> | Every region the endpoint serves from: the home region first, then the others in alphabetical order. |
1466
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.property.rollbackAlarms">rollbackAlarms</a></code> | <code>aws-cdk-lib.aws_cloudwatch.IAlarm[]</code> | The alarms this endpoint created for its deployment's `rollbackOn`, one per threshold in every region it serves from (the home region's first). |
1105
1467
  | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.property.url">url</a></code> | <code>string</code> | The endpoint's URL: the global URL for `MULTI_REGION`, otherwise the home region's. |
1106
1468
 
1107
1469
  ---
@@ -1202,6 +1564,20 @@ Every region the endpoint serves from: the home region first, then the others in
1202
1564
 
1203
1565
  ---
1204
1566
 
1567
+ ##### `rollbackAlarms`<sup>Required</sup> <a name="rollbackAlarms" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.property.rollbackAlarms"></a>
1568
+
1569
+ ```typescript
1570
+ public readonly rollbackAlarms: IAlarm[];
1571
+ ```
1572
+
1573
+ - *Type:* aws-cdk-lib.aws_cloudwatch.IAlarm[]
1574
+
1575
+ The alarms this endpoint created for its deployment's `rollbackOn`, one per threshold in every region it serves from (the home region's first).
1576
+
1577
+ Empty without `rollbackOn`.
1578
+
1579
+ ---
1580
+
1205
1581
  ##### `url`<sup>Required</sup> <a name="url" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.property.url"></a>
1206
1582
 
1207
1583
  ```typescript
@@ -2119,6 +2495,7 @@ const webFunctionCanaryDeploymentOptions: WebFunctionCanaryDeploymentOptions = {
2119
2495
  | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionCanaryDeploymentOptions.property.bake">bake</a></code> | <code>aws-cdk-lib.Duration</code> | How long the new revision serves `percent` before it gets all traffic (1-45 minutes). |
2120
2496
  | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionCanaryDeploymentOptions.property.percent">percent</a></code> | <code>number</code> | The share of traffic, in whole percent (1-99), that the new revision gets first. |
2121
2497
  | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionCanaryDeploymentOptions.property.alarms">alarms</a></code> | <code>aws-cdk-lib.aws_cloudwatch.IAlarm[]</code> | Alarms that stop the deployment: if one is in ALARM, the endpoint goes back to the previous revision and the deployment fails, so CloudFormation rolls the stack back. |
2498
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionCanaryDeploymentOptions.property.rollbackOn">rollbackOn</a></code> | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionRollbackOptions">WebFunctionRollbackOptions</a></code> | Alarms on the endpoint's own error rates, created by the endpoint in every region it serves from. |
2122
2499
 
2123
2500
  ---
2124
2501
 
@@ -2164,6 +2541,21 @@ Use alarms in any region (by ARN), including composite alarms.
2164
2541
 
2165
2542
  ---
2166
2543
 
2544
+ ##### `rollbackOn`<sup>Optional</sup> <a name="rollbackOn" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionCanaryDeploymentOptions.property.rollbackOn"></a>
2545
+
2546
+ ```typescript
2547
+ public readonly rollbackOn: WebFunctionRollbackOptions;
2548
+ ```
2549
+
2550
+ - *Type:* <a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionRollbackOptions">WebFunctionRollbackOptions</a>
2551
+ - *Default:* no endpoint alarms
2552
+
2553
+ Alarms on the endpoint's own error rates, created by the endpoint in every region it serves from.
2554
+
2555
+ They stop the deployment like `alarms` (both can be used together).
2556
+
2557
+ ---
2558
+
2167
2559
  ### WebFunctionEndpointOptions <a name="WebFunctionEndpointOptions" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpointOptions"></a>
2168
2560
 
2169
2561
  Options for a Web Function's endpoint.
@@ -2319,6 +2711,7 @@ const webFunctionLinearDeploymentOptions: WebFunctionLinearDeploymentOptions = {
2319
2711
  | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionLinearDeploymentOptions.property.interval">interval</a></code> | <code>aws-cdk-lib.Duration</code> | How long each step serves before the next one (at least 1 minute, and at most 45 minutes in total). |
2320
2712
  | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionLinearDeploymentOptions.property.percent">percent</a></code> | <code>number</code> | The share of traffic, in whole percent (5-50), that moves to the new revision at each step. |
2321
2713
  | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionLinearDeploymentOptions.property.alarms">alarms</a></code> | <code>aws-cdk-lib.aws_cloudwatch.IAlarm[]</code> | Alarms that stop the deployment: if one is in ALARM, the endpoint goes back to the previous revision and the deployment fails, so CloudFormation rolls the stack back. |
2714
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionLinearDeploymentOptions.property.rollbackOn">rollbackOn</a></code> | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionRollbackOptions">WebFunctionRollbackOptions</a></code> | Alarms on the endpoint's own error rates, created by the endpoint in every region it serves from. |
2322
2715
 
2323
2716
  ---
2324
2717
 
@@ -2362,6 +2755,21 @@ Use alarms in any region (by ARN), including composite alarms.
2362
2755
 
2363
2756
  ---
2364
2757
 
2758
+ ##### `rollbackOn`<sup>Optional</sup> <a name="rollbackOn" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionLinearDeploymentOptions.property.rollbackOn"></a>
2759
+
2760
+ ```typescript
2761
+ public readonly rollbackOn: WebFunctionRollbackOptions;
2762
+ ```
2763
+
2764
+ - *Type:* <a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionRollbackOptions">WebFunctionRollbackOptions</a>
2765
+ - *Default:* no endpoint alarms
2766
+
2767
+ Alarms on the endpoint's own error rates, created by the endpoint in every region it serves from.
2768
+
2769
+ They stop the deployment like `alarms` (both can be used together).
2770
+
2771
+ ---
2772
+
2365
2773
  ### WebFunctionOptions <a name="WebFunctionOptions" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionOptions"></a>
2366
2774
 
2367
2775
  Options shared by `WebFunction` and `NodejsWebFunction`: everything except how the code is supplied.
@@ -2930,6 +3338,104 @@ The revision's share of the endpoint's traffic, as a fraction (like `lambda.Alia
2930
3338
 
2931
3339
  ---
2932
3340
 
3341
+ ### WebFunctionRollbackOptions <a name="WebFunctionRollbackOptions" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionRollbackOptions"></a>
3342
+
3343
+ Alarms an endpoint creates on its own metrics to stop a canary or linear deployment.
3344
+
3345
+ The endpoint creates one alarm per threshold in every region it serves from (metrics are published
3346
+ in the region that served the request, and an alarm can only watch metrics in its own region).
3347
+ Lambda Web Function metrics have no revision dimension, so the alarms watch the whole endpoint: while
3348
+ the new revision gets 10% of the traffic, its errors are about a tenth of the endpoint's.
3349
+
3350
+ #### Initializer <a name="Initializer" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionRollbackOptions.Initializer"></a>
3351
+
3352
+ ```typescript
3353
+ import { WebFunctionRollbackOptions } from '@ashishpandeyone/cdk-lambda-web-function'
3354
+
3355
+ const webFunctionRollbackOptions: WebFunctionRollbackOptions = { ... }
3356
+ ```
3357
+
3358
+ #### Properties <a name="Properties" id="Properties"></a>
3359
+
3360
+ | **Name** | **Type** | **Description** |
3361
+ | --- | --- | --- |
3362
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionRollbackOptions.property.clientErrorRate">clientErrorRate</a></code> | <code>number</code> | Roll back when more than this percent of the endpoint's requests get a 4XX response (0-100). |
3363
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionRollbackOptions.property.evaluationPeriods">evaluationPeriods</a></code> | <code>number</code> | How many consecutive periods must breach a threshold before the deployment rolls back. |
3364
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionRollbackOptions.property.minimumRequests">minimumRequests</a></code> | <code>number</code> | Periods with fewer requests than this don't count, so one failed request out of two doesn't roll back. |
3365
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionRollbackOptions.property.period">period</a></code> | <code>aws-cdk-lib.Duration</code> | The period each rate is measured over (at least 1 minute, in whole minutes). |
3366
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionRollbackOptions.property.serverErrorRate">serverErrorRate</a></code> | <code>number</code> | Roll back when more than this percent of the endpoint's requests get a 5XX response (0-100). |
3367
+
3368
+ ---
3369
+
3370
+ ##### `clientErrorRate`<sup>Optional</sup> <a name="clientErrorRate" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionRollbackOptions.property.clientErrorRate"></a>
3371
+
3372
+ ```typescript
3373
+ public readonly clientErrorRate: number;
3374
+ ```
3375
+
3376
+ - *Type:* number
3377
+ - *Default:* no client error alarm
3378
+
3379
+ Roll back when more than this percent of the endpoint's requests get a 4XX response (0-100).
3380
+
3381
+ Requests over `rateLimit` or `maxEnvironments` get 429, which counts here.
3382
+
3383
+ ---
3384
+
3385
+ ##### `evaluationPeriods`<sup>Optional</sup> <a name="evaluationPeriods" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionRollbackOptions.property.evaluationPeriods"></a>
3386
+
3387
+ ```typescript
3388
+ public readonly evaluationPeriods: number;
3389
+ ```
3390
+
3391
+ - *Type:* number
3392
+ - *Default:* 2
3393
+
3394
+ How many consecutive periods must breach a threshold before the deployment rolls back.
3395
+
3396
+ ---
3397
+
3398
+ ##### `minimumRequests`<sup>Optional</sup> <a name="minimumRequests" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionRollbackOptions.property.minimumRequests"></a>
3399
+
3400
+ ```typescript
3401
+ public readonly minimumRequests: number;
3402
+ ```
3403
+
3404
+ - *Type:* number
3405
+ - *Default:* 10
3406
+
3407
+ Periods with fewer requests than this don't count, so one failed request out of two doesn't roll back.
3408
+
3409
+ ---
3410
+
3411
+ ##### `period`<sup>Optional</sup> <a name="period" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionRollbackOptions.property.period"></a>
3412
+
3413
+ ```typescript
3414
+ public readonly period: Duration;
3415
+ ```
3416
+
3417
+ - *Type:* aws-cdk-lib.Duration
3418
+ - *Default:* Duration.minutes(1)
3419
+
3420
+ The period each rate is measured over (at least 1 minute, in whole minutes).
3421
+
3422
+ ---
3423
+
3424
+ ##### `serverErrorRate`<sup>Optional</sup> <a name="serverErrorRate" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionRollbackOptions.property.serverErrorRate"></a>
3425
+
3426
+ ```typescript
3427
+ public readonly serverErrorRate: number;
3428
+ ```
3429
+
3430
+ - *Type:* number
3431
+ - *Default:* no server error alarm
3432
+
3433
+ Roll back when more than this percent of the endpoint's requests get a 5XX response (0-100).
3434
+
3435
+ 5XX includes the platform's 503s while an endpoint scales up for a sudden burst, not only your application's errors.
3436
+
3437
+ ---
3438
+
2933
3439
  ## Classes <a name="Classes" id="Classes"></a>
2934
3440
 
2935
3441
  ### WebFunctionDeployment <a name="WebFunctionDeployment" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionDeployment"></a>