When using sam build and running sam local start api or sam local invoke, SAM builds the Lambda image on the fly. However, it seems that the Lambda code is not being mounted correctly in /var/task, which results in an empty directory. This prevents the Lambda from executing properly.
Context:
I expect SAM to mount the built Lambda sources from dist/ into /var/task inside the container. However, the /var/task directory is empty, making it impossible to execute the Lambda function via sam local start api.
I've tried multiple solutions but couldn't resolve this issue. It might be related to switching from a Linux development environment to a Windows environment.
In my template.yml, I point the CodeUri to the compiled code in the dist/ directory, like this:
CodeUri: dist/lambdas/myFunction/
Expected behavior:
The compiled Lambda code should be mounted into /var/task inside the container to allow the Lambda function to execute properly.
Environment:
Operating System: Windows
SAM CLI Version: Tested with version 1.120
Docker Version: 26.1.0-rd
Docker setup: Running on WSL2
Custom Lambda Image: Defined in template.yml
Steps to reproduce:
Run sam build.
Start the Lambda function using either sam local start api or sam local invoke.
Inspect the container, and observe that /var/task is empty.
Possible suggestions or fixes:
Ensure that SAM properly mounts the Lambda code into the /var/task directory during execution on Windows.
Investigate if the issue is related to file mounting differences between Linux and Windows.
Description:
When using
sam build
and runningsam local start api
orsam local invoke
, SAM builds the Lambda image on the fly. However, it seems that the Lambda code is not being mounted correctly in/var/task
, which results in an empty directory. This prevents the Lambda from executing properly.Context:
I expect SAM to mount the built Lambda sources from
dist/
into/var/task
inside the container. However, the/var/task
directory is empty, making it impossible to execute the Lambda function viasam local start api
.I've tried multiple solutions but couldn't resolve this issue. It might be related to switching from a Linux development environment to a Windows environment.
In my
template.yml
, I point theCodeUri
to the compiled code in thedist/
directory, like this:Expected behavior:
The compiled Lambda code should be mounted into
/var/task
inside the container to allow the Lambda function to execute properly.Environment:
template.yml
Steps to reproduce:
sam build
.sam local start api
orsam local invoke
./var/task
is empty.Possible suggestions or fixes:
/var/task
directory during execution on Windows.Thank you for your help!