nipatiitti / custom-aws-lambda-image

Custom Docker image for AWS Lambda functions that supports local development

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Custom AWS lambda Docker image with hot reloading development enviroment

This project is an example and a starting point for creating a custom AWS lambda docker image with hot reloading development enviroment. The project uses aws-lambda-rie and aws-lambda-ric

Running

To make running this project easier there is a included docker-compose.yml file. To get started just run:

docker compose  -f "docker-compose.yml" up -d --build development

The dockerfile will install all the dependencies and run the custom package.json script that starts nodemon that watches for changes in ./function folder and restarts the rie and ric processes if needed.

IF YOU ADD NPM PACKAGES YOU NEED TO REBUILD THE DOCKER IMAGE

The compose file will mount the ./function folder to the container and expose the port 9000 for the rie to listen on. This enables you to make changes to the code and see the changes immediately. The api aws-lambda-rie uses is:

http://localhost:9000/2015-03-31/functions/function/invocations

You can test the api with curl:

curl -XPOST "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{"body": "test"}'

Testing

You can run the tests with the Development.Dockerfile using docker-compose with:

docker compose  -f "docker-compose.yml" up -d --build tests

Or without compose:

docker build -f Development.Dockerfile -t aws-custom-image .
docker run -it --rm --name aws-custom-image aws-custom-image ./entrypoint.test.sh

About

Custom Docker image for AWS Lambda functions that supports local development


Languages

Language:Dockerfile 53.1%Language:TypeScript 28.3%Language:Shell 18.6%