• Charly Prinsloo

Using Heroku connect with a RDS Postgres

On a recent project, I was tasked to use Heroku to synchronize data from an external system into salesforce. My initial thoughts were "Great!, I'll use Heroku Connect and it will be easy...". I then learned that the company has decided to use AWS RDS Postgres due to encryption requirements, and Heroku Connect no longer seemed like an easy option.

I couldn't find much on the net on how to do this, and it took a few days, but I succeeded and wanted to share my experience with you so that you can use it in your arsenal of integration tools.

Word of warning: Heroku does not support the use of RDS Postgres and it will become difficult to troubleshoot sync issues with the help of Heroku's support team if you do decide to use an AWS Postgres.

First, set up Heroku CLI

  • Install Heroku CLI.

  • The Heroku Command Line Interface (CLI), formerly known as the Heroku Toolbelt, is a tool for creating and managing Heroku apps from the command line / shell of various operating systems. Get all the info here

  • To verify your CLI installation use the heroku --version command

You will be asked to enter your Heroku credentials the first time you run a command; after the first time, your email address and an API token will be saved to ~/.netrc for future use.

  • Get your Heroku Auth token

  • ​You can display the token via the CLI: heroku auth:token

  • The output would be a 32 digit alphanumeric token like 24136b11-4722-4fad-a70d-31af31c205cf

Next, there are 5 steps you need o follow for this to work correctly:

  1. Create a user in SFDC for the Heroku integration, make sure you have the username and password

  2. Create an app in your Heroku account

  3. Add the Heroku Connect Add-on

  4. Set Database URL

  5. Add the Salesforce Connection

Sounds easy enough? Wrong. Here are the detailed steps:

1. Create a user in SFDC for the Heroku integration, make sure you have the username and password

Ok this was easy enough... let's move on

2. Create an app in your Heroku account

Ok this was also easy enough...

3. Add the Heroku Connect Add-on

This is where it gets tricky. Instead of using the UI to add the Heroku app, you need to use the CLI.

the command is:

heroku addons:create herokuconnect:demo --name {name-your-add-on} --app {specify-the-app-name}


heroku addons:create herokuconnect:demo --name heroku-connect-dev --app my-heroku-connect-rds-app

NOTE: if you have a paid account, use "danketsu" instead of "demo"

If all went well, you can refresh your Heroku dashboard and you will see the Heroku Connect add on installed.

4. Set Database URL

Next we need set the Database URL in Heroku Connect to the RDS database and we need to do this via the CLI too.

heroku config:add DATABASE_URL='postgres://{username}:{password}@{endpointURL}:{port}/{db-name}?sslmode=require&encrypt=true' --app {heroku-app-name}

The username, password, endpoint and db name are all parameters from your RDS database.


ENDPOINT: my-db-dev.c3bonfqedrgc.us-west-2.rds.amazonaws.com

USERNAME: masteruser

PORT: 5432

DB Name: dev

heroku config:add DATABASE_URL='postgres://masteruserr:myp@ssw0rd@my-db-dev.c6bonfqedrgc.us-west-22.rds.amazonaws.com:5432/dev?sslmode=require&encrypt=true' --app my-heroku-connect-rds-app


If you've done that right, you should see a success message:

IF you open the Heroku Connect App you will see the Connection is not yet setup

To set up the connection you need to use the Heroku APIs. I use postman.

In order to configure the new connection, you need to retrieve your app ID.

Use a GET to https://connect-us.heroku.com/api/v3/connections?app={your-app-name}, and specify 2 headers:

Content-Type = "application/json"

Authorization = bearer "your auth code you got earlier"

This will return all the info about your app, including the important app id we need to establish the connection.

With your id, you will now do a PATCH to https://connect-us.heroku.com/api/v3/connections/{app-id}.

In the body you need to specify the schema name and the db_key as DATABASE_URL.

Dont forget to set your headers!

(Content-Type = "application/json"

Authorization = bearer "your auth code you got earlier")

Once this is done successfully, you need to get back to your Heroku dashboard and resume the setup there. The hard part is over...

Continue the setup and you should now have Heroku Connect configured to a RDS Postgres.

#heroku #AWSRDSPostgress #herokuconnect #integration



All content copyright Charly Prinsloo © 2017 • All rights reserved.