# Update a GCP connector in Cloud Run with CLI

Periodically, you may need to update your Google Cloud connector to help maintain functionality, performance, and security.

This article explains how to update an existing connector deployed on Google Cloud Run using the CLI.

***

### Prerequisites

<table><thead><tr><th width="231.4296875">Item</th><th>Description</th></tr></thead><tbody><tr><td><strong>Apono token</strong></td><td><p>Account-specific Apono authentication value</p><p>Follow these steps to obtain your token:</p><ol><li>On the <a href="https://app.apono.io/connectors"><strong>Connectors</strong></a> page, click <strong>Install Connector</strong>. The <strong>Install Connector</strong> page appears.</li><li>Click <strong>GCP > Install and Connect GCP Project > CLI (Cloud Run)</strong>.</li><li>Copy the token in step listed on the page in step <strong>1</strong>.</li></ol><p><strong>NOTE</strong>: This value must be the same token that was used in the existing connector. You can also find the <code>APONO_TOKEN</code> on the <strong>YAML</strong> tab of your Cloud Run service in the GCP console.</p></td></tr><tr><td><strong>Google Cloud CLI</strong></td><td><a href="https://cloud.google.com/sdk/gcloud">Command-line interface</a> used to manage Google Cloud resources</td></tr><tr><td><strong>Google Cloud roles</strong></td><td><p><a href="https://cloud.google.com/iam/docs/roles-overview?sjid=2603002525407015039-NC#basic">Google Cloud role</a> that provides Owner permissions for the project or organization</p><p><strong>Project implementation role</strong>:</p><ul><li>Owner<br></li></ul><p><strong>Organization implementation roles</strong>:</p><ul><li>Owner</li><li>Organization Administrator</li></ul></td></tr><tr><td><strong>Google Cloud information</strong></td><td><p>Information for your Google Cloud instance</p><p>Google-defined values:</p><ul><li><strong>Organization ID</strong> (<code>GCP_ORGANIZATION_ID</code>): (For Organization connectors <strong>only</strong>) Unique identifier of your GCP organization</li><li><strong>Project ID</strong> (<code>GCP_PROJECT_ID</code>): (For Organization <strong>and</strong> Project connectors) Unique identifier of your GCP project where the Cloud Run service is running</li><li><strong>Location</strong> (<code>GCP_LOCATION</code>): Region where your Cloud Run service and artifact repository are located<br></li></ul><p>Customer-defined values:</p><ul><li><strong>Service account name</strong> (<code>SERVICE_ACCOUNT_NAME</code>): Name of the GCP service account used by the connector</li><li><strong>Artifact repository name</strong> (<code>GCP_ARTIFACT_REPOSITORY_NAME</code>): Name of your Docker-format GCP Artifact Registry</li><li><strong>Cloud Run service name</strong> (<code>GCP_CLOUDRUN_SERVICE_NAME</code>): Name of the Cloud Run service where the connector is deployed</li></ul><p>Apono-defined values:</p><ul><li><strong>Apono connector ID</strong> (<code>APONO_CONNECTOR_ID</code>): Unique identifier used when the connector was originally installed</li></ul><p><br><strong>NOTE</strong>: You can find all parameters above on the <strong>YAML</strong> tab of your Cloud Run service in the GCP console.</p></td></tr></tbody></table>

***

### Update a connector

To update an Apono connector on Google Cloud Run, follow these steps in your shell environment:

1. Log in to Google Cloud.

```bash
gcloud auth login
```

2. Set the environment variables.

{% hint style="info" %}
The `GCP_ORGANIZATION_ID` is **only** required for Organization connectors.
{% endhint %}

{% code overflow="wrap" %}

```bash
export GCP_ORGANIZATION_ID=<GOOGLE_ORGANIZATION_ID>
export GCP_PROJECT_ID=<GOOGLE_PROJECT_ID>
export SERVICE_ACCOUNT_NAME=<SERVICE_ACCOUNT_NAME>
export GCP_ARTIFACT_REPOSITORY_NAME=<ARTIFACT_REPOSITORY_NAME>
export GCP_CLOUDRUN_SERVICE_NAME=<CLOUDRUN_SERVICE_NAME>
export GCP_LOCATION=<GCP_LOCATION>
export APONO_TOKEN=<APONO_TOKEN>
export APONO_CONNECTOR_ID=<APONO_CONNECTOR_ID>
```

{% endcode %}

3. Authenticate with the Apono Docker registry.

{% code overflow="wrap" %}

```bash
docker login registry.apono.io -u apono --password $APONO_TOKEN
```

{% endcode %}

4. Pull and tag the latest connector image.

{% code overflow="wrap" %}

```bash
docker pull --platform linux/amd64 registry.apono.io/apono-connector:v1.7.8

export IMAGE_PATH=$GCP_LOCATION-docker.pkg.dev/$GCP_PROJECT_ID/$GCP_ARTIFACT_REPOSITORY_NAME/registry.apono.io/apono-connector:v1.7.8

echo $IMAGE_PATH

docker image tag registry.apono.io/apono-connector:v1.7.8 $IMAGE_PATH
```

{% endcode %}

5. Configure Docker for your GCP region.

{% code overflow="wrap" %}

```bash
gcloud auth configure-docker $GCP_LOCATION-docker.pkg.dev
```

{% endcode %}

6. Push the image to GCP Artifact Registry.

{% code overflow="wrap" %}

```bash
docker push $IMAGE_PATH
```

{% endcode %}

7. Deploy the updated image to Cloud Run.

{% code overflow="wrap" %}

```bash
gcloud run deploy "$GCP_CLOUDRUN_SERVICE_NAME" \
  --image "$IMAGE_PATH" \
  --region="$GCP_LOCATION" \
  --allow-unauthenticated \
  --max-instances=1 \
  --min-instances=1 \
  --cpu=1 \
  --memory=2Gi \
  --no-cpu-throttling \
  --service-account "$SERVICE_ACCOUNT_NAME" \
  --update-env-vars \
  APONO_CONNECTOR_ID="$APONO_CONNECTOR_ID",APONO_TOKEN="$APONO_TOKEN",APONO_URL=api.apono.io
```

{% endcode %}

8. On the [**Connectors**](https://app.apono.io/connectors) page in the Apono UI, verify that the connector is updated.
