Configure a CloudSQL for PostgreSQL connector

You're viewing Apigee X documentation.
View Apigee Edge documentation.

The CloudSQL for PostgreSQL Connector type lets you insert, read, update and delete rows in a CloudSQL for PostgreSQL database and use the resulting output in an integration. This page provides a reference for configuring a CloudSQL for PostgreSQL connection and using the CloudSQL for PostgreSQL connection connection with Apigee Integration.

About Cloud SQL for PostgreSQL

CloudSQL for PostgreSQL is a fully-managed database service that helps you set up, maintain, manage, and administer your PostgreSQL relational databases on Google Cloud.

For a hands-on introduction, try one of the CloudSQL for PostgreSQL quickstarts.

Enable required services

Connectors requires that you enable the following Google services:

Name Title
apigee.googleapis.com Apigee API
secretmanager.googleapis.com Secret Manager API
connectors.googleapis.com Connector Platform API

If these services have not been enabled for your project previously, you will be prompted to enable them before using the Connectors UI.

If you are creating a CloudSQL for PostgreSQL connection, you must also enable the following API to administer your Cloud SQL instance:

Name Title
sqladmin.googleapis.com Cloud SQL Admin API

Create a CloudSQL for PostgreSQL connection

To configure a Connection:

  1. In the Cloud console, go to Apigee > Connectors page and select or create a Google Cloud project.

    Go to the Connections page

  2. Click + CREATE NEW to open the Create Connection page.
  3. Configure the connection:
    1. In the Create Connection section, complete the following:
      • Connector: Select the Connector type from the drop down list of available Connector types. For this example, select gcp > cloudsql-postgresql.
      • Connector version: Select the Connector version from the drop down list of available versions.
      • In the Connection Name field, enter a name for the Connection instance.

        Connection names must meet the following criteria:

        • Connection names can use letters, numbers, or hyphens.
        • Letters must be lower-case.
        • Connection names must begin with a letter and end with a letter or number.
        • Connection names cannot exceed 63 characters.
      • Optionally, add a Description of the connection instance.
      • Project ID: Enter the of the Google Cloud project where the CloudSQL for PostgreSQL instance resides.
      • Database Region: Enter the name of the region where the CloudSQL for PostgreSQL instance resides.
      • Instance ID: Enter the ID of the CloudSQL for PostgreSQL instance to connect with.
      • Database Name: Enter the name of the CloudSQL for PostgreSQL database to connect with.
      • Optionally, click + ADD LABEL to add a label to the Connection in the form of a key/value pair.
      • Click NEXT.
    2. Location: Choose the location for the connection.
      • Select a location where Apigee is available from the Region drop-down list.

        Supported regions for Connectors include:

        • us-central1
        • us-east1
        • us-west1
        • europe-west1
        • asia-east1
      • Click NEXT.
    3. Authentication: Provide authentication credentials for your connection instance, if required.

      For CloudSQL for PostgreSQL connections, you can provide credentials in the form of a User and Password combination.

      To configure authentication using a User and Password combination, enter the following information:

      • Username: Enter the CloudSQL for PostgreSQL username for the connection.
      • Password: Enter the Secret Manager secret containing the password associated with the CloudSQL for PostgreSQL username.
        • If you have previously created a secret, and it is not available in the drop down list, select DON'T SEE YOUR SECRET? ENTER SECRET RESOURCE ID to open the Add a secret by resource ID dialog as shown in the image below:

          Copy and paste the resource ID from Secret Manager

          • To use the latest version, copy and paste the resource ID from the parent secret, in the format: "projects/project-number/secrets/secret-name"
          • To select a specific version, copy and paste the resource ID for that specific version, in the format "projects/project-number/secrets/secret-name/versions/1"

          Click ADD SECRET to add the secret and close the dialog.

        • If you have not created a secret for use with CloudSQL for PostgreSQL , click ADD A NEW SECRET to open the Create Secret dialog, as shown in the image below:

          Enter the secret details:

          • Name: Enter the secret name.
          • Secret value: Enter the contents of the secret.
          • Optionally, click + ADD LABEL to add a label in the form of a key/value pair.
      • Secret version: Select the version of the Password secret from the list of available versions in the drop-down.
      • Click NEXT.
    4. Review: Review your connections's configuration details. In this section, the Connection details and Authentication details of the new connection are displayed for your review.
  4. Click Create.

Create a Connectors task with a CloudSQL for PostgreSQL connection

To configure the Publish to Pub/Sub Topic task:

  1. Go to the Apigee UI and sign in.
  2. Select your organization using the drop-down menu in the upper left corner of the UI.
  3. Click Develop > Integrations.
  4. Search for or select the integration to edit from the Integrations list and click to open the integration designer.
  5. Click +Add a task/trigger > Tasks to view the list of available tasks.
  6. Drag the Connectors element to the integration designer.
  7. Click the Connectors element on the designer to view the Connectors task configuration pane.
  8. Optionally, click the to edit the task name. This enables you to change the task name from the generic Connectors to a meaningful name for your integration.
  9. On the Configuration tab in the Configuration section, click the Configure task button to open the Configure connector task pane.
    1. In the Connection column, choose the CloudSQL for PostgreSQL connection you created in a previous step from the list of available connections.
    2. Once a connection is chosen, the Type column appears. Select either an Entity or Action from the list of available Entities and Actions.
      • An Entity can be thought of as an object, or a collection of properties, in the connected application or service, that can be exposed to an integration through the Connector interface.

        Selecting an Entity from the available list generates a list of available Operations that are available for the Entity.

        Select an Operation from the available list.

      • An Action is a first class function that is made available to the integration through the Connector interface. These functions are defined in the connected application or service and define a change or series of changes that can be made to an entity or entities.

        Select an Action from the available list.

    3. Click Done to complete the connection configuration and close the pane.
  10. The Connectors task configuration pane for a CloudSQL for PostgreSQL connection also displays Task Input variables and Task Output variable automatically generated by the Entity and Operation or Action selected in the previous step for use in the connection. These variables are configurable and are accessible as inputs to the current task or outputs to subsequent tasks or conditionals configured in the current integration.

    To configure the Task Input or Task Output:

    1. Click on the Connector input payload or Connector output payload variable pill to open the Configure Variable pane.
    2. Configure the JSON payload or default value as desired.
    3. Select the Use as an input to integration checkbox or the Use as an output to integration, as desired.
    4. Click Save.
  11. You can configure various retry strategies to handle errors in a task. The retry strategies allow you to specify how to rerun the task in case of an error. For more information, see Error handling strategies.