-
Notifications
You must be signed in to change notification settings - Fork 141
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(examples): add example for AWS SAM #674
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.
Hello @bpauwels thanks a lot for opening this PR. I've made a first round of review in which I've left some comments. To avoid repeating I've left the comments only in one function but they apply to others as well.
I'm concerned about the long-term maintenance of Lambda functions for different tools Right now, we may have only SAM and CDK. But we'll eventually end up with probably 5+ tools. If we add/modify a feature, we'll need to do it 5+ times. The person who updates it will need to be familiar with 5+ tools. This will be very challenging to maintain and the example will be outdated very soon. I'm wondering if it's possible to use Lambda functions from another folder? If so, could we reuse the same set of Lambda functions existing in the cdk examples?
The drawback is that this is quite uncommon pattern for both CDK and SAM. So we need to decide on a trade-off here. |
As an alternative to @ijemmy's proposal, that I 100% share, I'd like to bring up the option of introducing a prerequisite step for users. With a structure like this:
Before running Since to test this they have to clone & checkout the repo locally anyway, any change they make would be on their local version. This would help keep the examples consistent with their idiomatic way of structuring a project and would still ease the maintenance overhead. The trade-off in this scenario would be that the examples would be less easy to just browse on GitHub. |
…ynamoDB DocumentClient
Thanks for reviewing, I have worked on the comments from @dreamorosi and added a few more commit. I like your idea of using lambda functions from another folder - but as of now the CDK sample and the SAM sample use completely different functions. (actually the SAM sample is based on the SAM "Quick Start: App Backend using TypeScript"). Would it make sense then? |
Thank you @bpauwels for addressing all the comments, really appreciate it. We are open to modify the content of the Lambda functions in the CDK example & converge to a common example surface that showcases Lambda Powertools, so that shouldn't be an issue. I think at this stage, and for the scope of this PR, it would be great to have the functions of this example extracted from the folder while still being able to deploy it easily and in a relatively idiomatic way. Later on we will adapt the CDK example to use all / some / most of these same functions and definitely remove all the leftover functions under For the CDK example, the functions that we consider most important are:
We consider them as such because these are the ones that show most of the features of the three utilities and with different patterns (manual instrumentation, decorator, Middy middleware). |
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.
Thanks for your contribution and the samples added. I also agree with @ijemmy and @dreamorosi's observation that this risks to become hard to maintain for us in the long term.
@dreamorosi @saragerion @ijemmy - I could not find any way to automatically create a symlink of an higher level lamdba-functions/ folder to src/handlers/ inside the SAM example. Last thing I tried was a git post-checkout hook but hooks are not commited to the repo. So the only way then would be to add an instruction to the README.md to create the symlink manually. |
Yep, that's acceptable |
Co-authored-by: Sara Gerion <[email protected]>
Co-authored-by: Sara Gerion <[email protected]>
The SAM CLI reads the application template to determine the API's routes and the functions that they invoke. The `Events` property on each function's definition includes the route and method for each path. | ||
|
||
```yaml | ||
Events: |
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.
Yes, it's correct if you look at it relative to the larger template, but since this is a decontextualised code snippet it's a bit odd that the first line starts with 6 spaces.
Either way it's really a minor / nitpicky comment, you can leave it if you think it makes sense.
… logger example in get-by-id and put-item to match get-all-items;
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.
After the latest round of commits I was finally able to deploy the sample & execute the functions, great job!
We have just 6 items remaining to address and then we're good to go:
docs(examples): add example for AWS SAM #674 (comment)docs(examples): add example for AWS SAM #674 (comment)docs(examples): add example for AWS SAM #674 (comment)docs(examples): add example for AWS SAM #674 (comment)docs(examples): add example for AWS SAM #674 (comment)docs(examples): add example for AWS SAM #674 (comment)
We are really close!!
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.
Thanks a ton for your hard work @bpauwels, looking forward to see this merged and to hear customer's feedback on it!
Description of your changes
Added an example for AWS SAM
How to verify this change
see new SAM example, use SAM CLI to deploy it
Related issues, RFCs
#606
PR status
Is this ready for review?: YES
Is it a breaking change?: NO
Checklist
Breaking change checklist
no breaking changes
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.