@@ -9,19 +9,19 @@ Event handler for Amazon API Gateway REST and HTTP APIs, Application Loader Bala |
9 | 9 |
|
10 | 10 | * Lightweight routing to reduce boilerplate for API Gateway REST/HTTP API, ALB and Lambda Function URLs. |
11 | 11 | * Support for CORS, binary and Gzip compression, Decimals JSON encoding and bring your own JSON serializer |
12 | | -* Built-in integration with [Event Source Data Classes utilities](../../utilities/data_classes.md){target="_blank" rel="nofollow"} for self-documented event schema |
| 12 | +* Built-in integration with [Event Source Data Classes utilities](../../utilities/data_classes.md){target="_blank"} for self-documented event schema |
13 | 13 |
|
14 | 14 | ## Getting started |
15 | 15 |
|
16 | 16 | ???+ tip |
17 | | - All examples shared in this documentation are available within the [project repository](https://github.com/aws-powertools/powertools-lambda-python/tree/develop/examples){target="_blank" rel="nofollow"}. |
| 17 | + All examples shared in this documentation are available within the [project repository](https://github.com/aws-powertools/powertools-lambda-python/tree/develop/examples){target="_blank"}. |
18 | 18 |
|
19 | 19 | ### Required resources |
20 | 20 |
|
21 | 21 | <!-- markdownlint-disable-next-line MD013 --> |
22 | | -If you're using any API Gateway integration, you must have an existing [API Gateway Proxy integration](https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-lambda-proxy-integrations.html){target="_blank" rel="nofollow"} or [ALB](https://docs.aws.amazon.com/elasticloadbalancing/latest/application/lambda-functions.html){target="_blank" rel="nofollow"} configured to invoke your Lambda function. |
| 22 | +If you're using any API Gateway integration, you must have an existing [API Gateway Proxy integration](https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-lambda-proxy-integrations.html){target="_blank"} or [ALB](https://docs.aws.amazon.com/elasticloadbalancing/latest/application/lambda-functions.html){target="_blank"} configured to invoke your Lambda function. |
23 | 23 |
|
24 | | -In case of using [VPC Lattice](https://docs.aws.amazon.com/lambda/latest/dg/services-vpc-lattice.html){target="_blank" rel="nofollow"}, you must have a service network configured to invoke your Lambda function. |
| 24 | +In case of using [VPC Lattice](https://docs.aws.amazon.com/lambda/latest/dg/services-vpc-lattice.html){target="_blank"}, you must have a service network configured to invoke your Lambda function. |
25 | 25 |
|
26 | 26 | This is the sample infrastructure for API Gateway and Lambda Function URLs we are using for the examples in this documentation. |
27 | 27 |
|
@@ -105,7 +105,7 @@ When using Amazon Application Load Balancer (ALB) to front your Lambda functions |
105 | 105 |
|
106 | 106 | #### Lambda Function URL |
107 | 107 |
|
108 | | -When using [AWS Lambda Function URL](https://docs.aws.amazon.com/lambda/latest/dg/urls-configuration.html){target="_blank" rel="nofollow"}, you can use `LambdaFunctionUrlResolver`. |
| 108 | +When using [AWS Lambda Function URL](https://docs.aws.amazon.com/lambda/latest/dg/urls-configuration.html){target="_blank"}, you can use `LambdaFunctionUrlResolver`. |
109 | 109 |
|
110 | 110 | === "getting_started_lambda_function_url_resolver.py" |
111 | 111 |
|
@@ -121,7 +121,7 @@ When using [AWS Lambda Function URL](https://docs.aws.amazon.com/lambda/latest/d |
121 | 121 |
|
122 | 122 | #### VPC Lattice |
123 | 123 |
|
124 | | -When using [VPC Lattice with AWS Lambda](https://docs.aws.amazon.com/lambda/latest/dg/services-vpc-lattice.html){target="_blank" rel="nofollow"}, you can use `VPCLatticeResolver`. |
| 124 | +When using [VPC Lattice with AWS Lambda](https://docs.aws.amazon.com/lambda/latest/dg/services-vpc-lattice.html){target="_blank"}, you can use `VPCLatticeResolver`. |
125 | 125 |
|
126 | 126 | === "getting_started_vpclattice_resolver.py" |
127 | 127 |
|
@@ -210,7 +210,7 @@ If you need to accept multiple HTTP methods in a single function, you can use th |
210 | 210 |
|
211 | 211 | ### Accessing request details |
212 | 212 |
|
213 | | -Event Handler integrates with [Event Source Data Classes utilities](../../utilities/data_classes.md){target="_blank" rel="nofollow"}, and it exposes their respective resolver request details and convenient methods under `app.current_event`. |
| 213 | +Event Handler integrates with [Event Source Data Classes utilities](../../utilities/data_classes.md){target="_blank"}, and it exposes their respective resolver request details and convenient methods under `app.current_event`. |
214 | 214 |
|
215 | 215 | That is why you see `app.resolve(event, context)` in every example. This allows Event Handler to resolve requests, and expose data like `app.lambda_context` and `app.current_event`. |
216 | 216 |
|
@@ -268,11 +268,11 @@ We provide pre-defined errors for the most popular ones such as HTTP 400, 401, 4 |
268 | 268 |
|
269 | 269 | ### Custom Domain API Mappings |
270 | 270 |
|
271 | | -When using [Custom Domain API Mappings feature](https://docs.aws.amazon.com/apigateway/latest/developerguide/rest-api-mappings.html){target="_blank" rel="nofollow"}, you must use **`strip_prefixes`** param in the `APIGatewayRestResolver` constructor. |
| 271 | +When using [Custom Domain API Mappings feature](https://docs.aws.amazon.com/apigateway/latest/developerguide/rest-api-mappings.html){target="_blank"}, you must use **`strip_prefixes`** param in the `APIGatewayRestResolver` constructor. |
272 | 272 |
|
273 | 273 | **Scenario**: You have a custom domain `api.mydomain.dev`. Then you set `/payment` API Mapping to forward any payment requests to your Payments API. |
274 | 274 |
|
275 | | -**Challenge**: This means your `path` value for any API requests will always contain `/payment/<actual_request>`, leading to HTTP 404 as Event Handler is trying to match what's after `payment/`. This gets further complicated with an [arbitrary level of nesting](https://github.com/aws-powertools/powertools-lambda-roadmap/issues/34){target="_blank" rel="nofollow"}. |
| 275 | +**Challenge**: This means your `path` value for any API requests will always contain `/payment/<actual_request>`, leading to HTTP 404 as Event Handler is trying to match what's after `payment/`. This gets further complicated with an [arbitrary level of nesting](https://github.com/aws-powertools/powertools-lambda-roadmap/issues/34){target="_blank"}. |
276 | 276 |
|
277 | 277 | To address this API Gateway behavior, we use `strip_prefixes` parameter to account for these prefixes that are now injected into the path regardless of which type of API Gateway you're using. |
278 | 278 |
|
@@ -363,7 +363,7 @@ You can use the `Response` class to have full control over the response. For exa |
363 | 363 | Some event sources require headers and cookies to be encoded as `multiValueHeaders`. |
364 | 364 |
|
365 | 365 | ???+ warning "Using multiple values for HTTP headers in ALB?" |
366 | | - Make sure you [enable the multi value headers feature](https://docs.aws.amazon.com/elasticloadbalancing/latest/application/lambda-functions.html#multi-value-headers){target="_blank" rel="nofollow"} to serialize response headers correctly. |
| 366 | + Make sure you [enable the multi value headers feature](https://docs.aws.amazon.com/elasticloadbalancing/latest/application/lambda-functions.html#multi-value-headers){target="_blank"} to serialize response headers correctly. |
367 | 367 |
|
368 | 368 | === "fine_grained_responses.py" |
369 | 369 |
|
@@ -448,7 +448,7 @@ Like `compress` feature, the client must send the `Accept` header with the corre |
448 | 448 |
|
449 | 449 | ### Debug mode |
450 | 450 |
|
451 | | -You can enable debug mode via `debug` param, or via `POWERTOOLS_DEV` [environment variable](../../index.md#environment-variables){target="_blank" rel="nofollow"}. |
| 451 | +You can enable debug mode via `debug` param, or via `POWERTOOLS_DEV` [environment variable](../../index.md#environment-variables){target="_blank"}. |
452 | 452 |
|
453 | 453 | This will enable full tracebacks errors in the response, print request and responses, and set CORS in development mode. |
454 | 454 |
|
@@ -602,7 +602,7 @@ _**Benefits**_ |
602 | 602 |
|
603 | 603 | _**Downsides**_ |
604 | 604 |
|
605 | | -* **Cold starts**. Frequent deployments and/or high load can diminish the benefit of monolithic functions depending on your latency requirements, due to [Lambda scaling model](https://docs.aws.amazon.com/lambda/latest/dg/invocation-scaling.html){target="_blank" rel="nofollow"}. Always load test to pragmatically balance between your customer experience and development cognitive load. |
| 605 | +* **Cold starts**. Frequent deployments and/or high load can diminish the benefit of monolithic functions depending on your latency requirements, due to [Lambda scaling model](https://docs.aws.amazon.com/lambda/latest/dg/invocation-scaling.html){target="_blank"}. Always load test to pragmatically balance between your customer experience and development cognitive load. |
606 | 606 | * **Granular security permissions**. The micro function approach enables you to use fine-grained permissions & access controls, separate external dependencies & code signing at the function level. Conversely, you could have multiple functions while duplicating the final code artifact in a monolithic approach. |
607 | 607 | * Regardless, least privilege can be applied to either approaches. |
608 | 608 | * **Higher risk per deployment**. A misconfiguration or invalid import can cause disruption if not caught earlier in automated testing. Multiple functions can mitigate misconfigurations but they would still share the same code artifact. You can further minimize risks with multiple environments in your CI/CD pipeline. |
@@ -615,13 +615,13 @@ A micro function means that your final code artifact will be different to each f |
615 | 615 |
|
616 | 616 | **Benefits** |
617 | 617 |
|
618 | | -* **Granular scaling**. A micro function can benefit from the [Lambda scaling model](https://docs.aws.amazon.com/lambda/latest/dg/invocation-scaling.html){target="_blank" rel="nofollow"} to scale differently depending on each part of your application. Concurrency controls and provisioned concurrency can also be used at a granular level for capacity management. |
| 618 | +* **Granular scaling**. A micro function can benefit from the [Lambda scaling model](https://docs.aws.amazon.com/lambda/latest/dg/invocation-scaling.html){target="_blank"} to scale differently depending on each part of your application. Concurrency controls and provisioned concurrency can also be used at a granular level for capacity management. |
619 | 619 | * **Discoverability**. Micro functions are easier do visualize when using distributed tracing. Their high-level architectures can be self-explanatory, and complexity is highly visible — assuming each function is named to the business purpose it serves. |
620 | | -* **Package size**. An independent function can be significant smaller (KB vs MB) depending on external dependencies it require to perform its purpose. Conversely, a monolithic approach can benefit from [Lambda Layers](https://docs.aws.amazon.com/lambda/latest/dg/invocation-layers.html){target="_blank" rel="nofollow"} to optimize builds for external dependencies. |
| 620 | +* **Package size**. An independent function can be significant smaller (KB vs MB) depending on external dependencies it require to perform its purpose. Conversely, a monolithic approach can benefit from [Lambda Layers](https://docs.aws.amazon.com/lambda/latest/dg/invocation-layers.html){target="_blank"} to optimize builds for external dependencies. |
621 | 621 |
|
622 | 622 | **Downsides** |
623 | 623 |
|
624 | | -* **Upfront investment**. You need custom build tooling to bundle assets, including [C bindings for runtime compatibility](https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html){target="_blank" rel="nofollow"}. Operations become more elaborate — you need to standardize tracing labels/annotations, structured logging, and metrics to pinpoint root causes. |
| 624 | +* **Upfront investment**. You need custom build tooling to bundle assets, including [C bindings for runtime compatibility](https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html){target="_blank"}. Operations become more elaborate — you need to standardize tracing labels/annotations, structured logging, and metrics to pinpoint root causes. |
625 | 625 | * Engineering discipline is necessary for both approaches. Micro-function approach however requires further attention in consistency as the number of functions grow, just like any distributed system. |
626 | 626 | * **Harder to share code**. Shared code must be carefully evaluated to avoid unnecessary deployments when that changes. Equally, if shared code isn't a library, |
627 | 627 | your development, building, deployment tooling need to accommodate the distinct layout. |
|