aws / aws-sam-cli

CLI tool to build, test, debug, and deploy Serverless applications using AWS SAM
https://aws.amazon.com/serverless/sam/
Apache License 2.0
6.5k stars 1.17k forks source link

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

Open pedrocimp opened 2 weeks ago

pedrocimp commented 2 weeks ago

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:

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:

Thank you for your help!

aaythapa commented 2 weeks ago

Looks like a SAM CLI issue, transferring over to them

sidhujus commented 1 week ago

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