> ## Documentation Index
> Fetch the complete documentation index at: https://infisical.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# GCP Secret Manager sync

> Learn how to configure a GCP Secret Manager Sync for Infisical.

**Prerequisites:**

* Set up and add secrets to [Infisical Cloud](https://app.infisical.com)
* Create a [GCP Connection](https://infisical.com/docs/integrations/app-connections/gcp.md) with the required **Secret Sync** permissions
* Enable **Cloud Resource Manager API**, **Secret Manager API**, and **Service Usage API** on your GCP project

  ![Secret Syncs Tab](https://mintlify.s3.us-west-1.amazonaws.com/infisical/images/secret-syncs/gcp-secret-manager/enable-resource-manager-api.png)

  ![Secret Syncs Tab](https://mintlify.s3.us-west-1.amazonaws.com/infisical/images/secret-syncs/gcp-secret-manager/enable-secret-manager-api.png)

  ![Secret Syncs Tab](https://mintlify.s3.us-west-1.amazonaws.com/infisical/images/secret-syncs/gcp-secret-manager/enable-service-usage-api.png)
* Ensure your network security policies allow incoming requests from Infisical to this secret sync provider, if network restrictions apply.

> [tab] Infisical UI
>
> 1. Navigate to **Project** > **Integrations** and select the **Secret Syncs** tab. Select the **Add Sync** button.
>
>    ![Secret Syncs Tab](https://mintlify.s3.us-west-1.amazonaws.com/infisical/images/secret-syncs/general/revamped-secret-syncs-tab.png)
>
> 2. Select the **GCP Secret Manager** option.
>
>    ![Select GCP Secret Manager](https://mintlify.s3.us-west-1.amazonaws.com/infisical/images/secret-syncs/gcp-secret-manager/step-1.png)
>
> 3. Configure the **Source** from where secrets should be retrieved, then click **Next**.
>
>    ![Configure Source](https://mintlify.s3.us-west-1.amazonaws.com/infisical/images/secret-syncs/gcp-secret-manager/step-2.png)
>
>    * **Environment**: The project environment to retrieve secrets from.
>
>    * **Secret Path**: The folder path to retrieve secrets from.
>
> > [!TIP]
> >
> > If you need to sync secrets from multiple folder locations, check out [secret imports](https://infisical.com/docs/documentation/platform/secret-reference.md#secret-imports).
>
> 4. Configure the **Destination** to where secrets should be deployed, then click **Next**.
>
>    ![Configure Destination](https://mintlify.s3.us-west-1.amazonaws.com/infisical/images/secret-syncs/gcp-secret-manager/step-4.png)
>
>    * **GCP Connection**: The GCP Connection to authenticate with.
>
>    * **Project**: The GCP project to sync with.
>
>    * **Scope**: The GCP project scope that secrets should be synced to:
>      * **Global**: Secrets are available across all project regions. By default GCP uses automatic replication. You can optionally pin the data to specific regions using **Replica Regions** (see below).
>      * **Region**: Secrets are stored in a single specified region.
>
>    * **Replica Regions** (Global scope only): An optional list of regions used for GCP [user-managed replication](https://docs.cloud.google.com/secret-manager/docs/choosing-replication#user-managed). Leave this empty to use GCP automatic replication, or select one or more regions to control where your secrets are stored.
>
>    > [!WARNING]
>    >
>    > GCP does not allow changing a secret's replication policy after creation, so updates to Replica Regions only apply to newly synced secrets.
>
>    * **Region** (Region scope only): The single region that secrets should be synced to.
> 5. Configure the **Initial Sync Behavior** to determine how Infisical should resolve the first sync, then click **Next**.
>
>    ![Configure Initial Sync](https://mintlify.s3.us-west-1.amazonaws.com/infisical/images/secret-syncs/gcp-secret-manager/step-5.png)
>
>    * **Overwrite Destination Secrets**: Removes any secrets at the destination endpoint not present in Infisical.
>    * **Import Secrets (Prioritize Infisical)**: Imports secrets from the destination endpoint before syncing, prioritizing values from Infisical over GCP Secret Manager when keys conflict.
>    * **Import Secrets (Prioritize GCP Secret Manager)**: Imports secrets from the destination endpoint before syncing, prioritizing values from GCP Secret Manager over Infisical when keys conflict.
> 6. Configure the **Sync Options** to specify how secrets should be synced, then click **Next**.
>
>    ![Configure Options](https://mintlify.s3.us-west-1.amazonaws.com/infisical/images/secret-syncs/gcp-secret-manager/step-3.png)
>
>    * **Key Schema**: Template that determines how secret names are transformed when syncing, using `{{secretKey}}` as a placeholder for the original secret name and `{{environment}}` for the environment.
>
>    > [!NOTE]
>    >
>    > We highly recommend using a Key Schema to ensure that Infisical only manages the specific keys you intend, keeping everything else untouched.
>
>    * **Auto-Sync Enabled**: If enabled, secrets will automatically be synced from the source location when changes occur. Disable to enforce manual syncing only.
>    * **Disable Secret Deletion**: If enabled, Infisical will not remove secrets from the sync destination. Enable this option if you intend to manage some secrets manually outside of Infisical.
> 7. Configure the **Details** of your GCP Secret Manager Sync, then click **Next**.
>
>    ![Configure Details](https://mintlify.s3.us-west-1.amazonaws.com/infisical/images/secret-syncs/gcp-secret-manager/step-6.png)
>
>    * **Name**: The name of your sync. Must be slug-friendly.
>    * **Description**: An optional description for your sync.
> 8. Review your Secret Manager Sync configuration, then click **Create Sync**.
>
>    ![Confirm Configuration](https://mintlify.s3.us-west-1.amazonaws.com/infisical/images/secret-syncs/gcp-secret-manager/step-7.png)

> [tab] API
>
> To create a **GCP Secret Manager Sync**, make an API request to the [Create GCP
> Secret Manager Sync](https://infisical.com/docs/api-reference/endpoints/secret-syncs/gcp-secret-manager/create.md) API endpoint.
>
> The `destinationConfig` object accepts the following fields:
>
> * **scope** (`global` | `region`): How secrets are stored in GCP Secret Manager.
> * **projectId**: The ID of the GCP project to sync to.
> * **userReplicaLocationIds** (Global scope, optional): A list of region IDs (for example `["us-west4", "us-east1"]`) used for user-managed replication. If omitted or empty, GCP automatic replication is used. This applies only to secrets created after it is set.
> * **locationId** (Region scope): The single region ID (for example `"us-west4"`) that secrets should be synced to.
>
> ### Sample request
>
> ```bash Request theme={"dark"}
> curl    --request POST \
> --url https://app.infisical.com/api/v1/secret-syncs/gcp-secret-manager \
> --header 'Content-Type: application/json' \
> --data '{
>     "destinationConfig": {
>         "scope": "global",
>         "projectId": "infisical-test-playground"
>     },
>     "name": "my-gcp-sync",
>     "description": "this is an example secret sync",
>     "secretPath": "/",
>     "syncOptions": {
>         "initialSyncBehavior": "overwrite-destination"
>     },
>     "isAutoSyncEnabled": true,
>     "connectionId": "eec83609-5eb4-4d8d-9f6e-ded016984f0d",
>     "environment": "dev",
>     "projectId": "09eda1f8-85a3-47a9-8a6f-e27f133b2a36"
> }'
> ```
>
> ### Sample response
>
> ```bash Response theme={"dark"}
> {
>     "secretSync": {
>         "id": "aee02c4a-4a5f-488c-82dd-0b3164772871",
>         "name": "my-gcp-sync",
>         "description": "this is an example secret sync",
>         "isAutoSyncEnabled": true,
>         "version": 1,
>         "projectId": "09eda1f8-85a3-47a9-8a6f-e27f133b2a36",
>         "folderId": "1447389e-16fb-49ba-96fd-361b5a2522af",
>         "connectionId": "eec83609-5eb4-4d8d-9f6e-ded016984f0d",
>         "createdAt": "2025-01-27T12:28:59.408Z",
>         "updatedAt": "2025-01-27T12:28:59.408Z",
>         "syncStatus": "pending",
>         "lastSyncJobId": null,
>         "lastSyncMessage": null,
>         "lastSyncedAt": null,
>         "importStatus": null,
>         "lastImportJobId": null,
>         "lastImportMessage": null,
>         "lastImportedAt": null,
>         "removeStatus": null,
>         "lastRemoveJobId": null,
>         "lastRemoveMessage": null,
>         "lastRemovedAt": null,
>         "syncOptions": {
>             "initialSyncBehavior": "overwrite-destination"
>         },
>         "connection": {
>             "app": "gcp",
>             "name": "my-gcp-connection",
>             "id": "eec83609-5eb4-4d8d-9f6e-ded016984f0d"
>         },
>         "environment": {
>             "slug": "dev",
>             "name": "Development",
>             "id": "124e0392-4070-4b1c-900e-ced30cd55bf3"
>         },
>         "folder": {
>             "id": "1447389e-16fb-49ba-96fd-361b5a2522af",
>             "path": "/"
>         },
>         "destination": "gcp-secret-manager",
>         "destinationConfig": {
>             "projectId": "infisical-test-playground"
>         }
>     }
> }
> ```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.