Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SAM Build Not Mounting Lambda Code in /var/task During sam local start api on Windows #7478

Open
pedrocimp opened this issue Sep 13, 2024 · 2 comments
Labels
area/docker blocked/more-info-needed More info is needed from the requester. If no response in 14 days, it will become stale. platform/windows

Comments

@pedrocimp
Copy link

Description:

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:

  1. Run sam build.
  2. Start the Lambda function using either sam local start api or sam local invoke.
  3. 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.

Thank you for your help!

@pedrocimp pedrocimp added the stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. label Sep 13, 2024
@aaythapa
Copy link

Looks like a SAM CLI issue, transferring over to them

@aaythapa aaythapa transferred this issue from aws/serverless-application-model Sep 13, 2024
@sidhujus
Copy link
Contributor

Hi thanks for raising this issue! Could you provide the output generated by sam cli when running the commands with the --debug flag?

@sidhujus sidhujus added area/docker platform/windows blocked/more-info-needed More info is needed from the requester. If no response in 14 days, it will become stale. and removed stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. labels Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/docker blocked/more-info-needed More info is needed from the requester. If no response in 14 days, it will become stale. platform/windows
Projects
None yet
Development

No branches or pull requests

3 participants