powertools-lambda-typescript
powertools-lambda-typescript copied to clipboard
Bug (all) : Unexpected PowerTools behaviours when leveraging the default SAM TypeScript template with SAM ESBuild support enabled
Summary
When using the SAM "Hello World Example TypeScript TS" template with ESBuild support enabled various PowerTools anomalies are observed.
Configuration
aws-lambda-powertools ^1.0.2 middy/core": ^3.1.1 sam cli 1.53.0 nodejs14.x
Bug description
Various documented PowerTools expected behaviours are not operating as expected when leveraging the default SAM TypeScript template ". ESBuild beta support has been enabled.
Logger Example : Powertools logger does not log the expected additional Lambda context information when configured according to the documentation.
Example of log keys generated
{
"level": "INFO",
"message": "Example INFO log missing context",
"service": "PowerToolsLoggerExample",
"timestamp": "2022-08-11T09:43:16.307Z",
"xray_trace_id": "1-62f4cf33-4e8360c401b2c85f2521113c"
}
Expected log keys generated
{
"cold_start": true,
"function_arn": "arn:aws:lambda:eu-west-1:123456789012:function:shopping-cart-api-lambda-prod-eu-west-1",
"function_memory_size": 128,
"function_request_id": "c6af9ac6-7b61-11e6-9a41-93e812345678",
"function_name": "shopping-cart-api-lambda-prod-eu-west-1",
"level": "INFO",
"message": "This is an INFO log with some context",
"service": "serverlessAirline",
"timestamp": "2021-12-12T21:21:08.921Z",
"xray_trace_id": "abcdef123456abcdef123456abcdef123456"
}
Steps to Reproduce
- Build a new SAM project leveraging the default TypeScript template
"Hello World Example TypeScript" - Enable es2020 support in SAM template.yaml
Metadata: # Manage esbuild properties
BuildMethod: esbuild
BuildProperties:
Minify: true
Target: "es2020"
Sourcemap: true
- Configure PowerTools logger as per documentation and generate a log. Observe the missing context information.
HI @DomSearle,
thanks for reporting the issue. I will look into this and get back to you as soon as I have reproduced it.
Thanks. I have been working internally with Andrea Amorosi on this and he has a copy of my code repo if helpful.
Thank you @DomSearle, yes, I have already talked with Benedikt and shared your repo with them as well all the other details shared in the Slack thread.
As already discussed in private, @DomSearle, please check that the Handler defined in template.yaml matches the actual handler exported in your function code. Issue can be closed!
Thanks @bpauwels for your assistance in resolving my local configuration issue. Closing as not a bug.
⚠️ COMMENT VISIBILITY WARNING ⚠️
Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.
@bpauwels can you share the resolution steps/details in this issue?
Maybe it'll be helpful to others in the future.
For posterity: no resolution steps are needed as this was due to a small misnaming in the IaC config.