Hi There,
Any help is highly appreciated, I have been struggling with the below error for last 3 days and tried all the configurations including zip type and hotreloading of lamda code but of no use. It would be great if you can let me know which configuration is missing. When the function is created it doesn’t have any code in the folder “/var/runtime”. What is the configuration that I have to use? Is there any system variable that is available to override where to look for code files when a function is created.
l.s.l.i.executor_endpoint : Execution environment startup failed: {"errorType":"Runtime.ImportModuleError","errorMessage":"Error: Cannot find module 'index'\nRequire stack:\n- /var/runtime/index.mjs","trace":["Runtime.ImportModuleError: Error: Cannot find module 'index'","Require stack:","- /var/runtime/index.mjs"," at _loadUserApp (file:///var/runtime/index.mjs:1087:17)"," at async UserFunction.js.module.exports.load (file:///var/runtime/index.mjs:1119:21)"," at async start (file:///var/runtime/index.mjs:1282:23)"," at async file:///var/runtime/index.mjs:1288:1"]}
awslocal batch script:
awslocal lambda create-function \
--code S3Bucket='hot-reload',S3Key='/usr/lambda' \
--function-name abc-function \
--handler app/index.handler \
--role "arn:aws:iam::000000000000:role/DummyRole" \
--runtime nodejs20.x \
--environment "Variables={LOG_LEVEL=debug,UPDATE_REQUEST_QUEUE_URL=${UPDATE_REQUEST_QUEUE_URL},MESSAGE_GROUPS=2}"
log "Created Lambda function"
Docker compose:
version: "3.0"
networks:
test:
services:
localstack:
image: localstack/localstack:3.4.0
networks:
- test
environment:
- SERVICES=sns,sqs,kms,events,lambda,s3,iam
- LOCALSTACK_HOST=localstack
- AWS_ACCESS_KEY_ID=test
- AWS_SECRET_ACCESS_KEY=test
- AWS_REGION=eu-west-2
- AWS_DEFAULT_REGION=eu-west-2
- DEFAULT_REGION=eu-west-2
- SKIP_SSL_CERT_DOWNLOAD=1
- LOCALSTACK_KMS_BACKEND=moto
- LAMBDA_RUNTIME_ENVIRONMENT_TIMEOUT=2000
- LAMBDA_KEEPALIVE_MS=6000000
- LAMBDA_EXECUTOR=docker-reuse
- DEBUG=0
- UPDATE_REQUEST_QUEUE_URL=http://localstack:4566/000000000000/test_update_request_queue.fifo
- UPDATE_REQUEST_SNS_TOPIC_ARN=arn:aws:sns:eu-west-2:000000000000:test_update_request_queue.fifo
- MESSAGE_GROUPS=2
volumes:
- ./test/integration/localstackinit.d/init:/etc/localstack/init/boot.d/
- ./test/integration/localstackinit.d/ready/:/etc/localstack/init/ready.d/
- ./sd_refresh_docs.zip://home/aws/functions/sd_refresh_docs.zip
- ./:/usr/lambda/
- "/var/run/docker.sock:/var/run/docker.sock"
healthcheck:
test: [ "CMD", "curl", "http://localhost.localstack.cloud:4566/_localstack/health" ]
interval: 10s
timeout: 5s
retries: 10
expose:
- 4566
- 4575
- 9915
ports:
- 4566:4566
- 4575:4575
- 9915:9915
- 4571:4572
- 8090:8080
Below is the structure of lambda code
All the code files are in app folder including index.js
Please suggest if I am missing anything.
Thank you