@ashishpandeyone/cdk-lambda-web-function 0.1.1 → 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
@@ -51,9 +51,16 @@ new NodejsWebFunction(scope: Construct, id: string, props: NodejsWebFunctionProp
51
51
  | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.NodejsWebFunction.with">with</a></code> | Applies one or more mixins to this construct. |
52
52
  | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.NodejsWebFunction.applyCrossStackReferenceStrength">applyCrossStackReferenceStrength</a></code> | Override the cross-stack reference strength for this resource. |
53
53
  | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.NodejsWebFunction.applyRemovalPolicy">applyRemovalPolicy</a></code> | Apply the given removal policy to this resource. |
54
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.NodejsWebFunction.addEndpoint">addEndpoint</a></code> | Adds an endpoint (up to 10 per function), e.g. a public one next to an IAM-only one, or one pinned to an earlier revision. Each endpoint has its own URL, authentication, regions and limits. |
54
55
  | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.NodejsWebFunction.addEnvironment">addEnvironment</a></code> | Adds an environment variable. |
55
56
  | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.NodejsWebFunction.addToRolePolicy">addToRolePolicy</a></code> | Adds a statement to the execution role's policy. |
56
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`). |
57
64
 
58
65
  ---
59
66
 
@@ -128,6 +135,28 @@ account for data recovery and cleanup later (`RemovalPolicy.RETAIN`).
128
135
 
129
136
  ---
130
137
 
138
+ ##### `addEndpoint` <a name="addEndpoint" id="@ashishpandeyone/cdk-lambda-web-function.NodejsWebFunction.addEndpoint"></a>
139
+
140
+ ```typescript
141
+ public addEndpoint(id: string, options: AddWebFunctionEndpointOptions): WebFunctionEndpoint
142
+ ```
143
+
144
+ Adds an endpoint (up to 10 per function), e.g. a public one next to an IAM-only one, or one pinned to an earlier revision. Each endpoint has its own URL, authentication, regions and limits.
145
+
146
+ ###### `id`<sup>Required</sup> <a name="id" id="@ashishpandeyone/cdk-lambda-web-function.NodejsWebFunction.addEndpoint.parameter.id"></a>
147
+
148
+ - *Type:* string
149
+
150
+ the endpoint's construct ID, also used in its generated name (`<id>-<hash>`).
151
+
152
+ ---
153
+
154
+ ###### `options`<sup>Required</sup> <a name="options" id="@ashishpandeyone/cdk-lambda-web-function.NodejsWebFunction.addEndpoint.parameter.options"></a>
155
+
156
+ - *Type:* <a href="#@ashishpandeyone/cdk-lambda-web-function.AddWebFunctionEndpointOptions">AddWebFunctionEndpointOptions</a>
157
+
158
+ ---
159
+
131
160
  ##### `addEnvironment` <a name="addEnvironment" id="@ashishpandeyone/cdk-lambda-web-function.NodejsWebFunction.addEnvironment"></a>
132
161
 
133
162
  ```typescript
@@ -181,6 +210,103 @@ Shortcut for `grants.invoke(grantee)`, as on `lambda.Function`.
181
210
 
182
211
  ---
183
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
+
184
310
  #### Static Functions <a name="Static Functions" id="Static Functions"></a>
185
311
 
186
312
  | **Name** | **Description** |
@@ -262,9 +388,10 @@ Check whether the given construct is a Resource.
262
388
  | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.NodejsWebFunction.property.node">node</a></code> | <code>constructs.Node</code> | The tree node. |
263
389
  | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.NodejsWebFunction.property.env">env</a></code> | <code>aws-cdk-lib.interfaces.ResourceEnvironment</code> | The environment this resource belongs to. |
264
390
  | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.NodejsWebFunction.property.stack">stack</a></code> | <code>aws-cdk-lib.Stack</code> | The stack in which this resource is defined. |
265
- | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.NodejsWebFunction.property.endpoint">endpoint</a></code> | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint">WebFunctionEndpoint</a></code> | The function's endpoint. |
391
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.NodejsWebFunction.property.currentRevision">currentRevision</a></code> | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.IWebFunctionRevision">IWebFunctionRevision</a></code> | The revision built from the current code and configuration. |
392
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.NodejsWebFunction.property.endpoint">endpoint</a></code> | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint">WebFunctionEndpoint</a></code> | The default endpoint. |
266
393
  | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.NodejsWebFunction.property.grantPrincipal">grantPrincipal</a></code> | <code>aws-cdk-lib.aws_iam.IPrincipal</code> | The principal to grant permissions to (the execution role). |
267
- | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.NodejsWebFunction.property.grants">grants</a></code> | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionGrants">WebFunctionGrants</a></code> | Grants on the function (e.g. `grants.invoke(principal)`). |
394
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.NodejsWebFunction.property.grants">grants</a></code> | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionGrants">WebFunctionGrants</a></code> | Grants on the default endpoint (e.g. `grants.invoke(principal)`). Other endpoints have their own `grants`. |
268
395
  | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.NodejsWebFunction.property.logGroup">logGroup</a></code> | <code>aws-cdk-lib.aws_logs.ILogGroup</code> | The home-region log group that receives the logs of every region the function serves from. |
269
396
  | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.NodejsWebFunction.property.revisionId">revisionId</a></code> | <code>string</code> | The ID of the current revision. |
270
397
  | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.NodejsWebFunction.property.role">role</a></code> | <code>aws-cdk-lib.aws_iam.IRole</code> | The execution role. |
@@ -318,6 +445,18 @@ The stack in which this resource is defined.
318
445
 
319
446
  ---
320
447
 
448
+ ##### `currentRevision`<sup>Required</sup> <a name="currentRevision" id="@ashishpandeyone/cdk-lambda-web-function.NodejsWebFunction.property.currentRevision"></a>
449
+
450
+ ```typescript
451
+ public readonly currentRevision: IWebFunctionRevision;
452
+ ```
453
+
454
+ - *Type:* <a href="#@ashishpandeyone/cdk-lambda-web-function.IWebFunctionRevision">IWebFunctionRevision</a>
455
+
456
+ The revision built from the current code and configuration.
457
+
458
+ ---
459
+
321
460
  ##### `endpoint`<sup>Required</sup> <a name="endpoint" id="@ashishpandeyone/cdk-lambda-web-function.NodejsWebFunction.property.endpoint"></a>
322
461
 
323
462
  ```typescript
@@ -326,7 +465,9 @@ public readonly endpoint: WebFunctionEndpoint;
326
465
 
327
466
  - *Type:* <a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint">WebFunctionEndpoint</a>
328
467
 
329
- The function's endpoint.
468
+ The default endpoint.
469
+
470
+ Add more with `addEndpoint`.
330
471
 
331
472
  ---
332
473
 
@@ -350,7 +491,7 @@ public readonly grants: WebFunctionGrants;
350
491
 
351
492
  - *Type:* <a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionGrants">WebFunctionGrants</a>
352
493
 
353
- Grants on the function (e.g. `grants.invoke(principal)`).
494
+ Grants on the default endpoint (e.g. `grants.invoke(principal)`). Other endpoints have their own `grants`.
354
495
 
355
496
  ---
356
497
 
@@ -378,6 +519,8 @@ public readonly revisionId: string;
378
519
 
379
520
  The ID of the current revision.
380
521
 
522
+ Same as `currentRevision.revisionId`.
523
+
381
524
  ---
382
525
 
383
526
  ##### `role`<sup>Required</sup> <a name="role" id="@ashishpandeyone/cdk-lambda-web-function.NodejsWebFunction.property.role"></a>
@@ -435,8 +578,9 @@ A reference to this function, for APIs that accept `lambda.IWebFunctionRef`.
435
578
 
436
579
  A Node.js HTTP server running as an AWS Lambda Web Function, served from one or more regions.
437
580
 
438
- Creates the function, its current revision (code and configuration; any change replaces it),
439
- an HTTPS endpoint, an execution role, and owns the function's log groups in every region.
581
+ Creates the function, its current revision (code and configuration; any change creates a new one,
582
+ and the newest `revisionRetention` are kept), a default HTTPS endpoint, an execution role, and owns
583
+ the function's log groups in every region its endpoints serve from.
440
584
 
441
585
  Importing existing functions (`fromXxx` methods) is planned after 0.1.
442
586
 
@@ -482,9 +626,16 @@ new WebFunction(scope: Construct, id: string, props: WebFunctionProps)
482
626
  | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunction.with">with</a></code> | Applies one or more mixins to this construct. |
483
627
  | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunction.applyCrossStackReferenceStrength">applyCrossStackReferenceStrength</a></code> | Override the cross-stack reference strength for this resource. |
484
628
  | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunction.applyRemovalPolicy">applyRemovalPolicy</a></code> | Apply the given removal policy to this resource. |
629
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunction.addEndpoint">addEndpoint</a></code> | Adds an endpoint (up to 10 per function), e.g. a public one next to an IAM-only one, or one pinned to an earlier revision. Each endpoint has its own URL, authentication, regions and limits. |
485
630
  | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunction.addEnvironment">addEnvironment</a></code> | Adds an environment variable. |
486
631
  | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunction.addToRolePolicy">addToRolePolicy</a></code> | Adds a statement to the execution role's policy. |
487
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`). |
488
639
 
489
640
  ---
490
641
 
@@ -559,6 +710,28 @@ account for data recovery and cleanup later (`RemovalPolicy.RETAIN`).
559
710
 
560
711
  ---
561
712
 
713
+ ##### `addEndpoint` <a name="addEndpoint" id="@ashishpandeyone/cdk-lambda-web-function.WebFunction.addEndpoint"></a>
714
+
715
+ ```typescript
716
+ public addEndpoint(id: string, options: AddWebFunctionEndpointOptions): WebFunctionEndpoint
717
+ ```
718
+
719
+ Adds an endpoint (up to 10 per function), e.g. a public one next to an IAM-only one, or one pinned to an earlier revision. Each endpoint has its own URL, authentication, regions and limits.
720
+
721
+ ###### `id`<sup>Required</sup> <a name="id" id="@ashishpandeyone/cdk-lambda-web-function.WebFunction.addEndpoint.parameter.id"></a>
722
+
723
+ - *Type:* string
724
+
725
+ the endpoint's construct ID, also used in its generated name (`<id>-<hash>`).
726
+
727
+ ---
728
+
729
+ ###### `options`<sup>Required</sup> <a name="options" id="@ashishpandeyone/cdk-lambda-web-function.WebFunction.addEndpoint.parameter.options"></a>
730
+
731
+ - *Type:* <a href="#@ashishpandeyone/cdk-lambda-web-function.AddWebFunctionEndpointOptions">AddWebFunctionEndpointOptions</a>
732
+
733
+ ---
734
+
562
735
  ##### `addEnvironment` <a name="addEnvironment" id="@ashishpandeyone/cdk-lambda-web-function.WebFunction.addEnvironment"></a>
563
736
 
564
737
  ```typescript
@@ -612,6 +785,103 @@ Shortcut for `grants.invoke(grantee)`, as on `lambda.Function`.
612
785
 
613
786
  ---
614
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
+
615
885
  #### Static Functions <a name="Static Functions" id="Static Functions"></a>
616
886
 
617
887
  | **Name** | **Description** |
@@ -693,9 +963,10 @@ Check whether the given construct is a Resource.
693
963
  | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunction.property.node">node</a></code> | <code>constructs.Node</code> | The tree node. |
694
964
  | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunction.property.env">env</a></code> | <code>aws-cdk-lib.interfaces.ResourceEnvironment</code> | The environment this resource belongs to. |
695
965
  | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunction.property.stack">stack</a></code> | <code>aws-cdk-lib.Stack</code> | The stack in which this resource is defined. |
696
- | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunction.property.endpoint">endpoint</a></code> | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint">WebFunctionEndpoint</a></code> | The function's endpoint. |
966
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunction.property.currentRevision">currentRevision</a></code> | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.IWebFunctionRevision">IWebFunctionRevision</a></code> | The revision built from the current code and configuration. |
967
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunction.property.endpoint">endpoint</a></code> | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint">WebFunctionEndpoint</a></code> | The default endpoint. |
697
968
  | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunction.property.grantPrincipal">grantPrincipal</a></code> | <code>aws-cdk-lib.aws_iam.IPrincipal</code> | The principal to grant permissions to (the execution role). |
698
- | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunction.property.grants">grants</a></code> | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionGrants">WebFunctionGrants</a></code> | Grants on the function (e.g. `grants.invoke(principal)`). |
969
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunction.property.grants">grants</a></code> | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionGrants">WebFunctionGrants</a></code> | Grants on the default endpoint (e.g. `grants.invoke(principal)`). Other endpoints have their own `grants`. |
699
970
  | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunction.property.logGroup">logGroup</a></code> | <code>aws-cdk-lib.aws_logs.ILogGroup</code> | The home-region log group that receives the logs of every region the function serves from. |
700
971
  | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunction.property.revisionId">revisionId</a></code> | <code>string</code> | The ID of the current revision. |
701
972
  | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunction.property.role">role</a></code> | <code>aws-cdk-lib.aws_iam.IRole</code> | The execution role. |
@@ -749,6 +1020,18 @@ The stack in which this resource is defined.
749
1020
 
750
1021
  ---
751
1022
 
1023
+ ##### `currentRevision`<sup>Required</sup> <a name="currentRevision" id="@ashishpandeyone/cdk-lambda-web-function.WebFunction.property.currentRevision"></a>
1024
+
1025
+ ```typescript
1026
+ public readonly currentRevision: IWebFunctionRevision;
1027
+ ```
1028
+
1029
+ - *Type:* <a href="#@ashishpandeyone/cdk-lambda-web-function.IWebFunctionRevision">IWebFunctionRevision</a>
1030
+
1031
+ The revision built from the current code and configuration.
1032
+
1033
+ ---
1034
+
752
1035
  ##### `endpoint`<sup>Required</sup> <a name="endpoint" id="@ashishpandeyone/cdk-lambda-web-function.WebFunction.property.endpoint"></a>
753
1036
 
754
1037
  ```typescript
@@ -757,7 +1040,9 @@ public readonly endpoint: WebFunctionEndpoint;
757
1040
 
758
1041
  - *Type:* <a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint">WebFunctionEndpoint</a>
759
1042
 
760
- The function's endpoint.
1043
+ The default endpoint.
1044
+
1045
+ Add more with `addEndpoint`.
761
1046
 
762
1047
  ---
763
1048
 
@@ -781,7 +1066,7 @@ public readonly grants: WebFunctionGrants;
781
1066
 
782
1067
  - *Type:* <a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionGrants">WebFunctionGrants</a>
783
1068
 
784
- Grants on the function (e.g. `grants.invoke(principal)`).
1069
+ Grants on the default endpoint (e.g. `grants.invoke(principal)`). Other endpoints have their own `grants`.
785
1070
 
786
1071
  ---
787
1072
 
@@ -809,6 +1094,8 @@ public readonly revisionId: string;
809
1094
 
810
1095
  The ID of the current revision.
811
1096
 
1097
+ Same as `currentRevision.revisionId`.
1098
+
812
1099
  ---
813
1100
 
814
1101
  ##### `role`<sup>Required</sup> <a name="role" id="@ashishpandeyone/cdk-lambda-web-function.WebFunction.property.role"></a>
@@ -862,9 +1149,9 @@ A reference to this function, for APIs that accept `lambda.IWebFunctionRef`.
862
1149
 
863
1150
  ### WebFunctionEndpoint <a name="WebFunctionEndpoint" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint"></a>
864
1151
 
865
- The HTTPS endpoint of a Web Function. Created by `WebFunction`; access it as `fn.endpoint`.
1152
+ An HTTPS endpoint of a Web Function: `fn.endpoint` (the default one) or the result of `fn.addEndpoint()`.
866
1153
 
867
- Only `WebFunction` creates endpoints in this version (one per function), so the constructor is private.
1154
+ Endpoints are created only through `WebFunction`, which owns their log groups in every region, so the constructor is private.
868
1155
 
869
1156
  #### Methods <a name="Methods" id="Methods"></a>
870
1157
 
@@ -872,7 +1159,18 @@ Only `WebFunction` creates endpoints in this version (one per function), so the
872
1159
  | --- | --- |
873
1160
  | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.toString">toString</a></code> | Returns a string representation of this construct. |
874
1161
  | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.with">with</a></code> | Applies one or more mixins to this construct. |
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`). |
875
1172
  | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.regionalUrl">regionalUrl</a></code> | The URL of this endpoint in one region. |
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; |
876
1174
 
877
1175
  ---
878
1176
 
@@ -905,164 +1203,752 @@ The mixins to apply.
905
1203
 
906
1204
  ---
907
1205
 
908
- ##### `regionalUrl` <a name="regionalUrl" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.regionalUrl"></a>
1206
+ ##### `grantInvoke` <a name="grantInvoke" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.grantInvoke"></a>
909
1207
 
910
1208
  ```typescript
911
- public regionalUrl(region: string): string
1209
+ public grantInvoke(grantee: IGrantable): Grant
912
1210
  ```
913
1211
 
914
- The URL of this endpoint in one region.
915
-
916
- Only for `PER_REGION` endpoints.
917
-
918
- ###### `region`<sup>Required</sup> <a name="region" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.regionalUrl.parameter.region"></a>
919
-
920
- - *Type:* string
921
-
922
- one of `regions`.
1212
+ Allows `grantee` to call this endpoint.
923
1213
 
924
- ---
1214
+ Shortcut for `grants.invoke(grantee)`.
1215
+ [disable-awslint:no-grants]
925
1216
 
926
- #### Static Functions <a name="Static Functions" id="Static Functions"></a>
1217
+ ###### `grantee`<sup>Required</sup> <a name="grantee" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.grantInvoke.parameter.grantee"></a>
927
1218
 
928
- | **Name** | **Description** |
929
- | --- | --- |
930
- | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.isConstruct">isConstruct</a></code> | Checks if `x` is a construct. |
1219
+ - *Type:* aws-cdk-lib.aws_iam.IGrantable
931
1220
 
932
1221
  ---
933
1222
 
934
- ##### `isConstruct` <a name="isConstruct" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.isConstruct"></a>
1223
+ ##### `metric` <a name="metric" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.metric"></a>
935
1224
 
936
1225
  ```typescript
937
- import { WebFunctionEndpoint } from '@ashishpandeyone/cdk-lambda-web-function'
938
-
939
- WebFunctionEndpoint.isConstruct(x: any)
1226
+ public metric(metricName: string, props?: MetricOptions): Metric
940
1227
  ```
941
1228
 
942
- Checks if `x` is a construct.
943
-
944
- Use this method instead of `instanceof` to properly detect `Construct`
945
- instances, even when the construct library is symlinked.
946
-
947
- Explanation: in JavaScript, multiple copies of the `constructs` library on
948
- disk are seen as independent, completely different libraries. As a
949
- consequence, the class `Construct` in each copy of the `constructs` library
950
- is seen as a different class, and an instance of one class will not test as
951
- `instanceof` the other class. `npm install` will not create installations
952
- like this, but users may manually symlink construct libraries together or
953
- use a monorepo tool: in those cases, multiple copies of the `constructs`
954
- library can be accidentally installed, and `instanceof` will behave
955
- unpredictably. It is safest to avoid using `instanceof`, and using
956
- this type-testing method instead.
1229
+ A metric of this endpoint in `AWS/Lambda/Web` (dimensions `FunctionName` and `EndpointName`).
957
1230
 
958
- ###### `x`<sup>Required</sup> <a name="x" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.isConstruct.parameter.x"></a>
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.
959
1233
 
960
- - *Type:* any
1234
+ ###### `metricName`<sup>Required</sup> <a name="metricName" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.metric.parameter.metricName"></a>
961
1235
 
962
- Any object.
1236
+ - *Type:* string
963
1237
 
964
1238
  ---
965
1239
 
966
- #### Properties <a name="Properties" id="Properties"></a>
1240
+ ###### `props`<sup>Optional</sup> <a name="props" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.metric.parameter.props"></a>
967
1241
 
968
- | **Name** | **Type** | **Description** |
969
- | --- | --- | --- |
970
- | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.property.node">node</a></code> | <code>constructs.Node</code> | The tree node. |
971
- | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.property.domainName">domainName</a></code> | <code>string</code> | The endpoint's domain name: the global domain for `MULTI_REGION`, otherwise the home region's. |
972
- | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.property.endpointArn">endpointArn</a></code> | <code>string</code> | The endpoint's ARN. |
973
- | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.property.endpointName">endpointName</a></code> | <code>string</code> | The endpoint's name. |
974
- | <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. |
975
- | <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. |
976
- | <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. |
1242
+ - *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions
977
1243
 
978
1244
  ---
979
1245
 
980
- ##### `node`<sup>Required</sup> <a name="node" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.property.node"></a>
1246
+ ##### `metricActiveEnvironments` <a name="metricActiveEnvironments" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.metricActiveEnvironments"></a>
981
1247
 
982
1248
  ```typescript
983
- public readonly node: Node;
1249
+ public metricActiveEnvironments(props?: MetricOptions): Metric
984
1250
  ```
985
1251
 
986
- - *Type:* constructs.Node
1252
+ Execution environments serving the endpoint (`EndpointActiveEnvironments`), to compare with `maxEnvironments`.
987
1253
 
988
- The tree node.
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
989
1257
 
990
1258
  ---
991
1259
 
992
- ##### `domainName`<sup>Required</sup> <a name="domainName" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.property.domainName"></a>
1260
+ ##### `metricClientErrorRate` <a name="metricClientErrorRate" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.metricClientErrorRate"></a>
993
1261
 
994
1262
  ```typescript
995
- public readonly domainName: string;
1263
+ public metricClientErrorRate(props?: MetricOptions): MathExpression
996
1264
  ```
997
1265
 
998
- - *Type:* string
1266
+ The percentage of requests answered with a 4XX status (math expression;
999
1267
 
1000
- The endpoint's domain name: the global domain for `MULTI_REGION`, otherwise the home region's.
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
1001
1273
 
1002
1274
  ---
1003
1275
 
1004
- ##### `endpointArn`<sup>Required</sup> <a name="endpointArn" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.property.endpointArn"></a>
1276
+ ##### `metricClientErrors` <a name="metricClientErrors" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.metricClientErrors"></a>
1005
1277
 
1006
1278
  ```typescript
1007
- public readonly endpointArn: string;
1279
+ public metricClientErrors(props?: MetricOptions): Metric
1008
1280
  ```
1009
1281
 
1010
- - *Type:* string
1282
+ Requests answered with a 4XX status (`HTTPResponseStatusClass4XX`), including 429s from `rateLimit` and `maxEnvironments`.
1011
1283
 
1012
- The endpoint's ARN.
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
1013
1289
 
1014
1290
  ---
1015
1291
 
1016
- ##### `endpointName`<sup>Required</sup> <a name="endpointName" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.property.endpointName"></a>
1292
+ ##### `metricEnvironmentThrottles` <a name="metricEnvironmentThrottles" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.metricEnvironmentThrottles"></a>
1017
1293
 
1018
1294
  ```typescript
1019
- public readonly endpointName: string;
1295
+ public metricEnvironmentThrottles(props?: MetricOptions): Metric
1020
1296
  ```
1021
1297
 
1022
- - *Type:* string
1298
+ Requests rejected with 429 because the endpoint reached `maxEnvironments` (`EndpointActiveEnvironmentThrottles`).
1023
1299
 
1024
- The endpoint's name.
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
1025
1303
 
1026
1304
  ---
1027
1305
 
1028
- ##### `endpointType`<sup>Required</sup> <a name="endpointType" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.property.endpointType"></a>
1306
+ ##### `metricRequests` <a name="metricRequests" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.metricRequests"></a>
1029
1307
 
1030
1308
  ```typescript
1031
- public readonly endpointType: WebFunctionEndpointType;
1309
+ public metricRequests(props?: MetricOptions): Metric
1032
1310
  ```
1033
1311
 
1034
- - *Type:* <a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpointType">WebFunctionEndpointType</a>
1312
+ Requests the endpoint served (`ExecutedRequests`).
1035
1313
 
1036
- Where the endpoint serves traffic from.
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
1037
1319
 
1038
1320
  ---
1039
1321
 
1040
- ##### `regions`<sup>Required</sup> <a name="regions" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.property.regions"></a>
1322
+ ##### `metricRequestThrottles` <a name="metricRequestThrottles" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.metricRequestThrottles"></a>
1041
1323
 
1042
1324
  ```typescript
1043
- public readonly regions: string[];
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
+
1369
+ ##### `regionalUrl` <a name="regionalUrl" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.regionalUrl"></a>
1370
+
1371
+ ```typescript
1372
+ public regionalUrl(region: string): string
1373
+ ```
1374
+
1375
+ The URL of this endpoint in one region.
1376
+
1377
+ Only for `PER_REGION` endpoints.
1378
+
1379
+ ###### `region`<sup>Required</sup> <a name="region" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.regionalUrl.parameter.region"></a>
1380
+
1381
+ - *Type:* string
1382
+
1383
+ one of `regions`.
1384
+
1385
+ ---
1386
+
1387
+ ##### `routeTraffic` <a name="routeTraffic" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.routeTraffic"></a>
1388
+
1389
+ ```typescript
1390
+ public routeTraffic(revision: IWebFunctionRevision, additionalRevisions?: WebFunctionRevisionWeight[]): void
1391
+ ```
1392
+
1393
+ Routes the endpoint to `revision` instead of the function's current revision, optionally sharing traffic with one more revision (`additionalRevisions`, which gets its weight;
1394
+
1395
+ `revision` gets the rest).
1396
+
1397
+ Use it to keep an endpoint on an earlier revision (`WebFunctionRevision.fromRevisionAttributes`),
1398
+ or to send part of the traffic to the current revision:
1399
+ `fn.endpoint.routeTraffic(previous, [{ revision: fn.currentRevision, weight: 0.1 }])`.
1400
+ Can be called once per endpoint, and not on one created with `revision` or `additionalRevisions`.
1401
+
1402
+ ###### `revision`<sup>Required</sup> <a name="revision" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.routeTraffic.parameter.revision"></a>
1403
+
1404
+ - *Type:* <a href="#@ashishpandeyone/cdk-lambda-web-function.IWebFunctionRevision">IWebFunctionRevision</a>
1405
+
1406
+ ---
1407
+
1408
+ ###### `additionalRevisions`<sup>Optional</sup> <a name="additionalRevisions" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.routeTraffic.parameter.additionalRevisions"></a>
1409
+
1410
+ - *Type:* <a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionRevisionWeight">WebFunctionRevisionWeight</a>[]
1411
+
1412
+ ---
1413
+
1414
+ #### Static Functions <a name="Static Functions" id="Static Functions"></a>
1415
+
1416
+ | **Name** | **Description** |
1417
+ | --- | --- |
1418
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.isConstruct">isConstruct</a></code> | Checks if `x` is a construct. |
1419
+
1420
+ ---
1421
+
1422
+ ##### `isConstruct` <a name="isConstruct" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.isConstruct"></a>
1423
+
1424
+ ```typescript
1425
+ import { WebFunctionEndpoint } from '@ashishpandeyone/cdk-lambda-web-function'
1426
+
1427
+ WebFunctionEndpoint.isConstruct(x: any)
1428
+ ```
1429
+
1430
+ Checks if `x` is a construct.
1431
+
1432
+ Use this method instead of `instanceof` to properly detect `Construct`
1433
+ instances, even when the construct library is symlinked.
1434
+
1435
+ Explanation: in JavaScript, multiple copies of the `constructs` library on
1436
+ disk are seen as independent, completely different libraries. As a
1437
+ consequence, the class `Construct` in each copy of the `constructs` library
1438
+ is seen as a different class, and an instance of one class will not test as
1439
+ `instanceof` the other class. `npm install` will not create installations
1440
+ like this, but users may manually symlink construct libraries together or
1441
+ use a monorepo tool: in those cases, multiple copies of the `constructs`
1442
+ library can be accidentally installed, and `instanceof` will behave
1443
+ unpredictably. It is safest to avoid using `instanceof`, and using
1444
+ this type-testing method instead.
1445
+
1446
+ ###### `x`<sup>Required</sup> <a name="x" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.isConstruct.parameter.x"></a>
1447
+
1448
+ - *Type:* any
1449
+
1450
+ Any object.
1451
+
1452
+ ---
1453
+
1454
+ #### Properties <a name="Properties" id="Properties"></a>
1455
+
1456
+ | **Name** | **Type** | **Description** |
1457
+ | --- | --- | --- |
1458
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.property.node">node</a></code> | <code>constructs.Node</code> | The tree node. |
1459
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.property.authType">authType</a></code> | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionAuthType">WebFunctionAuthType</a></code> | How callers of the endpoint are authenticated. |
1460
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.property.domainName">domainName</a></code> | <code>string</code> | The endpoint's domain name: the global domain for `MULTI_REGION`, otherwise the home region's. |
1461
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.property.endpointArn">endpointArn</a></code> | <code>string</code> | The endpoint's ARN. |
1462
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.property.endpointName">endpointName</a></code> | <code>string</code> | The endpoint's name. |
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. |
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)`). |
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). |
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. |
1468
+
1469
+ ---
1470
+
1471
+ ##### `node`<sup>Required</sup> <a name="node" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.property.node"></a>
1472
+
1473
+ ```typescript
1474
+ public readonly node: Node;
1475
+ ```
1476
+
1477
+ - *Type:* constructs.Node
1478
+
1479
+ The tree node.
1480
+
1481
+ ---
1482
+
1483
+ ##### `authType`<sup>Required</sup> <a name="authType" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.property.authType"></a>
1484
+
1485
+ ```typescript
1486
+ public readonly authType: WebFunctionAuthType;
1487
+ ```
1488
+
1489
+ - *Type:* <a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionAuthType">WebFunctionAuthType</a>
1490
+
1491
+ How callers of the endpoint are authenticated.
1492
+
1493
+ ---
1494
+
1495
+ ##### `domainName`<sup>Required</sup> <a name="domainName" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.property.domainName"></a>
1496
+
1497
+ ```typescript
1498
+ public readonly domainName: string;
1499
+ ```
1500
+
1501
+ - *Type:* string
1502
+
1503
+ The endpoint's domain name: the global domain for `MULTI_REGION`, otherwise the home region's.
1504
+
1505
+ ---
1506
+
1507
+ ##### `endpointArn`<sup>Required</sup> <a name="endpointArn" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.property.endpointArn"></a>
1508
+
1509
+ ```typescript
1510
+ public readonly endpointArn: string;
1511
+ ```
1512
+
1513
+ - *Type:* string
1514
+
1515
+ The endpoint's ARN.
1516
+
1517
+ ---
1518
+
1519
+ ##### `endpointName`<sup>Required</sup> <a name="endpointName" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.property.endpointName"></a>
1520
+
1521
+ ```typescript
1522
+ public readonly endpointName: string;
1523
+ ```
1524
+
1525
+ - *Type:* string
1526
+
1527
+ The endpoint's name.
1528
+
1529
+ ---
1530
+
1531
+ ##### `endpointType`<sup>Required</sup> <a name="endpointType" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.property.endpointType"></a>
1532
+
1533
+ ```typescript
1534
+ public readonly endpointType: WebFunctionEndpointType;
1535
+ ```
1536
+
1537
+ - *Type:* <a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpointType">WebFunctionEndpointType</a>
1538
+
1539
+ Where the endpoint serves traffic from.
1540
+
1541
+ ---
1542
+
1543
+ ##### `grants`<sup>Required</sup> <a name="grants" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.property.grants"></a>
1544
+
1545
+ ```typescript
1546
+ public readonly grants: WebFunctionGrants;
1547
+ ```
1548
+
1549
+ - *Type:* <a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionGrants">WebFunctionGrants</a>
1550
+
1551
+ Grants on this endpoint (e.g. `grants.invoke(principal)`).
1552
+
1553
+ ---
1554
+
1555
+ ##### `regions`<sup>Required</sup> <a name="regions" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.property.regions"></a>
1556
+
1557
+ ```typescript
1558
+ public readonly regions: string[];
1044
1559
  ```
1045
1560
 
1046
1561
  - *Type:* string[]
1047
1562
 
1048
- Every region the endpoint serves from: the home region first, then the others in alphabetical order.
1563
+ Every region the endpoint serves from: the home region first, then the others in alphabetical order.
1564
+
1565
+ ---
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
+
1581
+ ##### `url`<sup>Required</sup> <a name="url" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.property.url"></a>
1582
+
1583
+ ```typescript
1584
+ public readonly url: string;
1585
+ ```
1586
+
1587
+ - *Type:* string
1588
+
1589
+ The endpoint's URL: the global URL for `MULTI_REGION`, otherwise the home region's.
1590
+
1591
+ ---
1592
+
1593
+
1594
+ ### WebFunctionRevision <a name="WebFunctionRevision" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionRevision"></a>
1595
+
1596
+ - *Implements:* <a href="#@ashishpandeyone/cdk-lambda-web-function.IWebFunctionRevision">IWebFunctionRevision</a>
1597
+
1598
+ A revision of a Web Function.
1599
+
1600
+ `WebFunction` creates its current revision (`fn.currentRevision`) from its code and configuration.
1601
+ Use `fromRevisionAttributes` to route an endpoint to an earlier one, which must still exist:
1602
+ only revisions within `revisionRetention`, or that an endpoint routes to, are kept.
1603
+
1604
+ #### Methods <a name="Methods" id="Methods"></a>
1605
+
1606
+ | **Name** | **Description** |
1607
+ | --- | --- |
1608
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionRevision.toString">toString</a></code> | Returns a string representation of this construct. |
1609
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionRevision.with">with</a></code> | Applies one or more mixins to this construct. |
1610
+
1611
+ ---
1612
+
1613
+ ##### `toString` <a name="toString" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionRevision.toString"></a>
1614
+
1615
+ ```typescript
1616
+ public toString(): string
1617
+ ```
1618
+
1619
+ Returns a string representation of this construct.
1620
+
1621
+ ##### `with` <a name="with" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionRevision.with"></a>
1622
+
1623
+ ```typescript
1624
+ public with(mixins: ...IMixin[]): IConstruct
1625
+ ```
1626
+
1627
+ Applies one or more mixins to this construct.
1628
+
1629
+ Mixins are applied in order. The list of constructs is captured at the
1630
+ start of the call, so constructs added by a mixin will not be visited.
1631
+ Use multiple `with()` calls if subsequent mixins should apply to added
1632
+ constructs.
1633
+
1634
+ ###### `mixins`<sup>Required</sup> <a name="mixins" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionRevision.with.parameter.mixins"></a>
1635
+
1636
+ - *Type:* ...constructs.IMixin[]
1637
+
1638
+ The mixins to apply.
1639
+
1640
+ ---
1641
+
1642
+ #### Static Functions <a name="Static Functions" id="Static Functions"></a>
1643
+
1644
+ | **Name** | **Description** |
1645
+ | --- | --- |
1646
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionRevision.isConstruct">isConstruct</a></code> | Checks if `x` is a construct. |
1647
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionRevision.fromRevisionAttributes">fromRevisionAttributes</a></code> | References an existing revision of `webFunction`, e.g. to pin an endpoint to it or split traffic with it. |
1648
+
1649
+ ---
1650
+
1651
+ ##### `isConstruct` <a name="isConstruct" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionRevision.isConstruct"></a>
1652
+
1653
+ ```typescript
1654
+ import { WebFunctionRevision } from '@ashishpandeyone/cdk-lambda-web-function'
1655
+
1656
+ WebFunctionRevision.isConstruct(x: any)
1657
+ ```
1658
+
1659
+ Checks if `x` is a construct.
1660
+
1661
+ Use this method instead of `instanceof` to properly detect `Construct`
1662
+ instances, even when the construct library is symlinked.
1663
+
1664
+ Explanation: in JavaScript, multiple copies of the `constructs` library on
1665
+ disk are seen as independent, completely different libraries. As a
1666
+ consequence, the class `Construct` in each copy of the `constructs` library
1667
+ is seen as a different class, and an instance of one class will not test as
1668
+ `instanceof` the other class. `npm install` will not create installations
1669
+ like this, but users may manually symlink construct libraries together or
1670
+ use a monorepo tool: in those cases, multiple copies of the `constructs`
1671
+ library can be accidentally installed, and `instanceof` will behave
1672
+ unpredictably. It is safest to avoid using `instanceof`, and using
1673
+ this type-testing method instead.
1674
+
1675
+ ###### `x`<sup>Required</sup> <a name="x" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionRevision.isConstruct.parameter.x"></a>
1676
+
1677
+ - *Type:* any
1678
+
1679
+ Any object.
1680
+
1681
+ ---
1682
+
1683
+ ##### `fromRevisionAttributes` <a name="fromRevisionAttributes" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionRevision.fromRevisionAttributes"></a>
1684
+
1685
+ ```typescript
1686
+ import { WebFunctionRevision } from '@ashishpandeyone/cdk-lambda-web-function'
1687
+
1688
+ WebFunctionRevision.fromRevisionAttributes(scope: Construct, id: string, attrs: WebFunctionRevisionAttributes)
1689
+ ```
1690
+
1691
+ References an existing revision of `webFunction`, e.g. to pin an endpoint to it or split traffic with it.
1692
+
1693
+ ###### `scope`<sup>Required</sup> <a name="scope" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionRevision.fromRevisionAttributes.parameter.scope"></a>
1694
+
1695
+ - *Type:* constructs.Construct
1696
+
1697
+ ---
1698
+
1699
+ ###### `id`<sup>Required</sup> <a name="id" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionRevision.fromRevisionAttributes.parameter.id"></a>
1700
+
1701
+ - *Type:* string
1702
+
1703
+ ---
1704
+
1705
+ ###### `attrs`<sup>Required</sup> <a name="attrs" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionRevision.fromRevisionAttributes.parameter.attrs"></a>
1706
+
1707
+ - *Type:* <a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionRevisionAttributes">WebFunctionRevisionAttributes</a>
1708
+
1709
+ ---
1710
+
1711
+ #### Properties <a name="Properties" id="Properties"></a>
1712
+
1713
+ | **Name** | **Type** | **Description** |
1714
+ | --- | --- | --- |
1715
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionRevision.property.node">node</a></code> | <code>constructs.Node</code> | The tree node. |
1716
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionRevision.property.revisionArn">revisionArn</a></code> | <code>string</code> | The revision's ARN. |
1717
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionRevision.property.revisionId">revisionId</a></code> | <code>string</code> | The revision's ID, e.g. `rev-a1b2c`. |
1718
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionRevision.property.webFunction">webFunction</a></code> | <code>aws-cdk-lib.interfaces.aws_lambda.IWebFunctionRef</code> | The function the revision belongs to. |
1719
+
1720
+ ---
1721
+
1722
+ ##### `node`<sup>Required</sup> <a name="node" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionRevision.property.node"></a>
1723
+
1724
+ ```typescript
1725
+ public readonly node: Node;
1726
+ ```
1727
+
1728
+ - *Type:* constructs.Node
1729
+
1730
+ The tree node.
1731
+
1732
+ ---
1733
+
1734
+ ##### `revisionArn`<sup>Required</sup> <a name="revisionArn" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionRevision.property.revisionArn"></a>
1735
+
1736
+ ```typescript
1737
+ public readonly revisionArn: string;
1738
+ ```
1739
+
1740
+ - *Type:* string
1741
+
1742
+ The revision's ARN.
1743
+
1744
+ ---
1745
+
1746
+ ##### `revisionId`<sup>Required</sup> <a name="revisionId" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionRevision.property.revisionId"></a>
1747
+
1748
+ ```typescript
1749
+ public readonly revisionId: string;
1750
+ ```
1751
+
1752
+ - *Type:* string
1753
+
1754
+ The revision's ID, e.g. `rev-a1b2c`.
1755
+
1756
+ ---
1757
+
1758
+ ##### `webFunction`<sup>Required</sup> <a name="webFunction" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionRevision.property.webFunction"></a>
1759
+
1760
+ ```typescript
1761
+ public readonly webFunction: IWebFunctionRef;
1762
+ ```
1763
+
1764
+ - *Type:* aws-cdk-lib.interfaces.aws_lambda.IWebFunctionRef
1765
+
1766
+ The function the revision belongs to.
1767
+
1768
+ ---
1769
+
1770
+
1771
+ ## Structs <a name="Structs" id="Structs"></a>
1772
+
1773
+ ### AddWebFunctionEndpointOptions <a name="AddWebFunctionEndpointOptions" id="@ashishpandeyone/cdk-lambda-web-function.AddWebFunctionEndpointOptions"></a>
1774
+
1775
+ Options for `WebFunction.addEndpoint`.
1776
+
1777
+ #### Initializer <a name="Initializer" id="@ashishpandeyone/cdk-lambda-web-function.AddWebFunctionEndpointOptions.Initializer"></a>
1778
+
1779
+ ```typescript
1780
+ import { AddWebFunctionEndpointOptions } from '@ashishpandeyone/cdk-lambda-web-function'
1781
+
1782
+ const addWebFunctionEndpointOptions: AddWebFunctionEndpointOptions = { ... }
1783
+ ```
1784
+
1785
+ #### Properties <a name="Properties" id="Properties"></a>
1786
+
1787
+ | **Name** | **Type** | **Description** |
1788
+ | --- | --- | --- |
1789
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.AddWebFunctionEndpointOptions.property.deployment">deployment</a></code> | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionDeployment">WebFunctionDeployment</a></code> | How the endpoint moves its traffic to a new revision: all at once, or in steps (`WebFunctionDeployment.canary()` or `linear()`) that watch CloudWatch alarms and move the traffic back when one goes into ALARM. |
1790
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.AddWebFunctionEndpointOptions.property.description">description</a></code> | <code>string</code> | A description of the endpoint. |
1791
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.AddWebFunctionEndpointOptions.property.endpointName">endpointName</a></code> | <code>string</code> | The endpoint's name, shown in logs (`endpointName`) and in the `lambda-web-endpoint-name` header. Names are unique per function. |
1792
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.AddWebFunctionEndpointOptions.property.endpointType">endpointType</a></code> | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpointType">WebFunctionEndpointType</a></code> | Where the endpoint serves traffic from. |
1793
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.AddWebFunctionEndpointOptions.property.maxEnvironments">maxEnvironments</a></code> | <code>number</code> | The most execution environments the endpoint may use (2–10,000). Each one uses 2 vCPUs of the account's quota. |
1794
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.AddWebFunctionEndpointOptions.property.rateLimit">rateLimit</a></code> | <code>number</code> | The most requests per second the endpoint accepts; |
1795
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.AddWebFunctionEndpointOptions.property.regions">regions</a></code> | <code>string[]</code> | Regions to serve from in addition to the home region (the stack's region). |
1796
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.AddWebFunctionEndpointOptions.property.authType">authType</a></code> | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionAuthType">WebFunctionAuthType</a></code> | How callers of this endpoint are authenticated. |
1797
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.AddWebFunctionEndpointOptions.property.additionalRevisions">additionalRevisions</a></code> | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionRevisionWeight">WebFunctionRevisionWeight</a>[]</code> | A second revision and its share of the endpoint's traffic; |
1798
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.AddWebFunctionEndpointOptions.property.revision">revision</a></code> | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.IWebFunctionRevision">IWebFunctionRevision</a></code> | The revision the endpoint serves, e.g. an earlier one from `WebFunctionRevision.fromRevisionAttributes` to keep this endpoint on it while others move on. Same as calling `routeTraffic`. |
1799
+
1800
+ ---
1801
+
1802
+ ##### `deployment`<sup>Optional</sup> <a name="deployment" id="@ashishpandeyone/cdk-lambda-web-function.AddWebFunctionEndpointOptions.property.deployment"></a>
1803
+
1804
+ ```typescript
1805
+ public readonly deployment: WebFunctionDeployment;
1806
+ ```
1807
+
1808
+ - *Type:* <a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionDeployment">WebFunctionDeployment</a>
1809
+ - *Default:* WebFunctionDeployment.allAtOnce()
1810
+
1811
+ How the endpoint moves its traffic to a new revision: all at once, or in steps (`WebFunctionDeployment.canary()` or `linear()`) that watch CloudWatch alarms and move the traffic back when one goes into ALARM.
1812
+
1813
+ A deployment in steps can't be combined with `revision`, `additionalRevisions` or `routeTraffic()`.
1814
+
1815
+ ---
1816
+
1817
+ ##### `description`<sup>Optional</sup> <a name="description" id="@ashishpandeyone/cdk-lambda-web-function.AddWebFunctionEndpointOptions.property.description"></a>
1818
+
1819
+ ```typescript
1820
+ public readonly description: string;
1821
+ ```
1822
+
1823
+ - *Type:* string
1824
+ - *Default:* no description
1825
+
1826
+ A description of the endpoint.
1049
1827
 
1050
1828
  ---
1051
1829
 
1052
- ##### `url`<sup>Required</sup> <a name="url" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint.property.url"></a>
1830
+ ##### `endpointName`<sup>Optional</sup> <a name="endpointName" id="@ashishpandeyone/cdk-lambda-web-function.AddWebFunctionEndpointOptions.property.endpointName"></a>
1053
1831
 
1054
1832
  ```typescript
1055
- public readonly url: string;
1833
+ public readonly endpointName: string;
1056
1834
  ```
1057
1835
 
1058
1836
  - *Type:* string
1837
+ - *Default:* `default-<hash>` for the function's default endpoint, `<id>-<hash>` for endpoints added with `addEndpoint`
1059
1838
 
1060
- The endpoint's URL: the global URL for `MULTI_REGION`, otherwise the home region's.
1839
+ The endpoint's name, shown in logs (`endpointName`) and in the `lambda-web-endpoint-name` header. Names are unique per function.
1840
+
1841
+ When omitted, the name ends in a hash of the endpoint type and regions, so changing either deploys
1842
+ a new endpoint cleanly. When set, changing the endpoint type or regions also requires a new name:
1843
+ two endpoints of one function can't share a name, and CloudFormation creates the replacement
1844
+ before deleting the old one.
1061
1845
 
1062
1846
  ---
1063
1847
 
1848
+ ##### `endpointType`<sup>Optional</sup> <a name="endpointType" id="@ashishpandeyone/cdk-lambda-web-function.AddWebFunctionEndpointOptions.property.endpointType"></a>
1064
1849
 
1065
- ## Structs <a name="Structs" id="Structs"></a>
1850
+ ```typescript
1851
+ public readonly endpointType: WebFunctionEndpointType;
1852
+ ```
1853
+
1854
+ - *Type:* <a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpointType">WebFunctionEndpointType</a>
1855
+ - *Default:* WebFunctionEndpointType.HOME_REGION
1856
+
1857
+ Where the endpoint serves traffic from.
1858
+
1859
+ ---
1860
+
1861
+ ##### `maxEnvironments`<sup>Optional</sup> <a name="maxEnvironments" id="@ashishpandeyone/cdk-lambda-web-function.AddWebFunctionEndpointOptions.property.maxEnvironments"></a>
1862
+
1863
+ ```typescript
1864
+ public readonly maxEnvironments: number;
1865
+ ```
1866
+
1867
+ - *Type:* number
1868
+ - *Default:* scales within the account's vCPU quota
1869
+
1870
+ The most execution environments the endpoint may use (2–10,000). Each one uses 2 vCPUs of the account's quota.
1871
+
1872
+ Enforced separately in each region the endpoint serves from.
1873
+
1874
+ ---
1875
+
1876
+ ##### `rateLimit`<sup>Optional</sup> <a name="rateLimit" id="@ashishpandeyone/cdk-lambda-web-function.AddWebFunctionEndpointOptions.property.rateLimit"></a>
1877
+
1878
+ ```typescript
1879
+ public readonly rateLimit: number;
1880
+ ```
1881
+
1882
+ - *Type:* number
1883
+ - *Default:* no limit beyond the service quota of 10,000 requests per second per endpoint (per region)
1884
+
1885
+ The most requests per second the endpoint accepts;
1886
+
1887
+ excess requests get HTTP 429.
1888
+ Allowed: 0 (blocks all traffic), 100–1,000 in steps of 100, or 2,000–10,000 in steps of 1,000.
1889
+
1890
+ Enforced separately in each region the endpoint serves from, so a multi-region endpoint
1891
+ can accept this many requests per second in every region.
1892
+
1893
+ ---
1894
+
1895
+ ##### `regions`<sup>Optional</sup> <a name="regions" id="@ashishpandeyone/cdk-lambda-web-function.AddWebFunctionEndpointOptions.property.regions"></a>
1896
+
1897
+ ```typescript
1898
+ public readonly regions: string[];
1899
+ ```
1900
+
1901
+ - *Type:* string[]
1902
+ - *Default:* no extra regions
1903
+
1904
+ Regions to serve from in addition to the home region (the stack's region).
1905
+
1906
+ Required (at least one) for `MULTI_REGION` and `PER_REGION`; must be empty for `HOME_REGION`.
1907
+
1908
+ Changing this creates a new endpoint with a new URL.
1909
+
1910
+ ---
1911
+
1912
+ ##### `authType`<sup>Required</sup> <a name="authType" id="@ashishpandeyone/cdk-lambda-web-function.AddWebFunctionEndpointOptions.property.authType"></a>
1913
+
1914
+ ```typescript
1915
+ public readonly authType: WebFunctionAuthType;
1916
+ ```
1917
+
1918
+ - *Type:* <a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionAuthType">WebFunctionAuthType</a>
1919
+
1920
+ How callers of this endpoint are authenticated.
1921
+
1922
+ ---
1923
+
1924
+ ##### `additionalRevisions`<sup>Optional</sup> <a name="additionalRevisions" id="@ashishpandeyone/cdk-lambda-web-function.AddWebFunctionEndpointOptions.property.additionalRevisions"></a>
1925
+
1926
+ ```typescript
1927
+ public readonly additionalRevisions: WebFunctionRevisionWeight[];
1928
+ ```
1929
+
1930
+ - *Type:* <a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionRevisionWeight">WebFunctionRevisionWeight</a>[]
1931
+ - *Default:* all traffic goes to `revision`
1932
+
1933
+ A second revision and its share of the endpoint's traffic;
1934
+
1935
+ `revision` gets the rest.
1936
+ An endpoint routes to at most two revisions.
1937
+
1938
+ ---
1939
+
1940
+ ##### `revision`<sup>Optional</sup> <a name="revision" id="@ashishpandeyone/cdk-lambda-web-function.AddWebFunctionEndpointOptions.property.revision"></a>
1941
+
1942
+ ```typescript
1943
+ public readonly revision: IWebFunctionRevision;
1944
+ ```
1945
+
1946
+ - *Type:* <a href="#@ashishpandeyone/cdk-lambda-web-function.IWebFunctionRevision">IWebFunctionRevision</a>
1947
+ - *Default:* the function's current revision (`currentRevision`)
1948
+
1949
+ The revision the endpoint serves, e.g. an earlier one from `WebFunctionRevision.fromRevisionAttributes` to keep this endpoint on it while others move on. Same as calling `routeTraffic`.
1950
+
1951
+ ---
1066
1952
 
1067
1953
  ### NodejsWebFunctionBundlingOptions <a name="NodejsWebFunctionBundlingOptions" id="@ashishpandeyone/cdk-lambda-web-function.NodejsWebFunctionBundlingOptions"></a>
1068
1954
 
@@ -1318,11 +2204,12 @@ const nodejsWebFunctionProps: NodejsWebFunctionProps = { ... }
1318
2204
  | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.NodejsWebFunctionProps.property.authType">authType</a></code> | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionAuthType">WebFunctionAuthType</a></code> | How callers of the endpoint are authenticated. |
1319
2205
  | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.NodejsWebFunctionProps.property.applicationLogLevelV2">applicationLogLevelV2</a></code> | <code>aws-cdk-lib.aws_lambda.ApplicationLogLevel</code> | The minimum level of application logs to keep. |
1320
2206
  | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.NodejsWebFunctionProps.property.description">description</a></code> | <code>string</code> | A description of the function's code and configuration. |
1321
- | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.NodejsWebFunctionProps.property.endpoint">endpoint</a></code> | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpointOptions">WebFunctionEndpointOptions</a></code> | The endpoint: where it serves from, and its name. |
2207
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.NodejsWebFunctionProps.property.endpoint">endpoint</a></code> | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpointOptions">WebFunctionEndpointOptions</a></code> | The default endpoint (`fn.endpoint`): where it serves from, its name and limits. It serves the current revision; route it elsewhere with `fn.endpoint.routeTraffic()`. Add more endpoints with `addEndpoint`. |
1322
2208
  | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.NodejsWebFunctionProps.property.environment">environment</a></code> | <code>{[ key: string ]: string}</code> | Environment variables. |
1323
2209
  | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.NodejsWebFunctionProps.property.logRemovalPolicy">logRemovalPolicy</a></code> | <code>aws-cdk-lib.RemovalPolicy</code> | What happens to the log groups when the function is removed: RETAIN or DESTROY. |
1324
2210
  | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.NodejsWebFunctionProps.property.logRetention">logRetention</a></code> | <code>aws-cdk-lib.aws_logs.RetentionDays</code> | Retention for every log group of the function, in every region it serves from. |
1325
2211
  | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.NodejsWebFunctionProps.property.maxConcurrencyPerEnvironment">maxConcurrencyPerEnvironment</a></code> | <code>number</code> | How many requests one execution environment handles at the same time (1-128). |
2212
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.NodejsWebFunctionProps.property.revisionRetention">revisionRetention</a></code> | <code>number</code> | How many of the newest revisions to keep (1-50). |
1326
2213
  | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.NodejsWebFunctionProps.property.role">role</a></code> | <code>aws-cdk-lib.aws_iam.IRole</code> | The execution role. |
1327
2214
  | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.NodejsWebFunctionProps.property.systemLogLevelV2">systemLogLevelV2</a></code> | <code>aws-cdk-lib.aws_lambda.SystemLogLevel</code> | The minimum level of platform logs to keep (DEBUG, INFO or WARN). |
1328
2215
  | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.NodejsWebFunctionProps.property.timeout">timeout</a></code> | <code>aws-cdk-lib.Duration</code> | How long a single request may run. |
@@ -1380,9 +2267,9 @@ public readonly endpoint: WebFunctionEndpointOptions;
1380
2267
  ```
1381
2268
 
1382
2269
  - *Type:* <a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpointOptions">WebFunctionEndpointOptions</a>
1383
- - *Default:* a HOME_REGION endpoint
2270
+ - *Default:* a HOME_REGION endpoint serving the current revision
1384
2271
 
1385
- The endpoint: where it serves from, and its name.
2272
+ The default endpoint (`fn.endpoint`): where it serves from, its name and limits. It serves the current revision; route it elsewhere with `fn.endpoint.routeTraffic()`. Add more endpoints with `addEndpoint`.
1386
2273
 
1387
2274
  ---
1388
2275
 
@@ -1444,6 +2331,26 @@ Requests share module-level state, so handlers must be concurrency-safe.
1444
2331
 
1445
2332
  ---
1446
2333
 
2334
+ ##### `revisionRetention`<sup>Optional</sup> <a name="revisionRetention" id="@ashishpandeyone/cdk-lambda-web-function.NodejsWebFunctionProps.property.revisionRetention"></a>
2335
+
2336
+ ```typescript
2337
+ public readonly revisionRetention: number;
2338
+ ```
2339
+
2340
+ - *Type:* number
2341
+ - *Default:* 20
2342
+
2343
+ How many of the newest revisions to keep (1-50).
2344
+
2345
+ Each deployment that changes the code or
2346
+ configuration creates a revision; older ones stay available to roll back to or route traffic to,
2347
+ and the oldest beyond this count are deleted after each deployment.
2348
+
2349
+ Revisions that an endpoint routes to are never deleted, and neither are those the previous
2350
+ deployment used (a rollback returns to them).
2351
+
2352
+ ---
2353
+
1447
2354
  ##### `role`<sup>Optional</sup> <a name="role" id="@ashishpandeyone/cdk-lambda-web-function.NodejsWebFunctionProps.property.role"></a>
1448
2355
 
1449
2356
  ```typescript
@@ -1569,6 +2476,86 @@ The Node.js runtime.
1569
2476
 
1570
2477
  ---
1571
2478
 
2479
+ ### WebFunctionCanaryDeploymentOptions <a name="WebFunctionCanaryDeploymentOptions" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionCanaryDeploymentOptions"></a>
2480
+
2481
+ Options for a canary deployment.
2482
+
2483
+ #### Initializer <a name="Initializer" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionCanaryDeploymentOptions.Initializer"></a>
2484
+
2485
+ ```typescript
2486
+ import { WebFunctionCanaryDeploymentOptions } from '@ashishpandeyone/cdk-lambda-web-function'
2487
+
2488
+ const webFunctionCanaryDeploymentOptions: WebFunctionCanaryDeploymentOptions = { ... }
2489
+ ```
2490
+
2491
+ #### Properties <a name="Properties" id="Properties"></a>
2492
+
2493
+ | **Name** | **Type** | **Description** |
2494
+ | --- | --- | --- |
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). |
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. |
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. |
2499
+
2500
+ ---
2501
+
2502
+ ##### `bake`<sup>Required</sup> <a name="bake" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionCanaryDeploymentOptions.property.bake"></a>
2503
+
2504
+ ```typescript
2505
+ public readonly bake: Duration;
2506
+ ```
2507
+
2508
+ - *Type:* aws-cdk-lib.Duration
2509
+
2510
+ How long the new revision serves `percent` before it gets all traffic (1-45 minutes).
2511
+
2512
+ Make it longer than the time your alarms need to fire (period × evaluation periods).
2513
+
2514
+ ---
2515
+
2516
+ ##### `percent`<sup>Required</sup> <a name="percent" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionCanaryDeploymentOptions.property.percent"></a>
2517
+
2518
+ ```typescript
2519
+ public readonly percent: number;
2520
+ ```
2521
+
2522
+ - *Type:* number
2523
+
2524
+ The share of traffic, in whole percent (1-99), that the new revision gets first.
2525
+
2526
+ ---
2527
+
2528
+ ##### `alarms`<sup>Optional</sup> <a name="alarms" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionCanaryDeploymentOptions.property.alarms"></a>
2529
+
2530
+ ```typescript
2531
+ public readonly alarms: IAlarm[];
2532
+ ```
2533
+
2534
+ - *Type:* aws-cdk-lib.aws_cloudwatch.IAlarm[]
2535
+ - *Default:* no alarms: traffic moves on a timer
2536
+
2537
+ 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.
2538
+
2539
+ They're checked before traffic moves, during the bake, and once the new revision has all traffic.
2540
+ Use alarms in any region (by ARN), including composite alarms.
2541
+
2542
+ ---
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
+
1572
2559
  ### WebFunctionEndpointOptions <a name="WebFunctionEndpointOptions" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpointOptions"></a>
1573
2560
 
1574
2561
  Options for a Web Function's endpoint.
@@ -1585,57 +2572,201 @@ const webFunctionEndpointOptions: WebFunctionEndpointOptions = { ... }
1585
2572
 
1586
2573
  | **Name** | **Type** | **Description** |
1587
2574
  | --- | --- | --- |
1588
- | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpointOptions.property.endpointName">endpointName</a></code> | <code>string</code> | The endpoint's name, shown in logs (`endpointName`) and in the `lambda-web-endpoint-name` header. |
2575
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpointOptions.property.deployment">deployment</a></code> | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionDeployment">WebFunctionDeployment</a></code> | How the endpoint moves its traffic to a new revision: all at once, or in steps (`WebFunctionDeployment.canary()` or `linear()`) that watch CloudWatch alarms and move the traffic back when one goes into ALARM. |
2576
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpointOptions.property.description">description</a></code> | <code>string</code> | A description of the endpoint. |
2577
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpointOptions.property.endpointName">endpointName</a></code> | <code>string</code> | The endpoint's name, shown in logs (`endpointName`) and in the `lambda-web-endpoint-name` header. Names are unique per function. |
1589
2578
  | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpointOptions.property.endpointType">endpointType</a></code> | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpointType">WebFunctionEndpointType</a></code> | Where the endpoint serves traffic from. |
2579
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpointOptions.property.maxEnvironments">maxEnvironments</a></code> | <code>number</code> | The most execution environments the endpoint may use (2–10,000). Each one uses 2 vCPUs of the account's quota. |
2580
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpointOptions.property.rateLimit">rateLimit</a></code> | <code>number</code> | The most requests per second the endpoint accepts; |
1590
2581
  | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpointOptions.property.regions">regions</a></code> | <code>string[]</code> | Regions to serve from in addition to the home region (the stack's region). |
1591
2582
 
1592
2583
  ---
1593
2584
 
1594
- ##### `endpointName`<sup>Optional</sup> <a name="endpointName" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpointOptions.property.endpointName"></a>
2585
+ ##### `deployment`<sup>Optional</sup> <a name="deployment" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpointOptions.property.deployment"></a>
2586
+
2587
+ ```typescript
2588
+ public readonly deployment: WebFunctionDeployment;
2589
+ ```
2590
+
2591
+ - *Type:* <a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionDeployment">WebFunctionDeployment</a>
2592
+ - *Default:* WebFunctionDeployment.allAtOnce()
2593
+
2594
+ How the endpoint moves its traffic to a new revision: all at once, or in steps (`WebFunctionDeployment.canary()` or `linear()`) that watch CloudWatch alarms and move the traffic back when one goes into ALARM.
2595
+
2596
+ A deployment in steps can't be combined with `revision`, `additionalRevisions` or `routeTraffic()`.
2597
+
2598
+ ---
2599
+
2600
+ ##### `description`<sup>Optional</sup> <a name="description" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpointOptions.property.description"></a>
2601
+
2602
+ ```typescript
2603
+ public readonly description: string;
2604
+ ```
2605
+
2606
+ - *Type:* string
2607
+ - *Default:* no description
2608
+
2609
+ A description of the endpoint.
2610
+
2611
+ ---
2612
+
2613
+ ##### `endpointName`<sup>Optional</sup> <a name="endpointName" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpointOptions.property.endpointName"></a>
2614
+
2615
+ ```typescript
2616
+ public readonly endpointName: string;
2617
+ ```
2618
+
2619
+ - *Type:* string
2620
+ - *Default:* `default-<hash>` for the function's default endpoint, `<id>-<hash>` for endpoints added with `addEndpoint`
2621
+
2622
+ The endpoint's name, shown in logs (`endpointName`) and in the `lambda-web-endpoint-name` header. Names are unique per function.
2623
+
2624
+ When omitted, the name ends in a hash of the endpoint type and regions, so changing either deploys
2625
+ a new endpoint cleanly. When set, changing the endpoint type or regions also requires a new name:
2626
+ two endpoints of one function can't share a name, and CloudFormation creates the replacement
2627
+ before deleting the old one.
2628
+
2629
+ ---
2630
+
2631
+ ##### `endpointType`<sup>Optional</sup> <a name="endpointType" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpointOptions.property.endpointType"></a>
2632
+
2633
+ ```typescript
2634
+ public readonly endpointType: WebFunctionEndpointType;
2635
+ ```
2636
+
2637
+ - *Type:* <a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpointType">WebFunctionEndpointType</a>
2638
+ - *Default:* WebFunctionEndpointType.HOME_REGION
2639
+
2640
+ Where the endpoint serves traffic from.
2641
+
2642
+ ---
2643
+
2644
+ ##### `maxEnvironments`<sup>Optional</sup> <a name="maxEnvironments" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpointOptions.property.maxEnvironments"></a>
2645
+
2646
+ ```typescript
2647
+ public readonly maxEnvironments: number;
2648
+ ```
2649
+
2650
+ - *Type:* number
2651
+ - *Default:* scales within the account's vCPU quota
2652
+
2653
+ The most execution environments the endpoint may use (2–10,000). Each one uses 2 vCPUs of the account's quota.
2654
+
2655
+ Enforced separately in each region the endpoint serves from.
2656
+
2657
+ ---
2658
+
2659
+ ##### `rateLimit`<sup>Optional</sup> <a name="rateLimit" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpointOptions.property.rateLimit"></a>
2660
+
2661
+ ```typescript
2662
+ public readonly rateLimit: number;
2663
+ ```
2664
+
2665
+ - *Type:* number
2666
+ - *Default:* no limit beyond the service quota of 10,000 requests per second per endpoint (per region)
2667
+
2668
+ The most requests per second the endpoint accepts;
2669
+
2670
+ excess requests get HTTP 429.
2671
+ Allowed: 0 (blocks all traffic), 100–1,000 in steps of 100, or 2,000–10,000 in steps of 1,000.
2672
+
2673
+ Enforced separately in each region the endpoint serves from, so a multi-region endpoint
2674
+ can accept this many requests per second in every region.
2675
+
2676
+ ---
2677
+
2678
+ ##### `regions`<sup>Optional</sup> <a name="regions" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpointOptions.property.regions"></a>
2679
+
2680
+ ```typescript
2681
+ public readonly regions: string[];
2682
+ ```
2683
+
2684
+ - *Type:* string[]
2685
+ - *Default:* no extra regions
2686
+
2687
+ Regions to serve from in addition to the home region (the stack's region).
2688
+
2689
+ Required (at least one) for `MULTI_REGION` and `PER_REGION`; must be empty for `HOME_REGION`.
2690
+
2691
+ Changing this creates a new endpoint with a new URL.
2692
+
2693
+ ---
2694
+
2695
+ ### WebFunctionLinearDeploymentOptions <a name="WebFunctionLinearDeploymentOptions" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionLinearDeploymentOptions"></a>
2696
+
2697
+ Options for a linear deployment.
2698
+
2699
+ #### Initializer <a name="Initializer" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionLinearDeploymentOptions.Initializer"></a>
2700
+
2701
+ ```typescript
2702
+ import { WebFunctionLinearDeploymentOptions } from '@ashishpandeyone/cdk-lambda-web-function'
2703
+
2704
+ const webFunctionLinearDeploymentOptions: WebFunctionLinearDeploymentOptions = { ... }
2705
+ ```
2706
+
2707
+ #### Properties <a name="Properties" id="Properties"></a>
2708
+
2709
+ | **Name** | **Type** | **Description** |
2710
+ | --- | --- | --- |
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). |
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. |
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. |
2715
+
2716
+ ---
2717
+
2718
+ ##### `interval`<sup>Required</sup> <a name="interval" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionLinearDeploymentOptions.property.interval"></a>
2719
+
2720
+ ```typescript
2721
+ public readonly interval: Duration;
2722
+ ```
2723
+
2724
+ - *Type:* aws-cdk-lib.Duration
2725
+
2726
+ How long each step serves before the next one (at least 1 minute, and at most 45 minutes in total).
2727
+
2728
+ ---
2729
+
2730
+ ##### `percent`<sup>Required</sup> <a name="percent" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionLinearDeploymentOptions.property.percent"></a>
1595
2731
 
1596
2732
  ```typescript
1597
- public readonly endpointName: string;
2733
+ public readonly percent: number;
1598
2734
  ```
1599
2735
 
1600
- - *Type:* string
1601
- - *Default:* `default-<hash of type and regions>`
1602
-
1603
- The endpoint's name, shown in logs (`endpointName`) and in the `lambda-web-endpoint-name` header.
2736
+ - *Type:* number
1604
2737
 
1605
- When omitted, the name is `default-<hash>`, with the hash covering the endpoint type and regions,
1606
- so changing either deploys a new endpoint cleanly. When set, changing the endpoint type or
1607
- regions also requires a new name: two endpoints of one function can't share a name, and
1608
- CloudFormation creates the replacement before deleting the old one.
2738
+ The share of traffic, in whole percent (5-50), that moves to the new revision at each step.
1609
2739
 
1610
2740
  ---
1611
2741
 
1612
- ##### `endpointType`<sup>Optional</sup> <a name="endpointType" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpointOptions.property.endpointType"></a>
2742
+ ##### `alarms`<sup>Optional</sup> <a name="alarms" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionLinearDeploymentOptions.property.alarms"></a>
1613
2743
 
1614
2744
  ```typescript
1615
- public readonly endpointType: WebFunctionEndpointType;
2745
+ public readonly alarms: IAlarm[];
1616
2746
  ```
1617
2747
 
1618
- - *Type:* <a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpointType">WebFunctionEndpointType</a>
1619
- - *Default:* WebFunctionEndpointType.HOME_REGION
2748
+ - *Type:* aws-cdk-lib.aws_cloudwatch.IAlarm[]
2749
+ - *Default:* no alarms: traffic moves on a timer
1620
2750
 
1621
- Where the endpoint serves traffic from.
2751
+ 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.
2752
+
2753
+ They're checked before traffic moves, during every step, and once the new revision has all traffic.
2754
+ Use alarms in any region (by ARN), including composite alarms.
1622
2755
 
1623
2756
  ---
1624
2757
 
1625
- ##### `regions`<sup>Optional</sup> <a name="regions" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpointOptions.property.regions"></a>
2758
+ ##### `rollbackOn`<sup>Optional</sup> <a name="rollbackOn" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionLinearDeploymentOptions.property.rollbackOn"></a>
1626
2759
 
1627
2760
  ```typescript
1628
- public readonly regions: string[];
2761
+ public readonly rollbackOn: WebFunctionRollbackOptions;
1629
2762
  ```
1630
2763
 
1631
- - *Type:* string[]
1632
- - *Default:* no extra regions
1633
-
1634
- Regions to serve from in addition to the home region (the stack's region).
2764
+ - *Type:* <a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionRollbackOptions">WebFunctionRollbackOptions</a>
2765
+ - *Default:* no endpoint alarms
1635
2766
 
1636
- Required (at least one) for `MULTI_REGION` and `PER_REGION`; must be empty for `HOME_REGION`.
2767
+ Alarms on the endpoint's own error rates, created by the endpoint in every region it serves from.
1637
2768
 
1638
- Changing this creates a new endpoint with a new URL.
2769
+ They stop the deployment like `alarms` (both can be used together).
1639
2770
 
1640
2771
  ---
1641
2772
 
@@ -1658,11 +2789,12 @@ const webFunctionOptions: WebFunctionOptions = { ... }
1658
2789
  | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionOptions.property.authType">authType</a></code> | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionAuthType">WebFunctionAuthType</a></code> | How callers of the endpoint are authenticated. |
1659
2790
  | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionOptions.property.applicationLogLevelV2">applicationLogLevelV2</a></code> | <code>aws-cdk-lib.aws_lambda.ApplicationLogLevel</code> | The minimum level of application logs to keep. |
1660
2791
  | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionOptions.property.description">description</a></code> | <code>string</code> | A description of the function's code and configuration. |
1661
- | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionOptions.property.endpoint">endpoint</a></code> | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpointOptions">WebFunctionEndpointOptions</a></code> | The endpoint: where it serves from, and its name. |
2792
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionOptions.property.endpoint">endpoint</a></code> | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpointOptions">WebFunctionEndpointOptions</a></code> | The default endpoint (`fn.endpoint`): where it serves from, its name and limits. It serves the current revision; route it elsewhere with `fn.endpoint.routeTraffic()`. Add more endpoints with `addEndpoint`. |
1662
2793
  | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionOptions.property.environment">environment</a></code> | <code>{[ key: string ]: string}</code> | Environment variables. |
1663
2794
  | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionOptions.property.logRemovalPolicy">logRemovalPolicy</a></code> | <code>aws-cdk-lib.RemovalPolicy</code> | What happens to the log groups when the function is removed: RETAIN or DESTROY. |
1664
2795
  | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionOptions.property.logRetention">logRetention</a></code> | <code>aws-cdk-lib.aws_logs.RetentionDays</code> | Retention for every log group of the function, in every region it serves from. |
1665
2796
  | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionOptions.property.maxConcurrencyPerEnvironment">maxConcurrencyPerEnvironment</a></code> | <code>number</code> | How many requests one execution environment handles at the same time (1-128). |
2797
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionOptions.property.revisionRetention">revisionRetention</a></code> | <code>number</code> | How many of the newest revisions to keep (1-50). |
1666
2798
  | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionOptions.property.role">role</a></code> | <code>aws-cdk-lib.aws_iam.IRole</code> | The execution role. |
1667
2799
  | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionOptions.property.systemLogLevelV2">systemLogLevelV2</a></code> | <code>aws-cdk-lib.aws_lambda.SystemLogLevel</code> | The minimum level of platform logs to keep (DEBUG, INFO or WARN). |
1668
2800
  | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionOptions.property.timeout">timeout</a></code> | <code>aws-cdk-lib.Duration</code> | How long a single request may run. |
@@ -1715,9 +2847,9 @@ public readonly endpoint: WebFunctionEndpointOptions;
1715
2847
  ```
1716
2848
 
1717
2849
  - *Type:* <a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpointOptions">WebFunctionEndpointOptions</a>
1718
- - *Default:* a HOME_REGION endpoint
2850
+ - *Default:* a HOME_REGION endpoint serving the current revision
1719
2851
 
1720
- The endpoint: where it serves from, and its name.
2852
+ The default endpoint (`fn.endpoint`): where it serves from, its name and limits. It serves the current revision; route it elsewhere with `fn.endpoint.routeTraffic()`. Add more endpoints with `addEndpoint`.
1721
2853
 
1722
2854
  ---
1723
2855
 
@@ -1779,6 +2911,26 @@ Requests share module-level state, so handlers must be concurrency-safe.
1779
2911
 
1780
2912
  ---
1781
2913
 
2914
+ ##### `revisionRetention`<sup>Optional</sup> <a name="revisionRetention" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionOptions.property.revisionRetention"></a>
2915
+
2916
+ ```typescript
2917
+ public readonly revisionRetention: number;
2918
+ ```
2919
+
2920
+ - *Type:* number
2921
+ - *Default:* 20
2922
+
2923
+ How many of the newest revisions to keep (1-50).
2924
+
2925
+ Each deployment that changes the code or
2926
+ configuration creates a revision; older ones stay available to roll back to or route traffic to,
2927
+ and the oldest beyond this count are deleted after each deployment.
2928
+
2929
+ Revisions that an endpoint routes to are never deleted, and neither are those the previous
2930
+ deployment used (a rollback returns to them).
2931
+
2932
+ ---
2933
+
1782
2934
  ##### `role`<sup>Optional</sup> <a name="role" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionOptions.property.role"></a>
1783
2935
 
1784
2936
  ```typescript
@@ -1855,11 +3007,12 @@ const webFunctionProps: WebFunctionProps = { ... }
1855
3007
  | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionProps.property.authType">authType</a></code> | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionAuthType">WebFunctionAuthType</a></code> | How callers of the endpoint are authenticated. |
1856
3008
  | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionProps.property.applicationLogLevelV2">applicationLogLevelV2</a></code> | <code>aws-cdk-lib.aws_lambda.ApplicationLogLevel</code> | The minimum level of application logs to keep. |
1857
3009
  | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionProps.property.description">description</a></code> | <code>string</code> | A description of the function's code and configuration. |
1858
- | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionProps.property.endpoint">endpoint</a></code> | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpointOptions">WebFunctionEndpointOptions</a></code> | The endpoint: where it serves from, and its name. |
3010
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionProps.property.endpoint">endpoint</a></code> | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpointOptions">WebFunctionEndpointOptions</a></code> | The default endpoint (`fn.endpoint`): where it serves from, its name and limits. It serves the current revision; route it elsewhere with `fn.endpoint.routeTraffic()`. Add more endpoints with `addEndpoint`. |
1859
3011
  | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionProps.property.environment">environment</a></code> | <code>{[ key: string ]: string}</code> | Environment variables. |
1860
3012
  | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionProps.property.logRemovalPolicy">logRemovalPolicy</a></code> | <code>aws-cdk-lib.RemovalPolicy</code> | What happens to the log groups when the function is removed: RETAIN or DESTROY. |
1861
3013
  | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionProps.property.logRetention">logRetention</a></code> | <code>aws-cdk-lib.aws_logs.RetentionDays</code> | Retention for every log group of the function, in every region it serves from. |
1862
3014
  | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionProps.property.maxConcurrencyPerEnvironment">maxConcurrencyPerEnvironment</a></code> | <code>number</code> | How many requests one execution environment handles at the same time (1-128). |
3015
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionProps.property.revisionRetention">revisionRetention</a></code> | <code>number</code> | How many of the newest revisions to keep (1-50). |
1863
3016
  | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionProps.property.role">role</a></code> | <code>aws-cdk-lib.aws_iam.IRole</code> | The execution role. |
1864
3017
  | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionProps.property.systemLogLevelV2">systemLogLevelV2</a></code> | <code>aws-cdk-lib.aws_lambda.SystemLogLevel</code> | The minimum level of platform logs to keep (DEBUG, INFO or WARN). |
1865
3018
  | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionProps.property.timeout">timeout</a></code> | <code>aws-cdk-lib.Duration</code> | How long a single request may run. |
@@ -1915,9 +3068,9 @@ public readonly endpoint: WebFunctionEndpointOptions;
1915
3068
  ```
1916
3069
 
1917
3070
  - *Type:* <a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpointOptions">WebFunctionEndpointOptions</a>
1918
- - *Default:* a HOME_REGION endpoint
3071
+ - *Default:* a HOME_REGION endpoint serving the current revision
1919
3072
 
1920
- The endpoint: where it serves from, and its name.
3073
+ The default endpoint (`fn.endpoint`): where it serves from, its name and limits. It serves the current revision; route it elsewhere with `fn.endpoint.routeTraffic()`. Add more endpoints with `addEndpoint`.
1921
3074
 
1922
3075
  ---
1923
3076
 
@@ -1979,6 +3132,26 @@ Requests share module-level state, so handlers must be concurrency-safe.
1979
3132
 
1980
3133
  ---
1981
3134
 
3135
+ ##### `revisionRetention`<sup>Optional</sup> <a name="revisionRetention" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionProps.property.revisionRetention"></a>
3136
+
3137
+ ```typescript
3138
+ public readonly revisionRetention: number;
3139
+ ```
3140
+
3141
+ - *Type:* number
3142
+ - *Default:* 20
3143
+
3144
+ How many of the newest revisions to keep (1-50).
3145
+
3146
+ Each deployment that changes the code or
3147
+ configuration creates a revision; older ones stay available to roll back to or route traffic to,
3148
+ and the oldest beyond this count are deleted after each deployment.
3149
+
3150
+ Revisions that an endpoint routes to are never deleted, and neither are those the previous
3151
+ deployment used (a rollback returns to them).
3152
+
3153
+ ---
3154
+
1982
3155
  ##### `role`<sup>Optional</sup> <a name="role" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionProps.property.role"></a>
1983
3156
 
1984
3157
  ```typescript
@@ -2075,19 +3248,266 @@ The file that starts your server, relative to the root of the code.
2075
3248
 
2076
3249
  ---
2077
3250
 
3251
+ ### WebFunctionRevisionAttributes <a name="WebFunctionRevisionAttributes" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionRevisionAttributes"></a>
3252
+
3253
+ Attributes of an existing revision.
3254
+
3255
+ #### Initializer <a name="Initializer" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionRevisionAttributes.Initializer"></a>
3256
+
3257
+ ```typescript
3258
+ import { WebFunctionRevisionAttributes } from '@ashishpandeyone/cdk-lambda-web-function'
3259
+
3260
+ const webFunctionRevisionAttributes: WebFunctionRevisionAttributes = { ... }
3261
+ ```
3262
+
3263
+ #### Properties <a name="Properties" id="Properties"></a>
3264
+
3265
+ | **Name** | **Type** | **Description** |
3266
+ | --- | --- | --- |
3267
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionRevisionAttributes.property.revisionId">revisionId</a></code> | <code>string</code> | The revision's ID, e.g. `rev-a1b2c` (the `revisionId` of an earlier deployment). |
3268
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionRevisionAttributes.property.webFunction">webFunction</a></code> | <code>aws-cdk-lib.interfaces.aws_lambda.IWebFunctionRef</code> | The function the revision belongs to. |
3269
+
3270
+ ---
3271
+
3272
+ ##### `revisionId`<sup>Required</sup> <a name="revisionId" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionRevisionAttributes.property.revisionId"></a>
3273
+
3274
+ ```typescript
3275
+ public readonly revisionId: string;
3276
+ ```
3277
+
3278
+ - *Type:* string
3279
+
3280
+ The revision's ID, e.g. `rev-a1b2c` (the `revisionId` of an earlier deployment).
3281
+
3282
+ ---
3283
+
3284
+ ##### `webFunction`<sup>Required</sup> <a name="webFunction" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionRevisionAttributes.property.webFunction"></a>
3285
+
3286
+ ```typescript
3287
+ public readonly webFunction: IWebFunctionRef;
3288
+ ```
3289
+
3290
+ - *Type:* aws-cdk-lib.interfaces.aws_lambda.IWebFunctionRef
3291
+
3292
+ The function the revision belongs to.
3293
+
3294
+ ---
3295
+
3296
+ ### WebFunctionRevisionWeight <a name="WebFunctionRevisionWeight" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionRevisionWeight"></a>
3297
+
3298
+ A revision and the share of an endpoint's traffic it receives.
3299
+
3300
+ #### Initializer <a name="Initializer" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionRevisionWeight.Initializer"></a>
3301
+
3302
+ ```typescript
3303
+ import { WebFunctionRevisionWeight } from '@ashishpandeyone/cdk-lambda-web-function'
3304
+
3305
+ const webFunctionRevisionWeight: WebFunctionRevisionWeight = { ... }
3306
+ ```
3307
+
3308
+ #### Properties <a name="Properties" id="Properties"></a>
3309
+
3310
+ | **Name** | **Type** | **Description** |
3311
+ | --- | --- | --- |
3312
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionRevisionWeight.property.revision">revision</a></code> | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.IWebFunctionRevision">IWebFunctionRevision</a></code> | The revision. |
3313
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionRevisionWeight.property.weight">weight</a></code> | <code>number</code> | The revision's share of the endpoint's traffic, as a fraction (like `lambda.Alias` `additionalVersions`). Must be a whole percentage from 0.01 to 0.99. |
3314
+
3315
+ ---
3316
+
3317
+ ##### `revision`<sup>Required</sup> <a name="revision" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionRevisionWeight.property.revision"></a>
3318
+
3319
+ ```typescript
3320
+ public readonly revision: IWebFunctionRevision;
3321
+ ```
3322
+
3323
+ - *Type:* <a href="#@ashishpandeyone/cdk-lambda-web-function.IWebFunctionRevision">IWebFunctionRevision</a>
3324
+
3325
+ The revision.
3326
+
3327
+ ---
3328
+
3329
+ ##### `weight`<sup>Required</sup> <a name="weight" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionRevisionWeight.property.weight"></a>
3330
+
3331
+ ```typescript
3332
+ public readonly weight: number;
3333
+ ```
3334
+
3335
+ - *Type:* number
3336
+
3337
+ The revision's share of the endpoint's traffic, as a fraction (like `lambda.Alias` `additionalVersions`). Must be a whole percentage from 0.01 to 0.99.
3338
+
3339
+ ---
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
+
2078
3439
  ## Classes <a name="Classes" id="Classes"></a>
2079
3440
 
3441
+ ### WebFunctionDeployment <a name="WebFunctionDeployment" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionDeployment"></a>
3442
+
3443
+ How an endpoint moves its traffic to a new revision.
3444
+
3445
+
3446
+ #### Static Functions <a name="Static Functions" id="Static Functions"></a>
3447
+
3448
+ | **Name** | **Description** |
3449
+ | --- | --- |
3450
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionDeployment.allAtOnce">allAtOnce</a></code> | All traffic moves to the new revision at once, as soon as it's ready (the default). |
3451
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionDeployment.canary">canary</a></code> | The new revision first gets `percent` of the traffic for `bake`, then all of it. |
3452
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionDeployment.linear">linear</a></code> | The new revision gets `percent` more of the traffic every `interval` until it has all of it. |
3453
+
3454
+ ---
3455
+
3456
+ ##### `allAtOnce` <a name="allAtOnce" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionDeployment.allAtOnce"></a>
3457
+
3458
+ ```typescript
3459
+ import { WebFunctionDeployment } from '@ashishpandeyone/cdk-lambda-web-function'
3460
+
3461
+ WebFunctionDeployment.allAtOnce()
3462
+ ```
3463
+
3464
+ All traffic moves to the new revision at once, as soon as it's ready (the default).
3465
+
3466
+ ##### `canary` <a name="canary" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionDeployment.canary"></a>
3467
+
3468
+ ```typescript
3469
+ import { WebFunctionDeployment } from '@ashishpandeyone/cdk-lambda-web-function'
3470
+
3471
+ WebFunctionDeployment.canary(options: WebFunctionCanaryDeploymentOptions)
3472
+ ```
3473
+
3474
+ The new revision first gets `percent` of the traffic for `bake`, then all of it.
3475
+
3476
+ ###### `options`<sup>Required</sup> <a name="options" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionDeployment.canary.parameter.options"></a>
3477
+
3478
+ - *Type:* <a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionCanaryDeploymentOptions">WebFunctionCanaryDeploymentOptions</a>
3479
+
3480
+ ---
3481
+
3482
+ ##### `linear` <a name="linear" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionDeployment.linear"></a>
3483
+
3484
+ ```typescript
3485
+ import { WebFunctionDeployment } from '@ashishpandeyone/cdk-lambda-web-function'
3486
+
3487
+ WebFunctionDeployment.linear(options: WebFunctionLinearDeploymentOptions)
3488
+ ```
3489
+
3490
+ The new revision gets `percent` more of the traffic every `interval` until it has all of it.
3491
+
3492
+ ###### `options`<sup>Required</sup> <a name="options" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionDeployment.linear.parameter.options"></a>
3493
+
3494
+ - *Type:* <a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionLinearDeploymentOptions">WebFunctionLinearDeploymentOptions</a>
3495
+
3496
+ ---
3497
+
3498
+
3499
+
2080
3500
  ### WebFunctionGrants <a name="WebFunctionGrants" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionGrants"></a>
2081
3501
 
2082
- Grants on a Web Function.
3502
+ Grants on a Web Function endpoint.
2083
3503
 
2084
- Access it as `fn.grants`.
3504
+ Access them as `fn.grants` (the default endpoint) or `endpoint.grants`.
2085
3505
 
2086
3506
  #### Methods <a name="Methods" id="Methods"></a>
2087
3507
 
2088
3508
  | **Name** | **Description** |
2089
3509
  | --- | --- |
2090
- | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionGrants.invoke">invoke</a></code> | Allows `grantee` to call the function's endpoint (`lambda:InvokeWebFunctionEndpoint`). |
3510
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionGrants.invoke">invoke</a></code> | Allows `grantee` to call the endpoint (`lambda:InvokeWebFunctionEndpoint`). |
2091
3511
 
2092
3512
  ---
2093
3513
 
@@ -2097,7 +3517,7 @@ Access it as `fn.grants`.
2097
3517
  public invoke(grantee: IGrantable): Grant
2098
3518
  ```
2099
3519
 
2100
- Allows `grantee` to call the function's endpoint (`lambda:InvokeWebFunctionEndpoint`).
3520
+ Allows `grantee` to call the endpoint (`lambda:InvokeWebFunctionEndpoint`).
2101
3521
 
2102
3522
  The grant is on the endpoint's home-region ARN, which IAM evaluates for every region the
2103
3523
  endpoint serves from, including a MULTI_REGION global URL.
@@ -2215,6 +3635,74 @@ The function's name.
2215
3635
 
2216
3636
  ---
2217
3637
 
3638
+ ### IWebFunctionRevision <a name="IWebFunctionRevision" id="@ashishpandeyone/cdk-lambda-web-function.IWebFunctionRevision"></a>
3639
+
3640
+ - *Extends:* constructs.IConstruct
3641
+
3642
+ - *Implemented By:* <a href="#@ashishpandeyone/cdk-lambda-web-function.WebFunctionRevision">WebFunctionRevision</a>, <a href="#@ashishpandeyone/cdk-lambda-web-function.IWebFunctionRevision">IWebFunctionRevision</a>
3643
+
3644
+ A revision of a Web Function: an immutable snapshot of its code and configuration.
3645
+
3646
+
3647
+ #### Properties <a name="Properties" id="Properties"></a>
3648
+
3649
+ | **Name** | **Type** | **Description** |
3650
+ | --- | --- | --- |
3651
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.IWebFunctionRevision.property.node">node</a></code> | <code>constructs.Node</code> | The tree node. |
3652
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.IWebFunctionRevision.property.revisionArn">revisionArn</a></code> | <code>string</code> | The revision's ARN. |
3653
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.IWebFunctionRevision.property.revisionId">revisionId</a></code> | <code>string</code> | The revision's ID, e.g. `rev-a1b2c`. |
3654
+ | <code><a href="#@ashishpandeyone/cdk-lambda-web-function.IWebFunctionRevision.property.webFunction">webFunction</a></code> | <code>aws-cdk-lib.interfaces.aws_lambda.IWebFunctionRef</code> | The function the revision belongs to. |
3655
+
3656
+ ---
3657
+
3658
+ ##### `node`<sup>Required</sup> <a name="node" id="@ashishpandeyone/cdk-lambda-web-function.IWebFunctionRevision.property.node"></a>
3659
+
3660
+ ```typescript
3661
+ public readonly node: Node;
3662
+ ```
3663
+
3664
+ - *Type:* constructs.Node
3665
+
3666
+ The tree node.
3667
+
3668
+ ---
3669
+
3670
+ ##### `revisionArn`<sup>Required</sup> <a name="revisionArn" id="@ashishpandeyone/cdk-lambda-web-function.IWebFunctionRevision.property.revisionArn"></a>
3671
+
3672
+ ```typescript
3673
+ public readonly revisionArn: string;
3674
+ ```
3675
+
3676
+ - *Type:* string
3677
+
3678
+ The revision's ARN.
3679
+
3680
+ ---
3681
+
3682
+ ##### `revisionId`<sup>Required</sup> <a name="revisionId" id="@ashishpandeyone/cdk-lambda-web-function.IWebFunctionRevision.property.revisionId"></a>
3683
+
3684
+ ```typescript
3685
+ public readonly revisionId: string;
3686
+ ```
3687
+
3688
+ - *Type:* string
3689
+
3690
+ The revision's ID, e.g. `rev-a1b2c`.
3691
+
3692
+ ---
3693
+
3694
+ ##### `webFunction`<sup>Required</sup> <a name="webFunction" id="@ashishpandeyone/cdk-lambda-web-function.IWebFunctionRevision.property.webFunction"></a>
3695
+
3696
+ ```typescript
3697
+ public readonly webFunction: IWebFunctionRef;
3698
+ ```
3699
+
3700
+ - *Type:* aws-cdk-lib.interfaces.aws_lambda.IWebFunctionRef
3701
+
3702
+ The function the revision belongs to.
3703
+
3704
+ ---
3705
+
2218
3706
  ## Enums <a name="Enums" id="Enums"></a>
2219
3707
 
2220
3708
  ### WebFunctionAuthType <a name="WebFunctionAuthType" id="@ashishpandeyone/cdk-lambda-web-function.WebFunctionAuthType"></a>