Closed
Description
Summary
The repo contains SAM examples of how to use the libraries. These examples are one of the most visited pages in the repository and since they were released the project and its documentation has evolved. The examples should be updated to reflect that.
Why is this needed?
The SAM samples were first created several months ago and in the meantime several updates have happened, so it's time to refresh them.
Which area does this relate to?
Other
Solution
Below a list of changes in no particular order:
Updates to README
- Change the section that reads "You will need to have a valid AWS Account in order to deploy these resources" to a "Note" with GitHub specific markdown (see here), so that it's better highlighted.
- Link documentation about Layers in Layers section of the README
- Modify X-Ray section of docs to point to CloudWatch Traces section instead
- Remove the section that talks/lists all IDEs (see image in details below)

Maintenance
- Update Powertools dependencies to latest available at time of PR
- Update all
devDependencies
to latest available & test that everything works - Move back code to
examples/lambda-functions
(where it was originally) & symlink (how it was originally)
Code
- Update one Lambda function to use Middy middleware usage (see docs)
- Update second Lambda to use Class-based/decorators usage (see docs)
- Update third Lambda (manual usage - like it is now) and make sure all features are represented (see docs)
- Move Powertools instances creation in shared file & import it throughout other files (see example here)
- Make sure all functions are minified, have source maps, use
NODE_OPTIONS: --enable-source-maps' ([here](https://docs.aws.amazon.com/lambda/latest/dg/typescript-exceptions.html)), and use
AWS_NODEJS_CONNECTION_REUSE_ENABLED = 1` (here) - Move DynamoDB client instantiation in separate shared file, reuse across functions (see example here) & apply tracing to it
- Move from
aws-sdk
(v2) to@aws-sdk/client-dynamodb
(v3 - docs) - keep DocumentClient - Add an example of HTTP call (i.e. fake retrieve data at some point) in each function at the beginning, use phin to make requests, make a request to https://httpbin.org/#/Dynamic_data/get_uuid and add the returned uuid to logs (with this), to main segment as annotation (see docs), and as metadata to metrics (using
addMetadata
). - All functions should log the incoming event: middleware/decorator via parameter, manual via a
logger.info(...)
Acknowledgment
- This request meets Lambda Powertools Tenets
- Should this be considered in other Lambda Powertools languages? i.e. TypeScript, Java