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.51k stars 1.17k forks source link

SAM local volume mapping #3984

Open agaddamu opened 2 years ago

agaddamu commented 2 years ago

Problem : sam local doesn't support docker volume mapping

Ex: Application has to read files on host machine. The host file location should be accessible to the application running in sam container. Currently there is no available option. The equivalent of this is -v in docker.

sam supports -v ( docker-volume-basedir ) but as per the spec is only for AWS SAM file.

"The location of the base directory where the AWS SAM file exists. If Docker is running on a remote machine, you must mount the path where the AWS SAM file exists on the Docker machine, and modify this value to match the remote machine"

Proposal

Tool built on top of underlying software should support the native options. For example : sam should honor docker options on top of sam options.

Things to consider: [ ] The SAM documentation will need to be updated

Additional Details

jfuss commented 2 years ago

Moving to correct repo.

jfuss commented 2 years ago

@agaddamu Why does your lambda function need access to files on your machine? Are you trying to test something specific?

I ask because when you deploy your lambda function, mounting other directories like this is not an option. You could use ESF however but that interaction we don't emulate locally. Mainly trying to understand what you are attempting to achieve with this.

As a note, you mentioned that "sam should honor docker options" but the reason we don't (in many cases) is because you can't do the same once deployed. So we don't provide the same options docker does to make sure we can emulate how lambda works as best we can.

agaddamu commented 2 years ago

@jfuss Sorry for the delayed response. The use case is "there is a requirement for the application to load certificates during startup. The certificates are available on the host machine."

richard-viney commented 1 year ago

We wan into this because we mount an EFS volume to the lambda that it reads from, but without the ability to mount local volumes under SAM a lambda like that can't be used locally.

Is there an alternative or a workaround?