This is the source code for my Deploying an Express Application to AWS Lambda, the easy way post, where I show how to deploy an existing Express app to AWS Lambda.
-
Install Node.js (v4.3.2 preferred) & yarn
-
Run
yarnto install project dependencies -
Create a local postgres database (v9.5.4 preferred)
psql -c "CREATE ROLE todo_user LOGIN PASSWORD 'todo_password' SUPERUSER;" template1
psql -c "CREATE DATABASE "todo" WITH OWNER todo_user;" template1
- Create your .env.yml file:
cp .env.example.yml .env.yml
If you used different DB credentials, modify the DATABASE_URL value
- Run your database migrations:
npm run db:migrate:dev
- Start the app:
npm start
- Edit your
.env.ymlfile:
- replace
accessKeyIdandsecretAccessKeywith your AWS keys (you can get AWS Keys by following this guide: https://serverless.com/framework/docs/providers/aws/setup/). - replace
DATABASE_URLforstagingandproductionenvironments (you can provision free postgres databases on https://postgres.heroku.com/databases)
- Run
npm run deploy:stagingornpm run deploy:prodto deploy your changes
This app uses massive.js instead of a full-blown ORM. PostgreSQL is amazing, why not use all of its potential?
PostgreSQL CheatSheet
Connect to postgres: psql DATABASE_URL
Toggle expanded display: \x
Show available tables: \dt+
Show details for a table: \d+ table_name
Show available functions \df
Show details for a function: \df+ function_name or \ef function_name