We're looking to use localstack in our docker-compose environment. We have several projects which are triggered by SQS, and call other Lambdas depending on the message.
After reviewing the documentation we were looking to use the parameter LAMBDA_REMOTE_DOCKER, but we're unsure by what it actually does:
false: your Lambda function definitions will be passed to the container by mounting a volume (potentially faster). This requires to have the Docker client and the Docker host on the same machine.
Does this mean that we could mount volumes containing the lambda code to execute? Or does all lambdas need to be created via the cli or sdk?
Thanks for the help!
The initial lambda definition still has to be done via cli or sdk.
When lambda is defined on localstack, the code is saved to a temp dir (path will contain hash) inside localstack container.
Then when the function is invoked using docker, localstack decides how to to make the code in that temp dir available to the lambda container.
If LAMBDA_REMOTE_DOCKER is true then localstack uses docker create then docker cp.
If false then localstack mount the temp dir in lambda container by docker run -v.
So passed to the container by mounting a volume is referring to the internal working of localstack.
Having said that though, after you call api/sdk to define your lambda function, if you can get your hands on the temp dir then you can directly manipulate the lambda code without having to go thru api/sdk again to create lambda function again with the updated code.
Thanks for this question @Noah-Vivial , and thanks @shenie for providing a comprehensive answer! Hope that helps clarify things.
Let say I follow the following step:
1) Run a localstack-lambda container.
2) mounted the temp file path.
3) Added a function using awscli to the localstack-lambda.
4) delete the localstack-lambda container and rerun it, with volume mount to temp file
Will the function be present in the new container when I run the command aws lambda list-functions --endpoint-url=http://localhost:4574
Most helpful comment
The initial lambda definition still has to be done via cli or sdk.
When lambda is defined on localstack, the code is saved to a temp dir (path will contain hash) inside localstack container.
Then when the function is invoked using docker, localstack decides how to to make the code in that temp dir available to the lambda container.
If
LAMBDA_REMOTE_DOCKERis true then localstack usesdocker create then docker cp.If false then localstack mount the temp dir in lambda container by
docker run -v.So
passed to the container by mounting a volumeis referring to the internal working of localstack.Having said that though, after you call api/sdk to define your lambda function, if you can get your hands on the temp dir then you can directly manipulate the lambda code without having to go thru api/sdk again to create lambda function again with the updated code.