- node
- postgres
- AWS account
- aws-cli
Make sure your lambda user can have access to VPC. You should also have postgres user named postgres.
aws configure
git clone https://github.com/mathieux51/sls-pg.git
npm install
npm startnpm run db:migrateTo see postgres logs we need to enable it:
psql postgres
# In psql:
show config_file;
show data_directory;Edit config_file:
logging_collector = on
log_statement = 'all'Restart postgres and you should see your logs in data_directory/log.
Create on postgres instance on AWS. Update:
.env.developmentserverless.yml
npm run db:backup:create
# or
pg_dump -U postgres slspgdb -Fc > backup.dumpnpm run db:backup:restore
# or
dropdb slspgdb --if-exists
createdb slspgdb -O postgres
PGPASSWORD='' pg_restore -Fc --no-acl --no-owner -U postgres -d slspgdb backup.dump
# Test if books table is populated
psql slspgdb postgres -c "select * from books;"