based off of jameshy/pgdump-aws-lambda
This repo has a companion Docker image that makes it easier to develop and test the lambda locally with the peace of mind that will work on AWS lambda service. It also allows you to create a bundle to be uploaded to AWS lambda service.
- Have Docker installed on your machine (for more instructions follow: https://docs.docker.com/docker-for-mac/install/)
- Create a environment variables file on the root of the project named
.env.localand populated using.envas a template.
$ docker-compose build
$ docker-compose up
$ EVENT='{"PGDATABASE":"<database>","PGUSER":"<user>","PGPASSWORD":"<password>","PGHOST":"<host>","S3_BUCKET":"<s3_bucket>","ROOT":"<s3_root_path>","EXCLUDE_TABLES": ["table_1", "table_2"]}'
$ curl -XPOST "http://localhost:8080/2015-03-31/functions/function/invocations" -d $EVENT
NOTE: EXCLUDE_TABLES is optional.
As of 25 Oct 2019, it is set to use PostgreSQL 11.4. If you need to upgrade it follow these steps:
- Change the
PG_VERSIONandpostgres_foldervalues ondocker-compose.yml - Change the folder location (
PGDUMP_PATH) underlib/config.js - Run
docker-compose build
-
Run the builder container (this step assumes you have already ran
docker-compose build)$ docker-compose run builder -
Deploy the
[pgdump-aws-lambda.zip](http://pgdump-aws-lambda.zip)that is located underdiston the desired lambda function.- Through the AWS console navigate to the lambda function > click the upload button and select the .zip file described above > click save
- More automated processes will come shortly