| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
A Docker image to help with development of a local AWS lambda Python functions. Based on the lambci/lambda image. Created, because I haven't found an easy way to run lambda function locally.
Features:
Go to directory with your lambda Python code. Next, run this command:
docker run -it \
-p 8080:8080 \
-v lambda-packages-cache:/packages/ \ # if you want to persist packages cache
-v $PWD:/var/task/ \
valian/python-lambda-local-server
It should automatically install packages from your requirements.txt and start web sever written in aiohttp. To see web UI, head to http://localhost:8080. You should see a simple web UI for testing your lambda function.
Assuming that you have your lambda entrypoint in lambda.py and handler is named handler, you should type it into respective inputs. Next, add JSON body that should be passed to the function as an event, and press 'Submit event'. Result and logs should be visible on the right panel after a moment.
First, clone this repository:
git clone https://github.com/Valian/python-lambda-local-server
cd python-lambda-local-serverNext, start server with a proper volume mounted:
docker run -it \
-p 8080:8080 \
-v $PWD/example:/var/task/ \
valian/python-lambda-local-serverGo to http://localhost:8080. You should see something like this:
Specify file, handler and event and click Submit event. It invokes handler and prints execution logs and return value.
Api gateway tab automatically formats event to an AWS API Gateway format:

You can of course use curl to submit events. Start sever and type:
curl -XPOST localhost:8080 -d '{"event": {"url": "https://example.com"}, "file": "handler.handler"}'
{
"stdout": {
"statusCode": 200,
"url": "https://example.com/"
},
"stderr": "START RequestId: b1891caf-c22b-4ce6-8639-e74862adae30 Version: $LATEST\nINFO:root:Starting request\nINFO:root:Request done, status code: 200\nEND RequestId: b1891caf-c22b-4ce6-8639-e74862adae30\nREPORT RequestId: b1891caf-c22b-4ce6-8639-e74862adae30 Duration: 803 ms Billed Duration: 900 ms Memory Size: 1536 MB Max Memory Used: 23 MB\n"
}MIT
| Back | FazBrowse Home | New Git URL |