Build CICD for your integration


This tutorial describes how to automate promoting an integration between different environments in different Google Cloud projects using config variables (preview).

Overview

In this tutorial, you'll automate Application Integration deployments using config variable for a sample integration. This sample integration flow calls an API and publishes the response from the API to a Pub/Sub topic. This sample is meant to illustrate the use of Call REST Endpoint and Connectors tasks. You can store the sample integration in GitHub repositories that correspond to the different environments and Google Cloud projects.

Objectives

This tutorial shows you how to complete the following tasks in your integration:

  • Create an integration.
  • Create config variables and use them in your integration.
  • Promote your integration to another environment.

Costs

In this tutorial, you use the following billable components of Google Cloud:

The instructions in this tutorial are designed to keep your resource usage within the limits of Google Cloud Free cloud features and trial offer.

When you finish the tasks that are described in this document, you can avoid continued billing by deleting the resources that you created. For more information, see Clean up.

Before you begin

  1. Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
  2. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Go to project selector

  3. Make sure that billing is enabled for your Google Cloud project.

  4. Enable the Secret Manager API, Connectors API APIs.

    Enable the APIs

  5. Create a service account:

    1. In the Google Cloud console, go to the Create service account page.

      Go to Create service account
    2. Select your project.
    3. In the Service account name field, enter a name. The Google Cloud console fills in the Service account ID field based on this name.

      In the Service account description field, enter a description. For example, Service account for quickstart.

    4. Click Create and continue.
    5. Grant the Pub/Sub Publisher (roles/pubsub.publisher) role to the service account.

      To grant the role, find the Select a role list, then select Pub/Sub Publisher (roles/pubsub.publisher).

    6. Click Continue.
    7. Click Done to finish creating the service account.

  6. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Go to project selector

  7. Make sure that billing is enabled for your Google Cloud project.

  8. Enable the Secret Manager API, Connectors API APIs.

    Enable the APIs

  9. Create a service account:

    1. In the Google Cloud console, go to the Create service account page.

      Go to Create service account
    2. Select your project.
    3. In the Service account name field, enter a name. The Google Cloud console fills in the Service account ID field based on this name.

      In the Service account description field, enter a description. For example, Service account for quickstart.

    4. Click Create and continue.
    5. Grant the Pub/Sub Publisher (roles/pubsub.publisher) role to the service account.

      To grant the role, find the Select a role list, then select Pub/Sub Publisher (roles/pubsub.publisher).

    6. Click Continue.
    7. Click Done to finish creating the service account.

Create a Pub/Sub topic

  1. In the Google Cloud console, go to the Pub/Sub Topics page.

    Go to Topics

  2. Click Create topic.

  3. In the Topic ID field, enter an ID for your topic. For more information about naming topics, see Guidelines to name a topic, subscription, schema, or snapshot.

  4. Retain the option Add a default subscription.

  5. Do not select the other options.

  6. Click Create topic.

Configure a Pub/Sub connector

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

    Go to the Connections page

  2. Click + Create New to open the Create Connection page.
  3. In the Location section, choose the location for the connection.
    1. Region: Select a location from the drop-down list.

      For the list of all the supported regions, see Locations.

    2. Click NEXT.
  4. In the Connection Details section, complete the following:
    1. Connector: Select Pub/Sub from the drop down list of available Connectors.
    2. Connector version: Select the Connector version from the drop down list of available versions.
    3. In the Connection Name field, enter pub-sub-connector.
    4. Service Account: Select a service account that has the required roles.
    5. Project ID: Google Cloud project ID where the Pub/Sub instance resides.
    6. Topic ID: Enter the name of your Pub/Sub topic.
    7. Click Next.
  5. In the Authentication section, click NEXT.
  6. Review: Review your connection and authentication details.
  7. Click Create.

Create a new integration

After you Set up Application Integration, you can create a new integration:

  1. In the Google Cloud console, go to the Application Integration page.

    Go to Application Integration

  2. In the navigation menu, click Integrations. The Integrations List page appears.
  3. Click Create integration and provide the following details in the Create Integration page:
    1. Integration name: Enter a name for your integration. For example, build-cicd.
    2. Description: Optionally, enter a description for your integration. For example, Demo integration created for CICD tutorial.
    3. Region: Select the region us-central1 from the list of provisioned regions. If the region that you want to select is not provision, see Provision a new region. To see a list of supported regions, see Application Integration locations.
    4. Service account: This field appears if you have enabled governance for your region. Select the service account for your integration. To learn how to enable governance for your region, see Edit region.
    5. Click Create. This opens the integration editor page in which you can add the tasks and the triggers to build your integration.

Create an integration flow

Add an API trigger and a Call REST Endpoint

To add an API trigger trigger, perform the following steps:
  1. In the Google Cloud console, go to the Application Integration page.

    Go to Application Integration

  2. In the navigation menu, click Integrations

    The Integrations List page appears listing all the integrations available in the Google Cloud project.

  3. Select the build-cicd integration.

    This opens the integration in the integration editor.

  4. In the integration editor navigation bar, click Triggers > API Trigger to add the trigger.
  5. In the integration editor navigation bar, click Tasks > Call REST Endpoint to add the task.
  6. Add an edge connection from the API trigger element to the Call REST Endpoint element by hovering over a control point on the API trigger element, then clicking and dragging a line to a control point on the Call REST Endpoint task element.

Create config variables

To create config variables, follow these steps:
  1. In the integration editor navigation bar, click (Toggle panel) to bring up the Variables pane.
  2. Click +Create.
  3. Do the following in the Create Variable pane:
    1. For Name, enter url.

      Application Integration adds `CONFIG_ prefix to the config variables. If you want to add the config variable to your integration using APIs, use the following format for config variables: `CONFIG_CONFIG_VARIABLE_NAME`. For information about how to download and upload integrations, see Upload and download integrations.

    2. For Variable type, select Config Variable.
    3. For Data type, select String.
    4. Click Create.

      The config variable appears in the Variables pane.

  4. Repeat Step 2 and 3 to add the following config variable:
    • Name: connection_name
    • Variable type: Config Variable
    • Data type: String

Add and configure Call REST Endpoint

To create a config variable, follow these steps:
  1. In the integration editor, click the Call REST Endpoint task to open the task configuration pane. Then, do the following:
    1. Expand the Task input section.
    2. In the Endpoint base URL click Variable and add $`CONFIG_url`$.

Add and configure a Connectors task

  1. In the integration editor navigation bar, click Task > Connectors.
  2. Click Configure Connectors.
  3. From the Region list, select the region where you created your Pub/Sub connector.
  4. In the Connection field, select the Pub/Sub connector that you created in the preceding step.
  5. In the Type section, select Actions.
  6. In the Set entities/actions section, for Actions, select publishMessage.
  7. In the Default value, add the default value for the config variable.
  8. Click Create.
  9. In the Connectors task configuration pane, expand the Connection details section to update the following field:
    1. In the Connection name field, click Variable and select $`CONFIG_connection_name`$.

Add a Data Mapping task

  1. In the integration editor navigation bar, click Task > Data mapping.
  2. Add an edge connection from the Call REST Endpoint element to the Data Mapping element by hovering over a control point on the Call REST Endpoint element, then clicking and dragging a line to a control point on the Data Mapping task element.
  3. Add another edge connection from the Data Mapping element to the Connectors element by hovering over a control point on the Data Mapping element, then clicking and dragging a line to a control point on the Connectors task element.
  4. In the Data Mapping task configuration pane, click Open Data Mapping Editor.
  5. Map the output variable of the Call REST Endpoint task to the input variable of the Connectors task.

Publish the integration

To publish the integration, follow these steps:
  1. To publish the integration click Publish in the integration editor toolbar.

    The Publish integration dialog appears.

  2. In the Publish integration dialog, enter the value for the following config variables:
    1. url: Enter the name of the endpoint URL.
    2. connection_name: Enter the name of the Pub/Sub connector that you created in the preceding step.
  3. Click Publish.
  4. Upon successfully publishing your integration, you can view and inspect the execution logs of the published integration. To view logs, click Logs in the toolbar of the integration editor.

Promote integration across environments

To promote your integration across environments, you can use the integrationcli tool, which is an open-source tool that lets you interact with Application Integration APIs and Integration Connectors APIs. This tool lets you manage integration entities such as integrations, auth configs, and so on. For information about how to generate the scaffold for the integration and apply the changes generated by the scaffold, see Introduction to integrationcli in the community blog.

You can also promote changes across environments by setting up DevOps pipelines for example, by using Jenkins, GitLab, Cloud Build, and so on. For more information, see Integration with Cloud Build.

If you don't want to use integrationcli, you can manually download and upload the integration to a new project. You'll have to create the connectors in the new project manually as they are currently not downloadable. When you publish the integration in the new environment, Application Integration enables you to enter values for the config variables.

What's next