Open dacgray opened 3 years ago
For reference - this is how we get around this issue:
https://github.com/dacgray/sam-local-start-api-container-image-volume-mount
Thanks for creating the feature request. I am tagging this for PM review and will update once we have discussed in team.
@c2tarun Any updates on this? This is currently a pretty significant drawback when using custom runtime container images, since any changes made to function code need a full rebuild of the runtime container. When using the built-in runtimes SAM detects changes to the function code and rebuilds the containers automatically.
/tmp
would also be a good choice for a mounted volume.
Agree with @BenVosper , this is a much needed feature.
Any progress regarding this request?
This is needed when using DevContainers. Or else it doesn't work.
Any update on this issue?
CC @hnnasit @mndeveci because you seem to be active. Looks like this issue might have gotten buried! Thanks for your help.
@c2tarun is there an update on the PM review? Is there a chance this feature will be implemented? Would be really good to have the possibility to mount volumes to, for example, emulate local EFS mounting.
I am interested in this feature because in the project I am working on there is a need to share files between lambdas executed as a part of one StepFunctions environment. When executed on AWS we use EFS for that.
But when testing functionality locally - there is no way (at least I'm not aware of it) to have a dir shared between different lambdas started by sam local start-lambda
For those running in devcontainer this solution worked for me
# get the host workspace path
host_workspace_path=$(docker inspect -f '{{ range .Mounts }}{{ if eq .Destination "/workspaces" }}{{ .Source }}{{ end }}{{ end }}' NAME_OR_ID)
# get the volume basedir
volume_basedir=$host_workspace_path/path-to-cdk-out
# now start sam local
sam local start-api --container-host host.docker.internal --docker-network NETWORK_NAME --docker-volume-basedir $volume_basedir
Describe your idea/feature/enhancement
Related to:
We use custom lambda container images. We run code in
/var/task/
or mount from EFS and run in/mnt/*
.We can't emulate the
/mnt
mount with SAM, or make changes to code mounted in/var/task
without a rebuild. This complicates dev - and makes dev impossible for builds with a big codebase.The lambda runtime emulator works but is very limited.
Is there a workaround?
Proposal
It would be great to emulate the behaviour of docker --mount, with an extra function param:
From the example below:
Additional Details
Example
foo.php
bootstrap
Dockerfile
template.yaml