This repository is a Plug and Play template to create containerized AWS Lambda Functions. The documentation contains:
- Descriptions of the files
- Instructions to use the template
- Instructions to test the container locally
File Name | Description |
---|---|
Dockerfile |
The dockerfile used to create the docker image |
app.py |
The code that we want to run in lambda |
requirements.txt |
The dependencies required for our code to run |
- On every lambda trigger, the
handler
function in theapp.py
file will be executed. Plug the code into theapp.py
file and make calls to respective modules in thehandler
function. - Add the required dependencies to the
requirements.txt
file.
Step 01: Build the docker image of the lambda function
Run the following command in the directory with the Dockerfile
docker build --network=host -t lambda:v1 .
Check the container with the following command
docker images
Step 02: Run the lambda function container
Run the following command.
docker run --network=host --name=lambda lambda:v1
This will create the lambda function container. Now your container is up and running to process the invocation.
Step 03: Invoke your lambda function
From another terminal, please execute the below command.
curl -XPOST "http://localhost:8080/2015-03-31/functions/function/invocations" -d '{"test": "payload"}'
This should return a response similar to the following:
{"statusCode": 200, "requestId": "49f8b661-d119-4b54-ad19-ca7591860ef3", "request": {"test": "payload"}}
Author: Pranay Chandekar