Some Lambda errors and resolutions:
1.
Lambda experiences timeout and provides no
response:
Possibly this will help:
version: '3.9'
services:
api:
image: public.ecr.aws/sam/build-nodejs14.x:1.26.0
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- ./dist:/var/task:ro
ports:
- 3000:3000
command: sam local start-api --template stack.yaml --host 0.0.0.0
--docker-network application --container-host host.docker.internal
--warm-containers EAGER
networks:
default:
name: application
Essentially, the
idea is to increase the timeout for all the large dependencies to load or use a warm start.
2.
Runtime.HandlerNotFound: index.handler is
undefined or not exported
One of the
following remediation steps could help assuming that a function handler exists
as entrypoint for Lambda:
1.
Module.exports = handler
2.
Exports default handler;
3.
Ensure that the file with the handler
is at the root level.
4.
The handler reference in the template
has path qualification.
3.
And the handler does not like import statements
in the NodeJscode
i.
Use require as preferred on the Javascript
console
ii.
Use ES modules as preferred by the newer nodeJs
runtime
4.
The size of the code exceeds 50MB.
i.
If the archive exceeds 50MB, upload it to S3
ii.
Separate the dependency into layers
iii.
Use a container image.
No comments:
Post a Comment