Description
Expected Behaviour
Do not import CodePipelineJobEvent
when using ApiGatewayResolver
, because the CodePipelineJobEvent
will import boto3
and huge increase the AWS Lambda Cold Start or prevent boto3
from being called unexpectedly.
Current Behaviour
When importing ApiGatewayResolver
, it is importing CodePipelineJobEvent
and boto3
. However, ApiGatewayResolver
does not need boto3
.
This behaviour is increasing the AWS Lambda cold start. When I use a profiling tool in my machine, it seems that just to import it is costing ~200ms. When running on AWS with a 800MB runtime, it is costing ~400ms.
According to the profiling in this use case, importing CodePipelineJobEvent
costed 61.9% of time, but it will not be used. That is weird.
Code snippet
from aws_lambda_powertools.logging import Logger
from aws_lambda_powertools.metrics import Metrics
from aws_lambda_powertools.tracing import Tracer
from aws_lambda_powertools.event_handler.api_gateway import ApiGatewayResolver
Possible Solution
No response
Steps to Reproduce
- Put this code on a Python file;
- Install
tuna
package usingpip install tuna
; - Run command
python -X importtime MY_SCRIPT.py 2> profile.log && tuna profile.log
Browser will appear with the profiling graph.
Powertools for AWS Lambda (Python) version
latest
AWS Lambda function runtime
3.9
Packaging format used
PyPi
Debugging logs
No response