This tutorial describes how to automate promoting an integration between different environments in different Google Cloud projects using [config variables](https://docs.cloud.google.com/application-integration/docs/variables#config_var).
**Note:** You cannot use config variables to configure entity operations and actions for connectors.

> [!TIP]
> **Tip:** To learn how to store integration and connector assets to a source code repository, promote changes across environments, and how such deployments can be automated, see the [CICD for Application Integration](https://www.googlecloudcommunity.com/gc/Cloud-Product-Articles/CI-CD-for-Application-Integration/ta-p/722811) blog.

## 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.

<br />

## 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:

- [Application Integration](https://docs.cloud.google.com/application-integration/docs/pricing)
- [Integration Connectors](https://docs.cloud.google.com/integration-connectors/docs/pricing)

The instructions in this tutorial are designed to keep your resource usage within the limits of Google Cloud [Free cloud features and trial offer](https://docs.cloud.google.com/free/docs/free-cloud-features).


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](https://docs.cloud.google.com/application-integration/docs/build-cicd#clean-up).

<br />

## Before you begin

## Create a Pub/Sub topic

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

   [Go to Topics](https://console.cloud.google.com/cloudpubsub/topic)
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.](https://docs.cloud.google.com/pubsub/docs/pubsub-basics#resource_names)

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](https://console.cloud.google.com/), go to the **Integration Connectors \> Connections** page and then select or create a Google Cloud project.


   [Go to the Connections page](https://console.cloud.google.com/connectors/connections)
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](https://docs.cloud.google.com/integration-connectors/docs/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](https://docs.cloud.google.com/application-integration/docs/build-cicd#before-you-begin).
   5. **Project ID**: Google Cloud project ID where the Pub/Sub instance resides.
   6. **Topic ID** : Enter the name of your [Pub/Sub topic](https://docs.cloud.google.com/application-integration/docs/build-cicd#create-a-pubsub-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](https://console.cloud.google.com/integrations)
2. Click **Integrations** from the left navigation menu to open the **Integrations** page.
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](https://docs.cloud.google.com/application-integration/docs/enable-new-region#provision-new-region). To see a list of supported regions, see [Application Integration locations](https://docs.cloud.google.com/application-integration/docs/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](https://docs.cloud.google.com/application-integration/docs/enable-new-region#edit-region).
   5. Click **Create** . This opens the integration editor page in which you can add the [tasks](https://docs.cloud.google.com/application-integration/docs/tasks) and the [triggers](https://docs.cloud.google.com/application-integration/docs/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](https://console.cloud.google.com/integrations)
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](https://docs.cloud.google.com/application-integration/docs/upload-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](https://docs.cloud.google.com/application-integration/docs/build-cicd#create-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](https://docs.cloud.google.com/application-integration/docs/build-cicd#create-pub-sub-connector).
3. Click **Publish**.
4. Upon successfully publishing your integration, you can view and inspect the [execution logs](https://docs.cloud.google.com/application-integration/docs/integration-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](https://docs.cloud.google.com/application-integration/docs/reference/rest) and [Integration Connectors APIs](https://docs.cloud.google.com/integration-connectors/docs/reference/rest). 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`](https://www.googlecloudcommunity.com/gc/Cloud-Product-Articles/CI-CD-for-Application-Integration/ta-p/722811#toc-hId--834912134) 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](https://www.googlecloudcommunity.com/gc/Cloud-Product-Articles/CI-CD-for-Application-Integration/ta-p/722811#toc-hId--1425956340).

If you don't want to use `integrationcli`, you can manually [download and upload the integration](https://docs.cloud.google.com/application-integration/docs/upload-download-integrations) 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

- Explore [sample integrations](https://github.com/GoogleCloudPlatform/application-integration-samples) in GitHub.
- Learn more about [config variables](https://docs.cloud.google.com/application-integration/docs/variables).
- Learn more about the [`integrationcli`](https://github.com/GoogleCloudPlatform/application-integration-management-toolkit) tool.