[WIP] Run AWS Lambda functions created with Claudia.js locally.
This project is based on docker-lambda created by Michael Hart. Inspired by SAM Local.
If you have lambda.js file that looks like this:
exports.handler = function (event, context) {
context.succeed('hello world');
};You can run following command from the same directory:
claudia-local --handler lambda.handlerAnd result should look like this:
At the moment, this is more like a TODO list, than a list of features:
- Run AWS Lamda function on docker-lambda locally
- Simulate AWS Lambda memory
- Simulate AWS Lambda timeout
- Use selected IAM role
- Read claudia.json if it exists
- Patch the assume role policy to allow claudia-local to use selected role
- Event generator — generate JSON triggers for S3, SNS, etc.
- Simple HTTP server that simulates API Gateway
Running serverless projects and functions locally requires Docker to be installed and running.
To install docker visit:
- Mac: Docker for Mac
- Windows: Docker Toolbox
- Linux: Check your distro’s package manager (for example:
yum install docker)
Verify that docker is working, and that you can run docker commands from the CLI (for example: docker ps). You do not need to install/fetch/pull any containers, that will be done automatically.
TBA
If you want to run dev version, you'll need to:
- Clone this repository and enter the project folder
- Install the dependencies (
npm i) - Link the script (
npm link)
After that, claudia-local command will point to the local version of the code.
List of currently available arguments:
handler— specify handler function in formatfile_name.exported_name, for example if yourindex.jsfile usesmodule.handlerfor export, handler should beindex.handler.timeout— specify AWS Lambda timeout in seconds, default is 3, and it can be between 3 and 300 seconds.memory— specify AWS Lambda memory in MBs, default is 128, and it can be between 128 and 1536 (1.5 GB) in 64MB increments.runtime— specify AWS Lambda runtime, default isnodejs6.10, and it can benodejs6.10ornodejs4.3.event— [will change] specify JSON event that will be passed as AWS Lambda event. At the moment in--event '{"hello": "world"}'format.
