4

I have sam initiated on local machine and below is the directory structure

 - application (python3 code)
 - efs (got some files)
 - template-local.yaml

Now, How do I tell sam local to start api with volume attachs.

I am running below command

sam local start-api \
  --template template-local.yaml \
  --docker-volume-basedir "/localmachine/project-folder/efs:/mnt/efs" \
  --profile otherAccount

The containers succesfully runs, but when I hit a request localhost:3000, then it crashes with below error

...
File "/usr/local/Cellar/aws-sam-cli/0.45.0/libexec/lib/python3.7/site-packages/docker/errors.py", line 31, in create_api_error_from_http_exception
    raise cls(e, response=response, explanation=explanation)
docker.errors.APIError: 500 Server Error: Internal Server Error ("invalid volume specification: '/localmachine/project-folder/efs/application:/var/task:ro,delegated'")
2020-06-22 20:52:04 127.0.0.1 - - [22/Jun/2020 20:52:04] "GET /status HTTP/1.1" 502 -

AWS SAM cli doc https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-cli-command-reference-sam-local-start-api.html doesnt give much details on volume mounting

Is there anything I am doing wrong.

Rafee
  • 3,975
  • 8
  • 58
  • 88

1 Answers1

3

Unfortunately there's no way to mount external volume on SAM. I'm trying to use this repo to build a docker with sam inside and try to mound and external volume

futurama92
  • 31
  • 4