-
Notifications
You must be signed in to change notification settings - Fork 407
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(event_handlers): Add support for Lambda Function URLs #1408
feat(event_handlers): Add support for Lambda Function URLs #1408
Conversation
Looks good -- thanks much!!!! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please correct spelling errors
Codecov Report
@@ Coverage Diff @@
## develop #1408 +/- ##
========================================
Coverage 99.89% 99.89%
========================================
Files 119 121 +2
Lines 5456 5480 +24
Branches 624 627 +3
========================================
+ Hits 5450 5474 +24
Misses 2 2
Partials 4 4
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks great, thank you @rubenfonseca !!!! Minor suggestions that you can easily commit, then we're good to merge and release tomorrow!
@@ -546,6 +552,9 @@ def _to_proxy_event(self, event: Dict) -> BaseProxyEvent: | |||
if self._proxy_type == ProxyEventType.APIGatewayProxyEventV2: | |||
logger.debug("Converting event to API Gateway HTTP API contract") | |||
return APIGatewayProxyEventV2(event) | |||
if self._proxy_type == ProxyEventType.LambdaFunctionUrlEvent: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note to future self: we should improve the return type to a more accurate one with @overload
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note to future self: wait for python 3.10 to actually have proper pattern matching
@@ -501,7 +526,7 @@ A micro function means that your final code artifact will be different to each f | |||
|
|||
**Downsides** | |||
|
|||
* **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. | |||
* **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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great catch!!
POWERTOOLS_SERVICE_NAME: example | ||
FunctionUrlConfig: | ||
Cors: # see CORS section | ||
# Notice that values here are Lists of Strings, vs comma-separated values on API Gateway |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great note!
YES except we won’t be able to use it (unless someone backported it? :/
…On Thu, 4 Aug 2022 at 12:13, Ruben Fonseca ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In aws_lambda_powertools/event_handler/api_gateway.py
<#1408 (comment)>
:
> @@ -546,6 +552,9 @@ def _to_proxy_event(self, event: Dict) -> BaseProxyEvent:
if self._proxy_type == ProxyEventType.APIGatewayProxyEventV2:
logger.debug("Converting event to API Gateway HTTP API contract")
return APIGatewayProxyEventV2(event)
+ if self._proxy_type == ProxyEventType.LambdaFunctionUrlEvent:
note to future self: wait for python 3.10 to actually have proper pattern
matching <https://peps.python.org/pep-0634/>
—
Reply to this email directly, view it on GitHub
<#1408 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAZPQBDYSRNV2NIQ6OXQAY3VXOJWDANCNFSM55OS2IVQ>
.
You are receiving this because you were assigned.Message ID:
***@***.***
com>
|
Co-authored-by: Heitor Lessa <heitor.lessa@hotmail.com>
Merging! Should be out in our next release tomorrow |
Issue number: #1142, #1141
Summary
Changes
This PR adds support for Lambda Function URL events (data class) and event handlers.
Data Class
For now, it seems that Lambda Function URL events follow the exact same payload as HTTP APIs Payload Format Version 2.0.
Event Handler
Certain keys in this payload format don't make sense for function urls (e.g:
routeKey
,stage
). These keys will have default values that come on the payload, but they are not useful since they can't be changed.User experience
Users could already use Lambda Function URLs before by using the API Gateway HTTP API data classes and handlers. However, we make the usage explicit and prepare for any future deviation from the API Gateway format.
Checklist
If your change doesn't seem to apply, please leave them unchecked.
Is this a breaking change?
RFC issue number:
Checklist:
Acknowledgment
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.
View rendered docs/core/event_handler/api_gateway.md
View rendered docs/index.md
View rendered docs/utilities/data_classes.md