-
Notifications
You must be signed in to change notification settings - Fork 421
docs(middleware-factory): snippets split, improved, and lint #1451
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
docs(middleware-factory): snippets split, improved, and lint #1451
Conversation
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 good too! Navigation needs fixing and made a suggestion to raise the bar by including a new section Combining Powertools utilities
.
This should address a common question on how to best handle decorator stacking or create their own middleware with common Powertools utilities baked in
Hi @heitorlessa and @rubenfonseca.. Could you please review the example? I think it covers a lot of features/utilities provided by Lambda Powertools and it is a real case for many customers. Thank you 😄 |
- dynamodb:PutItem | ||
Resource: !GetAtt HistoryTable.Arn | ||
- Effect: Allow | ||
Action: # https://docs.aws.amazon.com/appconfig/latest/userguide/getting-started-with-appconfig-permissions.html |
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.
I'm not sure if I'm comfortable with this, but from what I can see it's a real example in an official AWS documentation.
|
||
# this is just an example | ||
# change this values according your deployment strategy | ||
BasicDeploymentStrategy: |
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.
I added the deployment strategy to avoid the default baking time.. The default time (10 minutes) is too long to someone that wants to test this template.
def middleware_custom(handler: Callable, event: dict, context: LambdaContext): | ||
|
||
# validating the INPUT with the given schema | ||
# X-Customer-Id header must be informed in all requests |
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.
Early return? I think I need other opinions 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.
Great job Leandro! Left some comments :)
examples/middleware_factory/sam/combining_powertools_utilities_template.yaml
Outdated
Show resolved
Hide resolved
examples/middleware_factory/sam/combining_powertools_utilities_template.yaml
Outdated
Show resolved
Hide resolved
examples/middleware_factory/src/combining_powertools_utilities_function.py
Show resolved
Hide resolved
examples/middleware_factory/src/getting_started_middleware_before_logic_function.py
Outdated
Show resolved
Hide resolved
examples/middleware_factory/src/getting_started_middleware_with_params_function.py
Outdated
Show resolved
Hide resolved
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.
LGTM
Issue number: #1367
Summary
Changes
Changes snippet fictitious names to real code snippet filenames for easier discovery and collaboration to improve/correct document snippets.
Some examples have also been refactored so that the codes are complete and there are no lint/pre-commit hooks issues.
User experience
Before:


After:


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/utilities/middleware_factory.md