---
title: Connect Google Vertex AI to AI Runtime Control with Google Cloud IAM
summary: >-
  Use AI Runtime Control (ARC) to call models on Google Vertex AI without
  storing long-lived Google Cloud credentials by allowing ARC to impersonate a
  service account in your Google Cloud project through workload identity
  federation.
url: >-
  https://www.fastly.com/documentation/solutions/tutorials/ai-runtime-control/connect-google-vertex-ai-to-arc-with-google-cloud-iam
---

In this tutorial, you'll connect Google Vertex AI to AI Runtime Control (ARC) using Google Cloud IAM authentication. Instead of giving ARC an API key or a service account key, you'll set up workload identity federation in your Google Cloud project so that ARC can impersonate a service account, give that service account permission to call Vertex AI models, and send a test request through ARC to confirm everything works.

By the end, you'll understand how the workload identity pool, the pool provider, and the service account work together, and where to look when a request is denied.

Every resource you create in this tutorial is new and used only by ARC, so nothing already in your project changes. If you only want to try out the connection, you can also [make it temporary](https://www.fastly.com/documentation/solutions/tutorials/ai-runtime-control/connect-google-vertex-ai-to-arc-with-google-cloud-iam#making-the-connection-temporary) and remove everything when you're done.

> **NOTE:** 
>
> This article describes how to configure an integration with a service provided by a third party. As stated in our [Terms of Service](https://www.fastly.com/terms), we do not provide direct support for non-Fastly services.
>
>

## Before you begin

This tutorial assumes you already have access to ARC and have completed the steps to get started using it. You'll also need the following:

- The [Superuser role](https://www.fastly.com/documentation/guides/organizations-and-accounts/account-members-and-permissions/about-user-roles-and-permissions/). Other account roles can't access ARC.
- Access to a [Google Cloud](https://docs.cloud.google.com/) project with permission to create workload identity pools, create service accounts, and grant IAM roles. The Workload Identity Pool Admin, Service Account Admin, and Project IAM Admin roles cover these tasks.
- [Cloud Shell](https://docs.cloud.google.com/shell/docs) in the Google Cloud console, open to that project. Cloud Shell has the Google Cloud CLI (`gcloud`) installed and signed in.
- Access to gemini-4-argon. Some partner models, including Anthropic models, must be enabled in [Vertex AI Model Garden](https://cloud.google.com/model-garden) before you can call them.

## Why use Google Cloud IAM

With Google Cloud IAM, ARC never holds a long-lived Google Cloud credential. When ARC needs to call Vertex AI, it presents a short-lived token signed by Fastly to Google Cloud's Security Token Service, which checks that token against the workload identity pool provider in your project. If the token passes, ARC receives temporary credentials that let it act as your service account. You stay in control from your own Google Cloud project, and you can change the service account's permissions or revoke ARC's access at any time without touching ARC.

Three pieces in your project make this work:

- The **workload identity pool provider** controls which tokens your project accepts. Yours will trust Fastly's OIDC issuer, and only tokens that carry your Fastly customer ID.
- The **service account** controls what ARC can do in your project. Yours will be allowed to call Vertex AI models.
- The **Workload Identity User** role binding on the service account connects the two. It allows identities from your pool to impersonate the service account.

Most setup problems come from one of these three pieces, so it helps to keep them separate as you go.

## Step 1: Start adding the provider in ARC

Start in ARC, because it generates the values you'll need in Google Cloud.

1.   Log in to the [Fastly control panel](https://manage.fastly.com).

2. Go to **Tools** > **AI Runtime Control**.
3. Click the **Providers** tab.
4. Click **Add**, then select **Google Vertex AI**.
5. For **Authentication type**, select **Google Cloud IAM**. ARC displays an **OIDC issuer URL**, an **Audience**, and a **Customer ID**.
6. Click the clipboard <span class="inline-icons"><img src="https://www.fastly.com/documentation/img/icons/clipboard.png" alt="Clipboard icon" /></span> next to each value and paste them somewhere you can copy from later.

Keep this page open. You'll come back to it in Step 5.

## Step 2: Set up your Google Cloud project

Next, set the values you'll reuse in the rest of this tutorial as shell variables, and enable the APIs that workload identity federation and Vertex AI depend on. We'll use `fastly-arc-pool` for the workload identity pool, `fastly-arc-oidc` for the pool provider, and `fastly-arc` for the service account so that their purpose is clear later.

> **HINT:** You can choose other IDs, but pool and provider IDs must be 4 to 32 characters long. You can only use lowercase letters, digits, and hyphens. It also needs to start with a letter and can't start with `gcp-`.

1. Set your project and the values you copied from ARC:

   ```term copy
   $ export PROJECT_ID="your-project-id"
   $ export PROJECT_NUMBER="$(gcloud projects describe "$PROJECT_ID" --format='value(projectNumber)')"
   $ export ARC_ISSUER_URL=""
   $ export ARC_AUDIENCE=""
   $ export ARC_CUSTOMER_ID=""
   $ export POOL_ID="fastly-arc-pool"
   $ export PROVIDER_ID="fastly-arc-oidc"
   $ export SA_NAME="fastly-arc"
   $ export SA_EMAIL="${SA_NAME}@${PROJECT_ID}.iam.gserviceaccount.com"
   ```

2. Enable the required APIs:

   ```term copy
   $ gcloud services enable \
       aiplatform.googleapis.com \
       iam.googleapis.com \
       iamcredentials.googleapis.com \
       sts.googleapis.com \
       --project="$PROJECT_ID"
   ```

## Step 3: Create the workload identity pool and provider

Now create a workload identity pool and an OIDC provider in it that accepts tokens only from ARC, and only when they carry your customer ID.

1. Create the workload identity pool:

   ```term copy
   $ gcloud iam workload-identity-pools create "$POOL_ID" \
       --project="$PROJECT_ID" \
       --location="global" \
       --display-name="Fastly AI Runtime Control"
   ```

2. Create the OIDC provider in the pool:

   ```term copy
   $ gcloud iam workload-identity-pools providers create-oidc "$PROVIDER_ID" \
       --project="$PROJECT_ID" \
       --location="global" \
       --workload-identity-pool="$POOL_ID" \
       --issuer-uri="$ARC_ISSUER_URL" \
       --allowed-audiences="$ARC_AUDIENCE" \
       --attribute-mapping="google.subject=assertion.sub,attribute.customer_id=assertion.customer_id" \
       --attribute-condition="assertion.customer_id == '${ARC_CUSTOMER_ID}'"
   ```

Here's what each setting does:

- `--issuer-uri` tells Google Cloud to accept tokens signed by Fastly's OIDC issuer.
- `--allowed-audiences` tells Google Cloud to accept only tokens that ARC requested for this purpose.
- `--attribute-mapping` copies claims from the token into attributes you can refer to in IAM policies. `attribute.customer_id` is used in Step 4.
- `--attribute-condition` rejects any token that doesn't carry your customer ID. Without it, the provider would accept a token ARC issued for any Fastly customer.

> **IMPORTANT:** Always set the attribute condition. The issuer and audience are the same for every ARC customer, so the customer ID is what limits access to your account.

Confirm the provider was created with your attribute condition:

```term copy
$ gcloud iam workload-identity-pools providers describe "$PROVIDER_ID" \
    --project="$PROJECT_ID" \
    --location="global" \
    --workload-identity-pool="$POOL_ID" \
    --format="value(attributeCondition)"
```

The output should show your customer ID.

## Step 4: Create the service account and give it access

Next, create the service account that ARC will impersonate, give it permission to call Vertex AI, and allow identities from your pool to impersonate it.

1. Create the service account:

   ```term copy
   $ gcloud iam service-accounts create "$SA_NAME" \
       --project="$PROJECT_ID" \
       --display-name="Fastly AI Runtime Control"
   ```

2. Grant the service account the Vertex AI User role on your project:

   ```term copy
   $ gcloud projects add-iam-policy-binding "$PROJECT_ID" \
       --member="serviceAccount:${SA_EMAIL}" \
       --role="roles/aiplatform.user"
   ```

3. Allow identities from your pool that carry your customer ID to impersonate the service account:

   ```term copy
   $ gcloud iam service-accounts add-iam-policy-binding "$SA_EMAIL" \
       --project="$PROJECT_ID" \
       --role="roles/iam.workloadIdentityUser" \
       --member="principalSet://iam.googleapis.com/projects/${PROJECT_NUMBER}/locations/global/workloadIdentityPools/${POOL_ID}/attribute.customer_id/${ARC_CUSTOMER_ID}"
   ```

4. Confirm the impersonation binding:

   ```term copy
   $ gcloud iam service-accounts get-iam-policy "$SA_EMAIL" \
       --project="$PROJECT_ID"
   ```

   The output should list `roles/iam.workloadIdentityUser` with a `principalSet://` member that ends in your customer ID.

5. Print the values you'll need in ARC:

   ```term copy
   $ echo "Project ID: $PROJECT_ID"
   $ echo "Project number: $PROJECT_NUMBER"
   $ echo "Workload identity pool ID: $POOL_ID"
   $ echo "Workload provider ID: $PROVIDER_ID"
   $ echo "Service account email: $SA_EMAIL"
   ```

## Step 5: Finish adding the provider in ARC

Return to the ARC page you left open in Step 1.

1. Fill out the fields using the values you printed in Step 4:
   - In the **Project ID** field, enter your Google Cloud project ID.
   - In the **Project number** field, enter your Google Cloud project number.
   - In the **Workload identity pool ID** field, enter `fastly-arc-pool`.
   - In the **Workload provider ID** field, enter `fastly-arc-oidc`.
   - In the **Service account email** field, enter the email address of the service account you created.
   - In the **Region** field, enter `global`.
2. Under **Model permissions**, select **Limit model access**, then select Gemini 4 Argon.
3. Click **Save**. The new provider appears on the Providers tab.

> **IMPORTANT:** The region in ARC must be a region where your models are available. If it isn't, ARC can authenticate to your project, but model requests will fail.

## Step 6: Create a virtual key

Create a virtual key that routes requests to your new provider:

1. Click the **Virtual keys** tab.
2. Click **Add key**.
3. In the **Key name** field, enter `vertex-ai-test`.
4. From the **Select provider** menu in the **Provider Routing & Failover** area, select the Google Vertex AI provider you created in Step 5.
5. In the **Expiration** area, select **Never expires**.
6. Click **Add virtual key**. ARC displays the key value.
7. Click **Copy key**. This is the only time ARC shows the key, so keep it somewhere secure until you use it in Step 7.

## Step 7: Send a test request

IAM changes can take a few minutes to take effect. If your first request fails with a permission error, wait a few minutes and try again before troubleshooting.

Send a request to Gemini 4 Argon, the model you allowed on the provider in Step 5.

1. Store your virtual key in an environment variable. This command prompts for the key without displaying it or saving it to your shell history. Paste your key and press Enter.

   ```term copy
   $ read -rs ARC_API_KEY && export ARC_API_KEY
   ```

2. Send the request:

   ```term copy
   $ curl -i "https://arc.fastly.app/v1/chat/completions" \
       -H "Authorization: Bearer $ARC_API_KEY" \
       -H "Content-Type: application/json" \
       -d '{
         "model": "gemini-4-argon",
         "messages": [
           {"role": "user", "content": "Say hello and tell me which model you are."}
         ],
         "max_tokens": 100
       }'
   ```

A `200` response with the model's reply means your setup is complete. The response should look similar to this:

```term
HTTP/2 200
content-type: application/json

{
  "object": "chat.completion",
  "model": "gemini-4-argon",
  "choices": [
    {
      "index": 0,
      "finish_reason": "stop",
      "message": {
        "role": "assistant",
        "content": "Hello! I'm Gemini, a model made by Google."
      }
    }
  ],
  ...
}
```

To send requests from your application instead of curl, point your client at ARC and use the virtual key you created in Step 6 as the API key. For examples using common SDKs, check out [Connecting clients to AI Runtime Control](https://www.fastly.com/documentation/guides/platform/ai-runtime-control/connecting-clients-to-arc/).

## Troubleshooting

When a request fails, the error message usually indicates whether the error originated from Google Cloud or ARC. Use the error message to find the cause:

- **The audience doesn't match.** Google Cloud rejected the token because the provider's allowed audience doesn't match. Check that `--allowed-audiences` is set to the **Audience** value from ARC.
- **The credential is rejected by the attribute condition.** The token doesn't satisfy your provider's attribute condition. Check that the condition uses the exact **Customer ID** from ARC.
- **Permission `iam.serviceAccounts.getAccessToken` is denied.** ARC authenticated to your pool but isn't allowed to impersonate the service account. Check the Workload Identity User role binding from Step 4, including the project number, pool ID, and customer ID in the member.
- **A permission such as `aiplatform.endpoints.predict` is denied.** ARC is impersonating your service account, but the service account isn't allowed to call Vertex AI. Check that it has the Vertex AI User role on the project.
- **An API hasn't been used in the project or is disabled.** One of the required APIs isn't enabled. Enable the API named in the error.
- **The model isn't found, or the project doesn't have access to it.** The model isn't available in the region you set in ARC, or it hasn't been enabled in Model Garden.

## Adapting this setup

This tutorial made several choices for you so that you could get to a working connection quickly. Now that you've seen how the pieces fit together, you can adapt the setup for your own environment. The simplest change is using your own resource IDs: change the values you export in Step 2, and enter the matching pool and provider IDs in Step 5. Beyond that, here's how you might change other parts of the setup.

### Running commands from your own terminal

This tutorial used Cloud Shell because it comes with `gcloud` installed and signed in. If you'd rather work locally, for example to keep these commands in a script alongside your other infrastructure setup, install the [Google Cloud CLI](https://cloud.google.com/sdk/docs/install), sign in with `gcloud auth login`, and run the same commands. If you manage Google Cloud with an infrastructure-as-code tool, you can create the same pool, provider, service account, and role bindings there instead. Just make sure the provider definition includes the attribute condition.

### Allowing more models

This tutorial limited the provider to a single model so that the test request had a known result. To make more models available, [edit the provider](https://www.fastly.com/documentation/guides/platform/ai-runtime-control/managing-providers/#editing-a-provider)'s model permissions in ARC and add them, or allow the provider to select all models. Allowing all models can be convenient while you're evaluating models or when the set you use changes often, but limiting access gives you tighter control over cost and usage.

### Using a different region or model

You can use any model your project has access to, in any region where that model is available. If you change models, check the model's region availability in the Vertex AI documentation, and enable it in Model Garden first if it's a partner model. If you need models that are served in different regions, add a separate Google Vertex AI provider in ARC for each region.

### Narrowing the service account's permissions

The Vertex AI User role allows the service account to call any Vertex AI model in your project, and it also includes permissions ARC doesn't need. For production, consider creating a [custom role](https://cloud.google.com/iam/docs/creating-custom-roles) with only the permissions required to call the models you use, and granting that role instead.

For example, to create a custom role that can call models, grant it to the service account, and remove the Vertex AI User role:

```term copy
$ gcloud iam roles create fastlyArcModelInvoker \
    --project="$PROJECT_ID" \
    --title="Fastly ARC model invoker" \
    --permissions="aiplatform.endpoints.predict"
$ gcloud projects add-iam-policy-binding "$PROJECT_ID" \
    --member="serviceAccount:${SA_EMAIL}" \
    --role="projects/${PROJECT_ID}/roles/fastlyArcModelInvoker"
$ gcloud projects remove-iam-policy-binding "$PROJECT_ID" \
    --member="serviceAccount:${SA_EMAIL}" \
    --role="roles/aiplatform.user"
```

If a request fails after you switch roles, the error message names the missing permission. Add it to the custom role with `gcloud iam roles update`.

### Making the connection temporary

This tutorial set up a connection you can keep using. If you only want to try ARC with Vertex AI, for example to evaluate a model, you can treat the connection as temporary and remove it when you're done. Remove the ARC resources first, then the Google Cloud resources.

Revoke the test virtual key and remove the provider in ARC:

1. On the **Virtual keys** tab, click the three dots <span class="inline-icons"><img src="https://www.fastly.com/documentation/img/icons/more.png" alt="More icon" /></span> to the right of `vertex-ai-test`.
2. Click **Delete**, and confirm when prompted.
3. On the **Providers** tab, find the Google Vertex AI provider card and click **Details**.
4. Click **Remove**, then confirm by clicking **Remove provider**.

Remove the Google Cloud resources:

1. _(Optional)_ If you're in a new Cloud Shell session, set the variables from Step 2 again.

2. Remove the service account's role by doing one of the following:

   - If you used the Vertex AI User role, remove its binding:

     ```term copy
     $ gcloud projects remove-iam-policy-binding "$PROJECT_ID" \
         --member="serviceAccount:${SA_EMAIL}" \
         --role="roles/aiplatform.user"
     ```

   - If you switched to a custom role, remove its binding and delete the role:

     ```term copy
     $ gcloud projects remove-iam-policy-binding "$PROJECT_ID" \
         --member="serviceAccount:${SA_EMAIL}" \
         --role="projects/${PROJECT_ID}/roles/fastlyArcModelInvoker"
     $ gcloud iam roles delete fastlyArcModelInvoker \
         --project="$PROJECT_ID"
     ```

3. Delete the service account:

   ```term copy
   $ gcloud iam service-accounts delete "$SA_EMAIL" \
       --project="$PROJECT_ID"
   ```

4. Delete the workload identity pool, which also deletes its provider:

   ```term copy
   $ gcloud iam workload-identity-pools delete "$POOL_ID" \
       --project="$PROJECT_ID" \
       --location="global"
   ```

Deleted pools are kept for 30 days before they're permanently removed, and you can't reuse the pool ID during that time. To set up the connection again sooner, use a different pool ID or undelete the pool. For details, see [Manage workload identity pools and providers](https://docs.cloud.google.com/iam/docs/manage-workload-identity-pools-providers) in the Google Cloud documentation.

## What's next

You've connected Google Vertex AI to ARC without storing Google Cloud credentials in ARC. From here, you can:

- [connect your application](https://www.fastly.com/documentation/guides/platform/ai-runtime-control/connecting-clients-to-arc/) to ARC with the virtual key you created, so its requests route to your Vertex AI provider.
- [manage your providers](https://www.fastly.com/documentation/guides/platform/ai-runtime-control/managing-providers/), including editing the region or model permissions for your Vertex AI provider.
- [manage your virtual keys](https://www.fastly.com/documentation/guides/platform/ai-runtime-control/managing-virtual-keys/) to control which keys route requests to your Vertex AI provider.
