DEV Community

Discussion on: Unit Testing AWS Lambda Functions in Node.js

Collapse
 
nairp_onalytica profile image
Parag Nair

Alex, you are calling const deps = await exports.deps() inside the handler. Doesn't that mean every time the handler is executed, it will create an instance of AWS.DynamoDB.DocumentClient. Isn't it recommended for Lambdas to have all your initialization code outside the handler as I assume behind the scenes, it creates a container and stays warm till you keep hitting it periodically. Any initilization outside the handler is called once per container. Just a thought.