PostgreSQL

Use your existing PostgreSQL or dynamically create new one by following these guides:

Add dynamic PostgreSQL resource definition using Google CloudSQL

To provision PostgreSQL dynamically, add it as a Dynamic Resource Definition. The database will be provisioned during the deployment time and destroyed when its introductory Environment is deleted.

Prerequisites

  • You must have a Service Account with the Cloud SQL Client role.
  • You must create a key for this service account in JSON form. See Google’s account keys documentation for more information. The access key must use the GCP Console/gcloud format (i.e., the first example in the linked documentation).
  • You must have the CloudSQL Admin API enabled for your project.

1. Add a Google Cloud platform account

This guide explains how to connect PostgreSQL via Google Cloud Platform account. If you need to connect it using a different cloud provider, contact us at [email protected].

  1. Click the Profile icon in the top right.
  2. Click Organization Settings.
  3. Click on Dynamic resources tab.
  4. Select Google Cloud Platform. add-gcp-account
  5. Humanitec will ask you to provide an account name (a memorable name that will be displayed for this account) and a service account access key JSON (see prerequisites).
  6. Once you have added your account you will see the available Dynamic Resource Definitions.

gcp-account-added

2. Add PostgreSQL Dynamic Resource Definition

  1. In Organization settings, Dynamic Resource tab, click on your Google Cloud Platform Account that you want to use for adding your PostgreSQL.
  2. Click on PostgreSQL resource definition.
  3. Add a memorable ID for this Resource Definition and select a driver, here - cloudsql.
  4. Based on your resource driver, a form will be shown with the required driver parameters which will be passed to the driver on every resource creation. Add the values and click create.

add-dynamic-resource 5. Once created, the Resource Definition will appear in the list.

dynamic-resource-list 6. Assign your Resource Definition to an Environment Type.

dynamic-resource-to-env-type

Based on this Resource Definition, during the deployment on any of the matching environments, an Active Resource will be provisioned if required.

Add static PostgreSQL resource definition

  1. Log in to Humanitec.
  2. Click the Profile icon in the top right.
  3. Click Organization Settings.
  4. In Organization Settings page, click Static Resources.
  5. Click Postgres, which opens a dialog to define your Postgres as a static resource.
  6. Define an ID by which you will identify your resource definition
  7. Add Host, Database name and Port
  8. Provide password and username to allow Humanitec access your database.
  9. Click Create and it will appear in the list.
  10. Assign your Static Resource Definition to an Environment Type.

static-postgres-env-type

Based on this Static Resource Definition, during the deployment on any of the matching environments, the data required for the application to access the resource will be returned.