Objective
A demo to guide migration from Heroku Postgres to AWS RDS Postgres
Setup
1. Create Cloud9 instance
- Sign in to the AWS Management Console and open the Cloud9 console at https://ap-southeast-1.console.aws.amazon.com/cloud9/home
- Choose
Create environment
- Select
t3.small
instance type - Enter a name and choose
Next step
- Use default settings and choose
Next step
- Review settings and choose
Create environment
2. Configure cloud9 environment
- Create a terminal shell
- Beside the welcome tab, click
+
- Choose
New Terminal
- Run
git clone https://github.com/sebastianlzy/node-app-aws-heroku
- Run
. ./setup-helper/install-prerequisite.sh
3. Create a new RDS postgres 13 database in AWS
- Sign in to the AWS Management Console and open the RDS console at https://ap-southeast-1.console.aws.amazon.com/rds/home
- Choose
Create database
- Choose
Standard create
- Under Engine options
- For engine type, choose
PostgresSQL
- For version, choose
PostgresSQL 13.2-R1
- For engine type, choose
- Under Templates
- Choose Dev/Test
- Under Settings
- Enter
aws-rds-postgres
as "DB instance identifier" - Enter
postgres
as "username" - Enter a password for the "Master password"
- Enter the same password for "Confirm password"
- Enter
- Under DB instance class
- Choose
Burstable classes
, then selectdb.t3.micro
- Choose
- Leave the rest as default and choose
Create database
- Wait for database to be created
- Under connectivity & security
- Copy the Endpoint value
4. Migrate data from heroku:postgres database
- Sign in to Heroku and navigate to the app at https://dashboard.heroku.com/apps
- On the app, choose
Settings
- Under Config Vars, choose
Reveal Config Vars
- Copy the value for
DATABASE_URL
- Copy the value for
5. On cloud9 terminal
- export env variable
> export HEROKU_POSTGRES_URL= <Value copied from Heroku Postgres (Step 4.3.1)
> export RDS_POSTGRES_URL=<Value copied from AWS RDS Postgres (Step 3.10.1)>
> export RDS_POSTGRES_PASSWORD=<Value copied from AWS RDS Postgres (Step 6.3)>
- Download data from Heroku
- Run
pg_dump -v -Fc $HEROKU_POSTGRES_URL
- Run
- Restore data to AWS RDS
- Run
pg_restore -v -h $RDS_POSTGRES_URL -U postgres -d postgres < db.dmp
- Run