*This page
applies to **Apigee** and **Apigee hybrid**.*


*View [Apigee Edge](https://docs.apigee.com/api-platform/get-started/what-apigee-edge) documentation.*
![](https://fonts.gstatic.com/s/i/googlematerialicons/help/v13/gm_grey-24dp/1x/gm_help_gm_grey_24dp.png)

This page describes how to configure the Apigee Extension Processor to enable API policy enforcement
for API traffic using a Service Extensions-enabled load balancer.

To learn more about the suggested use cases and benefits of using the Apigee Extension Processor for
API management, see [Apigee Extension Processor overview](https://docs.cloud.google.com/apigee/docs/api-platform/service-extensions/extension-processor-overview.md.txt).

The Apigee Extension Processor is a traffic [extension](https://docs.cloud.google.com/service-extensions/docs/lb-extensions-overview.md.txt) (a type of Service Extension) that lets you use Cloud Load Balancing
to send callouts from the data processing path of the application load balancer to the Apigee Extension Processor. Once the load balancer
and traffic extension are configured, API traffic is processed by the load balancer. The policies in the Apigee Extension Processor are applied to API traffic using the
traffic extension callouts.

The following sections guide you through the steps to configure the key elements of the Apigee Extension Processor:

- [Configure a load balancer for a backend service](https://docs.cloud.google.com/apigee/docs/api-platform/service-extensions/extension-processor-quickstart.md.txt#configure-lb).
- [Configure the Apigee Extension Processor](https://docs.cloud.google.com/apigee/docs/api-platform/service-extensions/extension-processor-quickstart.md.txt#configure-ext-proc).
- [Configure the traffic extension](https://docs.cloud.google.com/apigee/docs/api-platform/service-extensions/extension-processor-quickstart.md.txt#configure-ext).
- [Use policies with the Extension Processor](https://docs.cloud.google.com/apigee/docs/api-platform/service-extensions/extension-processor-quickstart.md.txt#use-policies).

<br />

## Before you begin

Before you begin setting up the Apigee Extension Processor, complete the following tasks:

1. Install the [Google Cloud CLI](https://docs.cloud.google.com/sdk/gcloud.md.txt).

   After you install the Google Cloud CLI, run the `gcloud components update`
   command to get the latest gcloud components.
2. Provision an [Apigee](https://docs.cloud.google.com/apigee/docs/api-platform/get-started/provisioning-intro.md.txt) instance using
   version `1-15-0-apigee-2` or later, if you have not already done so.

   View instance versions in the **Instance details** page of the
   Apigee UI in Google Cloud console. Go to the **Instances** page in the Google Cloud console to select an instance and view its details:

   [Go to Instances](https://console.cloud.google.com/apigee/instances)

   You can use Extension Processor with a [Subscription](https://docs.cloud.google.com/apigee/docs/api-platform/reference/subscription-entitlements.md.txt)
   or [Pay-as-you-go](https://docs.cloud.google.com/apigee/docs/api-platform/reference/pay-as-you-go-updated-entitlements.md.txt) Apigee
   organization. If you are unsure whether you are using a Subscription or Pay-as-you-go Apigee organization, contact your Apigee organization administrator.
   For more details about provisioning paid Apigee instances,
   see [Before you begin](https://docs.cloud.google.com/apigee/docs/api-platform/get-started/overview.md.txt).
3. Confirm that you have a [VPC and subnet](https://docs.cloud.google.com/apigee/docs/api-platform/system-administration/shared-vpcs.md.txt#configuring-shared-vpc-with-apigee) enabled in the Apigee instance you plan to use. Go to the **VPC Networks** page in the Google Cloud console:

   [Go to VPC Networks](https://console.cloud.google.com/networking/networks/list)

### Required roles


To get the permissions that
you need to install the Apigee Extension Processor,

ask your administrator to grant you the
following IAM roles:

- Create and manage service accounts: [Service Account Admin](https://docs.cloud.google.com/iam/docs/roles-permissions/iam.md.txt#iam.serviceAccountAdmin) (`roles/iam.serviceAccountAdmin`) on organization
- Create and manage service extensions: [Service Extensions Admin](https://docs.cloud.google.com/iam/docs/roles-permissions/networkservices.md.txt#networkservices.serviceExtensionsAdmin) (`roles/networkservices.serviceExtensionsAdmin`) on organization
- Create and manage network endpoint groups (NEGs): [Compute Instance Admin](https://docs.cloud.google.com/iam/docs/roles-permissions/compute.md.txt#compute.instanceAdmin) (`roles/compute.instanceAdmin`) on organization
- Create and manage networking resources: [Compute Network Admin](https://docs.cloud.google.com/iam/docs/roles-permissions/compute.md.txt#compute.networkAdmin) (`roles/compute.networkAdmin`) on organization
- Create and manage backend services: [Compute Load Balancer Admin](https://docs.cloud.google.com/iam/docs/roles-permissions/compute.md.txt#compute.loadBalancerAdmin) (`roles/compute.loadBalancerAdmin`) on organization
- Create and manage Apigee resources: [Apigee Org Admin](https://docs.cloud.google.com/iam/docs/roles-permissions/apigee.md.txt#apigee.admin) (`roles/apigee.admin`) on organization
- Create and manage traffic extensions: [Apigee APIM Service Extension Admin](https://docs.cloud.google.com/iam/docs/roles-permissions/apigee.md.txt#apigee.apimServiceExtensionAdmin) (`roles/apigee.apimServiceExtensionAdmin`) on organization
- View traffic extensions: [Apigee APIM Service Extension Viewer](https://docs.cloud.google.com/iam/docs/roles-permissions/apigee.md.txt#apigee.apimServiceExtensionViewer) (`roles/apigee.apimServiceExtensionViewer`) on organization
- Manage long-running operations: [Apigee APIM Service Extension Service Agent](https://docs.cloud.google.com/iam/docs/roles-permissions/apigee.md.txt#apigee.apimServiceExtensionServiceAgent) (`roles/apigee.apimServiceExtensionServiceAgent`) on the service agent in the Google Cloud project


For more information about granting roles, see [Manage access to projects, folders, and organizations](https://docs.cloud.google.com/iam/docs/granting-changing-revoking-access.md.txt).


You might also be able to get
the required permissions through [custom
roles](https://docs.cloud.google.com/iam/docs/creating-custom-roles) or other [predefined
roles](https://docs.cloud.google.com/iam/docs/roles-overview#predefined).

### Set environment variables

In the Google Cloud project that contains your Apigee instance, use the following
command to set environment variables:

```bash
export PROJECT_ID=PROJECT_ID
export ORG_NAME=$PROJECT_ID
export REGION=REGION
export INSTANCE=INSTANCE
export VPC_NETWORK_NAME=VPC_NETWORK_NAME
export SUBNET=SUBNET
```

Where:

- `PROJECT_ID` is the ID of the project with your Apigee instance.
- `REGION` is the Google Cloud region of your Apigee instance.
- `INSTANCE` is the name of your Apigee instance.
- `VPC_NETWORK_NAME` is the name of the VPC network in your Google Cloud project that you want to use for the Apigee Extension Processor.
- `SUBNET` is the name of the subnet in your Google Cloud project that you want to use for the Apigee Extension Processor.

<br />

To confirm that the environment variables are set correctly, run the following command and review the output:

```bash
echo $PROJECT_ID $ORG_NAME $REGION $INSTANCE $VPC_NETWORK_NAME $SUBNET
```

<br />

### Configure an authentication token

To configure an authentication token, run the following command:

```bash
export TOKEN=$(gcloud auth print-access-token)
echo $TOKEN
```

## Configure a load balancer for a backend service

The following sections describe the steps to set up a global external Application Load Balancer for a backend service, using
**httpbin.org** as an example:

1. [Create a global external Application Load Balancer](https://docs.cloud.google.com/apigee/docs/api-platform/service-extensions/extension-processor-quickstart.md.txt#create-global-ext-app-lb).
2. [Create a network endpoint group (NEG)](https://docs.cloud.google.com/apigee/docs/api-platform/service-extensions/extension-processor-quickstart.md.txt#create-neg).
3. [Create a backend service](https://docs.cloud.google.com/apigee/docs/api-platform/service-extensions/extension-processor-quickstart.md.txt#create-backend-service).
4. [Create a URL map](https://docs.cloud.google.com/apigee/docs/api-platform/service-extensions/extension-processor-quickstart.md.txt#create-url-map).
5. [Create a target proxy](https://docs.cloud.google.com/apigee/docs/api-platform/service-extensions/extension-processor-quickstart.md.txt#create-target-proxy).
6. [Create a global forwarding rule](https://docs.cloud.google.com/apigee/docs/api-platform/service-extensions/extension-processor-quickstart.md.txt#create-global-forwarding-rule).

### Create a global external Application Load Balancer

To create the load balancer:

1. Set your `gcloud` configuration to use your current project:

   ```bash
   gcloud config set project PROJECT_ID
   ```

   Where <var translate="no">PROJECT_ID</var> is the ID of the project with your Apigee instance.
2. Create a global static IP address:

   ```bash
   gcloud compute addresses create IP_ADDRESS --ip-version=IPV4 --global
   ```

   Where <var translate="no">IP_ADDRESS</var> is the name of the IP address you want to create. The name must match the regular expression `(?:a-z?)`.
3. Get the IP address and save it as an environment variable:

   ```bash
   IP=$(gcloud compute addresses describe IP_ADDRESS --format="get(address)" --global)
   ```

   Where <var translate="no">IP_ADDRESS</var> is the name of the IP address you created in the previous step.
4. Create a TLS certificate for [`nip.io`](https://nip.io/), a third-party service that provides wildcard DNS records for IP addresses:

   ```bash
   gcloud compute ssl-certificates create SSL_CERT_NAME \
     --domains="nip.io"
   ```

   Where <var translate="no">SSL_CERT_NAME</var> is the name of the certificate you want to create.

### Create a network endpoint group (NEG)

To create the network endpoint group (NEG) for your load balancer:

1. Create a NEG:

   ```bash
   gcloud compute network-endpoint-groups create NEG_NAME \
     --network-endpoint-type=INTERNET_FQDN_PORT \
     --default-port=443 \
     --global
   ```

   Where <var translate="no">NEG_NAME</var> is the name of the NEG you want to create.
2. Add the endpoint for **httpbin.org** to the NEG:

   ```bash
   gcloud compute network-endpoint-groups update NEG_NAME \
     --add-endpoint=fqdn=httpbin.org,port=443 \
     --global
   ```

   Where <var translate="no">NEG_NAME</var> is the name of the NEG you created in the previous step.

### Create a backend service

To create the backend service exposed by the load balancer:

1. Create the backend service:

   ```bash
   gcloud compute backend-services create BACKEND_SERVICE_NAME \
     --load-balancing-scheme=EXTERNAL_MANAGED \
     --protocol=HTTPS \
     --global
   ```

   Replace <var translate="no">BACKEND_SERVICE_NAME</var> is the name of the backend service you want to create.
2. Add the NEG to the backend:

   ```bash
   gcloud compute backend-services add-backend BACKEND_SERVICE_NAME \
     --network-endpoint-group=NEG_NAME \
     --global-network-endpoint-group \
     --global
   ```

   Where:
   - <var translate="no">BACKEND_SERVICE_NAME</var> is the name of the backend service you created in the previous step.
   - <var translate="no">NEG_NAME</var> is the name of the NEG you created in a previous step.

### Create a URL map

To create a URL map between the load balancer and the backend service, use the following command:

```bash
gcloud compute url-maps create URL_MAP_NAME \
  --default-service BACKEND_SERVICE_NAME \
  --global
```

Where:

- <var translate="no">URL_MAP_NAME</var> is the name of the URL map you want to create.
- <var translate="no">BACKEND_SERVICE_NAME</var> is the name of the backend service you created in a previous step.

### Create a target proxy

To create a target proxy for the load balancer to process service extension traffic, use the following command:

```bash
gcloud compute target-https-proxies create TARGET_PROXY_NAME \
  --global \
  --ssl-certificates SSL_CERT_NAME \
  --global-ssl-certificates \
  --url-map URL_MAP_NAME \
  --global-url-map
```

Where:

- <var translate="no">TARGET_PROXY_NAME</var> is the name of the target proxy you want to create.
- <var translate="no">URL_MAP_NAME</var> is the name of the URL map you created in a previous step.
- <var translate="no">SSL_CERT_NAME</var> is the name of the SSL certificate you created for `nip.io` in a previous step.

<br />

### Create a global forwarding rule

To create a global forwarding rule for the load balancer, use the following command:

```bash
gcloud compute forwarding-rules create FORWARDING_RULE_NAME \
  --load-balancing-scheme=EXTERNAL_MANAGED \
  --network-tier=PREMIUM \
  --address=IP_ADDRESS \
  --target-https-proxy=TARGET_PROXY_NAME \
  --ports=443 \
  --global
```

Where:

- <var translate="no">FORWARDING_RULE_NAME</var> is the name of the forwarding rule you want to create.
- <var translate="no">IP_ADDRESS</var> is the name of the IP address of the NEG endpoint you created in a previous step.
- <var translate="no">TARGET_PROXY_NAME</var> is the name of the target proxy that processes extension traffic.

<br />

## Configure the Apigee Extension Processor

The following sections describe the steps to set up the Apigee Extension Processor:

1. [Create an Apigee environment](https://docs.cloud.google.com/apigee/docs/api-platform/service-extensions/extension-processor-quickstart.md.txt#create-apigee-environment).
2. [Create the Extension Processor proxy](https://docs.cloud.google.com/apigee/docs/api-platform/service-extensions/extension-processor-quickstart.md.txt#create-extproc-proxy).

### Create an Apigee environment

> [!NOTE]
> **Note:** Before creating a new environment and environment group, or using existing resources for the step, review the limitations on environments, environment groups, and API proxies in the Extension Processor configuration. For more information, see [Limitations](https://docs.cloud.google.com/apigee/docs/api-platform/service-extensions/extension-processor-overview.md.txt#limitations).

1. Create an Apigee environment using the following command:

   ```bash
   curl -i -X POST -H  "Authorization: Bearer $TOKEN" \
       "https://apigee.googleapis.com/v1/organizations/$ORG_NAME/environments" -H "Content-Type:application/json" -d \
       '{
           "name": "ENV_NAME",
           "displayName": "ENV_NAME",
           "state": "ACTIVE",
           "deploymentType": "PROXY",
           "apiProxyType": "PROGRAMMABLE",
           "type": "COMPREHENSIVE",
           "properties":
           {"property": [
               {
               "name": "apigee-service-extension-enabled",
               "value": "true"
               }
             ]
           }
       }'
   ```

   Where <var translate="no">ENV_NAME</var> is the name of the environment you are creating. The name must contain between
   2 and 32 characters which can be lowercase letters, numbers, or hyphens. The name must begin with
   a letter and cannot end with a hyphen. The name must be different from any other environment name in your organization.

   Confirm that the environment is created:

   ```bash
   curl -i -H "Authorization: Bearer $TOKEN" \
       "https://apigee.googleapis.com/v1/organizations/$ORG_NAME/environments"
   ```

   The list of environments should include the environment you just created.
2. Attach the newly created environment to your Apigee instance:

   ```bash
   curl -i -X POST -H "Authorization: Bearer $TOKEN" \
       "https://apigee.googleapis.com/v1/organizations/$ORG_NAME/instances/$INSTANCE/attachments" -H "Content-Type:application/json" -d \
       '{
           "environment": "ENV_NAME"
           }'
   ```

   Where <var translate="no">ENV_NAME</var> is the name of the environment you created in the previous step.

   This operation may take up to 10 minutes.
3. Create the Apigee environment group:

   ```bash
   curl -H "Authorization: Bearer $TOKEN" -X POST \
       "https://apigee.googleapis.com/v1/organizations/$ORG_NAME/envgroups" -H "Content-Type:application/json" -d \
       '{
           "name": "ENV_GROUP_NAME",
           "hostnames": ["ENV_GROUP_HOSTNAME"]
           }'
   ```

   Where:
   - <var translate="no">ENV_GROUP_NAME</var> is the name of the environment group you are creating.
   - <var translate="no">ENV_GROUP_HOSTNAME</var> is the hostname of the environment group you are creating. The hostname must be a fully qualified domain name (FQDN).

     > [!NOTE]
     > **Note:** The hostname does not need to be resolvable.

4. Attach the new environment to the new environment group:

   ```bash
   curl -H "Authorization: Bearer $TOKEN" -X POST\
       "https://apigee.googleapis.com/v1/organizations/$ORG_NAME/envgroups/ENV_GROUP_NAME/attachments" -H "content-type:application/json" -d \
           '{
               "name": "ENV_GROUP_NAME",
               "environment": "ENV_NAME"
           }' 
   ```

   Where:
   - <var translate="no">ENV_GROUP_NAME</var> is the name of the environment group you are creating.
   - <var translate="no">ENV_NAME</var> is the name of the environment you created in an earlier step.

### Create the Extension Processor proxy

The Extension Processor proxy is an Apigee API proxy that is used to apply API management
policies to the load balancer traffic. You can create a **no-target** proxy
or an **Server-Sent event (SSE)-enabled** proxy. To learn more about using SSE with Apigee, see
[Server-sent events](https://docs.cloud.google.com/apigee/docs/api-platform/develop/server-sent-events.md.txt).

To create an Apigee API proxy for use with the Extension Processor load balancer:

### No target proxy

1. Follow the steps in [Creating an API proxy](https://docs.cloud.google.com/apigee/docs/api-platform/develop/ui-create-proxy.md.txt#steps-to-create-an-api-proxy) to create a **No target** proxy with the following specifications:
   - Proxy template: Select **No target**.
   - Proxy name: Enter a proxy name. This name will serve as the identifier for the Extension Processor.
   - Base path: Set any base path you would like. The path will not be used.

   The XML specification for the proxy should appear similar to the following:

   ```xml
   <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
   <APIProxy revision="1" name="extproc-sample">
       <DisplayName/>
       <Description/>
       <CreatedAt>1739581781912</CreatedAt>
       <LastModifiedAt>1739582447868</LastModifiedAt>
       <BasePaths>/</BasePaths>
       <Policies></Policies>
       <ProxyEndpoints>
           <ProxyEndpoint>default</ProxyEndpoint>
       </ProxyEndpoints>
   </APIProxy>
   ```
2. Follow the steps in [Deploy an API proxy](https://docs.cloud.google.com/apigee/docs/api-platform/deploy/ui-deploy-new.md.txt#deploy-an-api-proxy) to deploy the proxy to the environment you created earlier.

### SSE-enabled proxy

1. Follow the steps in [Creating an API proxy](https://docs.cloud.google.com/apigee/docs/api-platform/develop/ui-create-proxy.md.txt#steps-to-create-an-api-proxy) to create a **Server-sent event** proxy with the following specifications:
   - Proxy template: Select **No target**.
   - Proxy name: Enter a proxy name.
   - Base path: Set any base path you would like. The path will not be used.

   The XML specification for the proxy should appear similar to the following:

   ```xml
   <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
   <APIProxy revision="1" name="extproc-sample">
       <DisplayName/>
       <Description/>
       <CreatedAt>1739581781912</CreatedAt>
       <LastModifiedAt>1739582447868</LastModifiedAt>
       <BasePaths>/</BasePaths>
       <ProxyEndpoints>
           <ProxyEndpoint>default</ProxyEndpoint>
       </ProxyEndpoints>
   </APIProxy>
   ```
2. Configure the `EventFlow` in the proxy:

   ```xml
   <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
   <APIProxy revision="1" name="extproc-sample">
       <DisplayName/>
       <Description/>
       <CreatedAt>1739581781912</CreatedAt>
       <LastModifiedAt>1739582447868</LastModifiedAt>
       <BasePaths>/</BasePaths>
       <ProxyEndpoints>
           <ProxyEndpoint>default</ProxyEndpoint>
           <EventFlow name="EventFlow" content-type="text/event-stream">
             <Response/>
           </EventFlow>
           <HTTPProxyConnection>
             <Properties/>
             <URL>https://httpbin.org/sse</URL>
           </HTTPProxyConnection>
       </ProxyEndpoints>
   </APIProxy>
   ```
3. Follow the steps in [Deploy an API proxy](https://docs.cloud.google.com/apigee/docs/api-platform/deploy/ui-deploy-new.md.txt#deploy-an-api-proxy) to deploy the proxy to the environment you created earlier.

## Configure the traffic extension

This section describes how to configure the traffic service extension for your Extension Processor, using the following
steps:

1. [Create the traffic extension with the Extension Processor provisioning API](https://docs.cloud.google.com/apigee/docs/api-platform/service-extensions/extension-processor-quickstart.md.txt#create-traffic-ext).
2. [Send a request to the load balancer](https://docs.cloud.google.com/apigee/docs/api-platform/service-extensions/extension-processor-quickstart.md.txt#send-request).

### Create the traffic extension with the Extension Processor provisioning API

In this step, create a traffic service extension for your Extension Processor using the Extension Processor provisioning API.

Create the traffic extension using the following command to call the Extension Processor provisioning API:

```bash
curl -X POST -H  "Authorization: Bearer $TOKEN" \
    https://apigee.googleapis.com/v1/organizations/$ORG_NAME/apimServiceExtensions?apimServiceExtensionId=TRAFFIC_EXT_NAME \
    -H "Content-Type:application/json" -d \
    '{
      "extensionProcessor": "TARGET_PROXY_NAME"
      "lbForwardingRule": "LB_FORWARDING_RULE",
      "network" : "NETWORK",
      "networkConfigs": [
        {
          "region": "$REGION",
          "subnet": "project/my-project/regions/$REGION/subnetworks/$SUBNET"
        }
      ],
      "extensions": [
        {
          "name": "TARGET_PROXY_NAME",
          "matchCondition": "CEL_EXPRESSION",
          "failOpen": FAIL_OPEN,
          "hostname": "ENV_GROUP_HOSTNAME",
          "supportedEvents": [
            "REQUEST_HEADERS",
            "RESPONSE_HEADERS"
          ]
        }
      ]
    }'
```

Where:

- <var translate="no">TRAFFIC_EXT_NAME</var> is is the name of the traffic extension you are creating.
- <var translate="no">LB_FORWARDING_RULE</var> is the name of the forwarding rule you created in an earlier step.
- <var translate="no">NETWORK</var> is the name of the network you created in an earlier step.
- <var translate="no">TARGET_PROXY_NAME</var> is the name of the proxy that processes extension traffic.
- <var translate="no">CEL_EXPRESSION</var> is the Common Expression Language (CEL) expression you want to use for the traffic extension. For more information on CEL syntax, see [CEL matcher language reference](https://cloud.google.com/service-extensions/docs/cel-matcher-language-reference).
- <var translate="no">FAIL_OPEN</var> is a boolean value that determines whether the traffic extension fails open or closed. Valid values are `true` or `false`.
- <var translate="no">ENV_GROUP_HOSTNAME</var> is the hostname of the environment group you created in an earlier step.

<br />

> [!NOTE]
> **Note:** Once the traffic extension is created, the `name`, `lbForwardingRule`, and `network` fields can't be changed.
>
> <br />
>
This operation may take a few minutes to complete.

### Get traffic extension details

To verify that the traffic service extension was created successfully, use the following command:

```bash
curl -H "Authorization: Bearer $TOKEN" \
    "https://apigee.googleapis.com/v1/organizations/$ORG_NAME/apimServiceExtensions/TRAFFIC_EXT_NAME"
```

Replace <var translate="no">TRAFFIC_EXT_NAME</var> with the name of the traffic extension you just created.

The response appears similar to the following:

```bash
{
  "name": "my-traffic-extension",
  "extensionProcessor": "my-extension-processor",
  "lbForwardingRule": "https://www.googleapis.com/compute/v1/projects/my-project/global/forwardingRules/my-forwarding-rule",
  "network": "projects/my-project/global/networks/my-network",
  "networkConfigs": [
    {
      "region": "us-west1",
      "subnet": "projects/my-project/regions/us-west1/subnetworks/my-subnet"
    }
  ],
  "extensions": [
    {
      "name": "organizations/my-org/apis/my-api-proxy",
      "matchCondition": "request.url.contains('1234567890')",
      "failOpen": true,
      "hostname": "my-hostname.apigee.net",
      "supportedEvents": [
        "REQUEST_HEADERS",
        "RESPONSE_HEADERS"
      ]
    }
  ]
}
```

### Update a traffic extension

You can update the traffic extension using the `updateMask` parameter. When using the `updateMask` parameter,
you specify the attributes of the resource that you want to update by providing a comma-separated list.
The supported attributes for `updateMask` are:

- `networkConfigs`: updates to `region` and `subnet` fields.

  > [!NOTE]
  > **Note:** This field is only updatable for **Global** Application Load Balancers. For **Regional** Application Load Balancers, the `networkConfigs` can't be updated; you must delete and recreate the extension to modify network configurations.

- `extensions`: updates the `name`, `matchCondition`, `failOpen`, `hostname`, and `supportedEvents` fields.
- `extensionProcessor`: updates the `extensionProcessor` field.

To update a traffic extension, use the `curl` command with the `PATCH` method. You can update multiple attributes by including them in the `updateMask` query parameter as a comma-separated string (e.g., `?updateMask=extensions,extensionProcessor`).

Here are some examples:

### Update `networkConfigs` (Global LB)

To update the `networkConfigs` attributes, use the following command:

```bash
curl -X PATCH -H  "Authorization: Bearer $TOKEN" \
  https://apigee.googleapis.com/v1/organizations/$ORG_NAME/apimServiceExtensions/TRAFFIC_EXT_NAME?updateMask=networkConfigs \
  -H "Content-Type:application/json" -d \
  '{
    "networkConfigs": [
      {
        "region": "REGION",
        "subnet": "projects/$PROJECT/regions/REGION/subnetworks/SUBNET"
      }
    ]
  }'
```

Where:

- <var translate="no">TRAFFIC_EXT_NAME</var> is the name of the Extension Processor traffic extension to update.
- <var translate="no">REGION</var> is the region of the updated region.
- <var translate="no">SUBNET</var> is the new subnet of the network.

<br />

### Update `extensions`

To update the `extensions` attributes, use the following command:

```bash
curl -X PATCH -H  "Authorization: Bearer $TOKEN" \
  https://apigee.googleapis.com/v1/organizations/$ORG_NAME/apimServiceExtensions/TRAFFIC_EXT_NAME?updateMask=extensions \
  -H "Content-Type:application/json" -d \
  '{
    "extensions": [
      {
        "name": "TARGET_PROXY_NAME",
        "matchCondition": "NEW_CEL_EXPRESSION",
        "failOpen": NEW_FAIL_OPEN
        "hostname": "NEW_ENV_GROUP_HOSTNAME",
        "supportedEvents": [
          "REQUEST_HEADERS",
          "RESPONSE_HEADERS"
        ]
      }
    ]
  }'
```

Where:

- <var translate="no">TRAFFIC_EXT_NAME</var> is the name of the Extension Processor traffic extension to update.
- <var translate="no">TARGET_PROXY_NAME</var> is the name of the proxy that processes extension traffic.
- <var translate="no">NEW_CEL_EXPRESSION</var> is the updated CEL expression.
- <var translate="no">NEW_FAIL_OPEN</var> is the updated boolean value for fail open.
- <var translate="no">NEW_ENV_GROUP_HOSTNAME</var> is the hostname of the environment group.

<br />

### Update `extensionProcessor`

To update the `extensionProcessor` attributes, use the following command:

```bash
curl -X PATCH -H  "Authorization: Bearer $TOKEN" \
  https://apigee.googleapis.com/v1/organizations/$ORG_NAME/apimServiceExtensions/TRAFFIC_EXT_NAME?updateMask=extensionProcessor \
  -H "Content-Type:application/json" -d \
  '{
    "extensionProcessor": "NEW_TARGET_PROXY_NAME"
  }'
```

Where:

- <var translate="no">TRAFFIC_EXT_NAME</var> is the name of the Extension Processor traffic extension to update.
- <var translate="no">NEW_TARGET_PROXY_NAME</var> is the new name of the proxy that processes extension traffic.

<br />

### Update Multiple Attributes (Global LB)

To update the `extensions` and `extensionProcessor` attributes simultaneously, use the following command:

```bash
curl -X PATCH -H  "Authorization: Bearer $TOKEN" \
  https://apigee.googleapis.com/v1/organizations/$ORG_NAME/apimServiceExtensions/TRAFFIC_EXT_NAME?updateMask=extensions,extensionProcessor \
  -H "Content-Type:application/json" -d \
  '{
    "extensions": [
      {
        "name": "TARGET_PROXY_NAME",
        "matchCondition": "NEW_CEL_EXPRESSION",
        "failOpen": NEW_FAIL_OPEN,
        "hostname": "NEW_ENV_GROUP_HOSTNAME",
        "supportedEvents": [
          "REQUEST_HEADERS",
          "RESPONSE_HEADERS"
        ]
      }
    ],
    "extensionProcessor": "NEW_TARGET_PROXY_NAME"
  }'
```

Where:

- <var translate="no">TRAFFIC_EXT_NAME</var> is the name of the Extension Processor traffic extension to update.
- <var translate="no">TARGET_PROXY_NAME</var> is the name of the proxy that processes extension traffic.
- <var translate="no">NEW_CEL_EXPRESSION</var> is the updated CEL expression.
- <var translate="no">NEW_FAIL_OPEN</var> is the updated boolean value for fail open.
- <var translate="no">NEW_ENV_GROUP_HOSTNAME</var> is the hostname of the environment group.
- <var translate="no">NEW_TARGET_PROXY_NAME</var> is the new name of the proxy that processes extension traffic.

<br />

## Send a request to the load balancer

To test the load balancer and Extension Processor setup, send a request to the load balancer:

```bash
curl "https://LB_DOMAIN_NAME/get"
```

Where <var translate="no">LB_DOMAIN_NAME</var> is the domain name you used for the load balancer and SSL certificate. If you
used `nip.io`, the domain name will look similar to `IP_ADDRESS.nip.io`.


The response appears similar to the following:

```bash
{"status": 200,
  {
    "args": {},
    "headers": {
      ...
    },
    "origin": "173.93.50.108",
    "url": "https://httpbin.org/get"
  }
}
```

## Use policies with the Extension Processor

This section describes how to use policies with the Extension Processor.

In this example, configure a [VerifyAPIKey](https://docs.cloud.google.com/apigee/docs/api-platform/reference/policies/verify-api-key-policy.md.txt)
and [AssignMessage](https://docs.cloud.google.com/apigee/docs/api-platform/reference/policies/assign-message-policy.md.txt) policy
for the Extension Processor. These
policies validate API keys included in requests to Apigee and inject a Google
token into request headers for calls to a backend service. This scenario would be useful for API providers
using the Apigee Extension Processor to authorize and authenticate requests to their Apigee services and seamlessly
inject the [Google auth tokens](https://docs.cloud.google.com/apigee/docs/api-platform/security/google-auth/overview.md.txt)
required for a backend service like Vertex AI.

### Add the VerifyAPIKey policy for API key validation

The following sections describe how to use the VerifyAPIKey policy to validate API keys for calls
to your backend service using the Extension Processor:

1. [Attach the VerifyAPIKey policy to the Extension Processor.](https://docs.cloud.google.com/apigee/docs/api-platform/service-extensions/extension-processor-quickstart.md.txt#attach-verify-api-key)
2. [Create an API product.](https://docs.cloud.google.com/apigee/docs/api-platform/service-extensions/extension-processor-quickstart.md.txt#create-api-product)
3. [Create a developer App and App credentials.](https://docs.cloud.google.com/apigee/docs/api-platform/service-extensions/extension-processor-quickstart.md.txt#create-developer-app)
4. [Send a request to the load balancer using the API key.](https://docs.cloud.google.com/apigee/docs/api-platform/service-extensions/extension-processor-quickstart.md.txt#send-request)

#### Attach the VerifyAPIKey policy to the proxy

To attach a VerifyAPIKey policy to the Extension Processor proxy:

1. In the Google Cloud console, go to the **Apigee \> Proxy Development \> API Proxies** page.

   [Go to API Proxies](https://console.cloud.google.com/apigee/proxies)
2. Select the Extension Processor proxy you created in [Create an extension processor](https://docs.cloud.google.com/apigee/docs/api-platform/service-extensions/extension-processor-quickstart.md.txt#create-extproc-proxy) section.
3. Click the **Develop** tab.
4. In the navigation pane, click in the **Policies** section.
5. In the **Create policy** dialog, select **VerifyAPIKey** from the list of policies.
6. In the **VerifyAPIKey** pane, complete the required fields in the **Name** and **Display name** sections using the following values:
   - **Name** : Enter a policy name. For example, `VA-verify-api-key`.
   - **Display name** : Enter policy name for use in the UI. For example, `VA-verify-api-key`.
7. Click **Create** .

   The XML specification for the VerifyAPIKey policy included in the Extension Processor proxy should appear similar to the following:

   ```xml
     <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
     <VerifyAPIKey continueOnError="false" enabled="true" name="VA-verify-api-key">
       <DisplayName>VA-verify-api-key</DisplayName>
       <Properties/>
       <APIKey ref="request.queryparam.x-api-key"/>
     </VerifyAPIKey>
   ```
8. Deploy the new proxy revision.

#### Create an API product

To create an API product and configure the API operation set for your service:


1. Follow the steps in [Creating an API product](https://docs.cloud.google.com/apigee/docs/api-platform/publish/create-api-products.md.txt#add) to create an API product for your service. You can configure the **Product details** for the API product however you wish.
2. Follow the steps in [Operations](https://docs.cloud.google.com/apigee/docs/api-platform/publish/create-api-products.md.txt#operations) to add an API operation set to the API product, according to the following specifications:
   - Source: In the Google Cloud console, go to the **Apigee \> Distribution \> API Products** page.

     [Go to API Products](https://console.cloud.google.com/apigee/apiproducts)
     Select the API product you created in an earlier step.
   - Operation: Click **Edit** and configure the following paths and methods:
     - Path: `/get` with Method: `GET`
     - Path: `/TARGET_PROXY_NAME` with Method: `GET`

       <var translate="no">TARGET_PROXY_NAME</var> is the name of the proxy that processes extension traffic.

#### Create a developer App and App credentials

To create a developer App and App credentials for the newly created API product:

1. Go to the **Apigee API management** page in the Google Cloud console:

   [Apigee API management](https://console.cloud.google.com/apigee)
2. Create a developer:
   1. Select **Distribution \> Developers**.
   2. On the **Developers** page, click **+ Create**.
   3. In the **Add developer** page, complete the required fields using any values you wish.
   4. Click **Add**.
3. Create an App:
   1. Select **Distribution\> Apps**.
   2. On the **Apps** page, click **+ Create**
   3. On the **Create App** page, complete the required fields in the **App Details** section using the following values:
      - **App name** : Enter a name for the App. For example, `ext-proc-app`
      - **Developer**: Select the developer you created in the previous step, or another developer from the list.
   4. In the **App Credentials** section, click **+ Add Credential**.
   5. In the **Credential** section, select **Never** from the **Expiry** list box.
   6. In the **Products** section, click **+ Add products** to display the **Add Products** pane.
   7. Select the API product you created in the previous step.
   8. Click **OK**.
   9. Click **Add** to close the **Add Products** pane.
   10. Click **Create**.
4. In the **App Details** page, in the **Credential** section, click to display the value of the **Key** .

   Copy the `Key` value. You will use this key to make API calls to your service in a later step.
5. In the **App Details** page, in the **Credential** section, click to display the value of the **App Secret**.

#### Send a request to the load balancer using the API key

To test the API key validation, send a request to the load balancer using the API key:

```bash
curl "https://LB_DOMAIN_NAME/get"
```

Where <var translate="no">LB_DOMAIN_NAME</var> is the domain name you used for the load balancer and SSL certificate.

The response fails without an API key.

Send another request to the load balancer, using the API key in the request:

```bash
curl "https://LB_DOMAIN_NAME/get?key=API_KEY"
```

Where:

- <var translate="no">LB_DOMAIN_NAME</var> is the domain name you used for the load balancer and SSL certificate.
- <var translate="no">API_KEY</var> is the API key from the Developer App credentials revealed in an earlier step.

The response indicates successful authorization for the endpoint. This indicates that the
Extension Processor validated the API key and the Apigee proxy can now process the request.

### Add the AssignMessage policy for Google authentication

If you want to use your Extension Processor to provide API management for a Google-authenticated service,
you can inject a Google access token or Google ID token into requests sent to the backend service using the
[AssignMessage policy](https://docs.cloud.google.com/apigee/docs/api-platform/reference/policies/assign-message-policy.md.txt).

The following sections describe how to use the AssignMessage policy to inject a Google authentication token into requests sent to the backend service using the Extension Processor:

1. [Attach the AssignMessage policy to the proxy.](https://docs.cloud.google.com/apigee/docs/api-platform/service-extensions/extension-processor-quickstart.md.txt#attach-assign-message)
2. [Send a request to the load balancer to test token injection.](https://docs.cloud.google.com/apigee/docs/api-platform/service-extensions/extension-processor-quickstart.md.txt#send-request)

#### Attach the AssignMessage policy to the proxy

To add the AssignMessage policy to your proxy:

1. In the Google Cloud console, go to the **Proxy Development \> API Proxies** page.

   [Go to API Proxies](https://console.cloud.google.com/apigee/proxies)
2. Select the Extension Processor proxy you created in [Create an extension processor](https://docs.cloud.google.com/apigee/docs/api-platform/service-extensions/extension-processor-quickstart.md.txt#create-extproc-proxy) section.
3. Click the **Develop** tab.
4. In the navigation pane, click in the **Policies** section.
5. In the **Create policy** dialog, select **AssignMessage** from the list of policies.
6. In the **Assign Message** pane, complete the required fields in the **Name** and **Display name** sections using the following values:
   - **Name** : Enter a policy name. For example, `AM-auth`.
   - **Display name** : Enter a policy name to display in the UI. For example, `AM-auth`.
7. Click **Create**.
8. Under the `<Set>` element, add the following child elements:

   ```xml
   <Set>
       <Authentication>
       <HeaderName>Authorization</HeaderName>
       <GoogleAccessToken>
           <Scopes>
           <Scope>https://www.googleapis.com/auth/cloud-platform</Scope>
           </Scopes>
       </GoogleAccessToken>
       </Authentication>
   </Set>
   ```
9. Click **Save**.
10. Deploy the new revision using a Google service account.

The service account
generates Google access tokens and injects them into the request header for API calls to
Google backend services.

#### Send a request to the load balancer to test token injection

To confirm that token injection is working, send a request to the load balancer:

```bash
curl "https://LB_DOMAIN_NAME/get"
```

Where <var translate="no">LB_DOMAIN_NAME</var> is the domain name you used for the load balancer and SSL certificate.

The response appears similar to the following:

```bash
{
  ...
  "headers": {
    "Accept": "*/*",
    "Authorization": "Bearer ya29.c.c0ASRK0Gbw03y9cfvxL11DxaRYBQUU18SmUP4Vu63OckHI5cX7wJ4DmGMG2vbDDS69HXJHqMj-lak4tcqOsJGmE65crn2gNuJLanXidwM8",
    "First": "1.0",
    "Host": "apigee-ext-proc-test.apigee.net",
    "Second": "1.0",
    "Sum": "2",
    "User-Agent": "curl/8.7.1",
    "X-Api-Key": "McYcHGR3PTSGLXExvKADwQ1JJeCjgPDUvAakCl0rJKCFaX0Y",
    "X-Cloud-Trace-Context": "0fd3dadc2a3c328fa968d5f5f1434c29/18300783092696918345"
  },
  ...
}
```

<br />

The response shows the successful injection of the Google authentication token into the request header.

With the successful application of the AssignMessage policy, the client's successful request (containing the API key)
to Apigee in the example scenario is modified further to include a Google authentication token in the request header,
as required by the Google-authenticated backend service.