trailhead

Deploy an App and Provision a Heroku Postgres Database

Lightning bolt icon

Attention, Trailblazer!

Salesforce has two different desktop user interfaces: Lightning Experience and Salesforce Classic. This project is designed for Lightning Experience.

You can learn about switching between interfaces, enabling Lightning Experience, and more in the Lightning Experience Basics module here on Trailhead.

Introduction

Heroku is an app platform that provides everything necessary to deploy, run, manage, and scale applications—web applications, APIs, or RESTful microservices—using open source languages, such as Java, Ruby, PHP, Python, Go, and Node.js.

The Heroku developer experience is an app-centric approach for software delivery integrated with popular developer tools and workflows.

Heroku supports many popular programming languages. However, this quick start just uses Node. If you're familiar with programming in any of the other above-mentioned languages and with using a command-line interface on a shell terminal, you'll have no problem following along.

This quick start guides you through deploying an app, deploying add-ons such as Heroku Postgres, and using Heroku Connect, a Heroku add-on that syncs data from a Salesforce org to a Heroku Postgres database connected to the app.

Deploy an Application

Applications are usually deployed to Heroku using either Git, GitHub, Dropbox, or some continuous integration framework.

In this section, you'll kick-start your app development by deploying an app using Heroku Button, which automates much of the application deployment and setup.

  1. Navigate to https://signup.heroku.com and create a Heroku account.
  2. Deploy the sample Phone Change App by following the instructions after clicking this Heroku Button:
    Deploy to Heroku button image
    Note: If you see a dialog that says the GitHub repository is private, you can still access it by connecting your Heroku account to a GitHub account

    If you don't specify a name for the app, a unique name is generated, like shielded-harbor-5440.
  3. Select United States as the Region, then click Deploy App.

Note: Clicking the Heroku Button kicks off the deployment. Heroku fetches the source code for the application, gets any code dependencies for that application, and creates an application by running the code in a dyno, which is a managed container.

The application is immediately available at something like http://APP_NAME.herokuapp.com.

After the app has been deployed, you can manage it in the Heroku Dashboard by clicking the Manage App button and view the app by clicking the View button.

Deploy Finished

Provision the Heroku Postgres Add-On

Now you are going to deploy an add-on. Heroku add-ons are cloud services, such as databases, monitoring services, caching services, and queuing systems, that can be instantly provisioned for an application.

In this step, you provision a relational database by adding the Heroku Postgres add-on.

  1. Click the Manage App button to visit the Heroku Dashboard and click on your new application.
  2. Click the Resources tab.
  3. In the search area in the Add-ons section, type Heroku Postgres, click Enter, and then click Provision.

The simplicity and speed of this process hides the complexity of what you just did. With only a few clicks, you provisioned one of 150 add-on services, in this case, a relational database. The service is fully managed, is already running, and is now connected to your application.

Heroku typically connects a provisioned add-on to an application by setting a configuration variable that is available as a runtime environment variable within the application.

  1. Select the Settings tab.
  2. In the Config Variables section, click Reveal Config Vars and notice that the DATABASE_URL is now set.

Now that you have started setting up your Heroku app, in the next step we'll connect it to your Trailhead Playground org.

retargeting