Skip to main content
Prerequisites:
  • Set up and add secrets to Infisical Cloud
  • Create a GCP Connection 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 Secret Syncs Tab Secret Syncs Tab
  • Ensure your network security policies allow incoming requests from Infisical to this secret sync provider, if network restrictions apply.
  1. Navigate to Project > Integrations and select the Secret Syncs tab. Select the Add Sync button. Secret Syncs Tab
  2. Select the GCP Secret Manager option. Select GCP Secret Manager
  3. Configure the Source from where secrets should be retrieved, then click Next. Configure Source
    • Environment: The project environment to retrieve secrets from.
    • Secret Path: The folder path to retrieve secrets from.
If you need to sync secrets from multiple folder locations, check out secret imports.
  1. Configure the Destination to where secrets should be deployed, then click Next. Configure Destination
    • 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. Leave this empty to use GCP automatic replication, or select one or more regions to control where your secrets are stored.
    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.
  2. Configure the Initial Sync Behavior to determine how Infisical should resolve the first sync, then click Next. Configure Initial Sync
    • 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.
  3. Configure the Sync Options to specify how secrets should be synced, then click Next. Configure Options
    • 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.
    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.
  4. Configure the Details of your GCP Secret Manager Sync, then click Next. Configure Details
    • Name: The name of your sync. Must be slug-friendly.
    • Description: An optional description for your sync.
  5. Review your Secret Manager Sync configuration, then click Create Sync. Confirm Configuration

Least-privilege permissions

The GCP Connection setup grants the service account the Secret Manager Admin role on the whole project. If the sync uses a Key Schema with a fixed prefix, such as INFISICAL_{{secretKey}}, you can limit the service account to the secrets whose names start with that prefix. The sync can still list all secret names and create new secrets, but it can only read, update, and delete secrets with the prefix. The prefix is the part of the key schema before {{secretKey}}, with {{environment}} replaced by the environment’s slug. For example, if the key schema is {{environment}}-{{secretKey}} and the sync reads from the prod environment, the prefix is prod-. Replace the service account’s Secret Manager Admin role with two custom roles on the project:
  1. A role without a condition, with the following permissions:
    • secretmanager.secrets.list and secretmanager.secrets.create, which the sync needs to find and create secrets
    • resourcemanager.projects.get, serviceusage.services.get, and secretmanager.locations.list, which the Infisical UI needs to list your projects and regions when you create the sync
  2. A role with secretmanager.versions.access, secretmanager.versions.add, and secretmanager.secrets.delete, with a condition that matches the prefix.
Google Cloud checks the permissions in the first role on the project, not on individual secrets, so a condition on the secret name would block them. None of them let the service account read secret values. The following commands create both roles and grant them. Replace INFISICAL_ with your prefix:
Google Cloud adds up every role a service account has, so the service account keeps access to every secret until you remove the Secret Manager Admin and Service Usage Admin roles that the GCP Connection setup granted:
If you only create syncs through the API or Terraform, you can leave resourcemanager.projects.get, serviceusage.services.get, and secretmanager.locations.list out of the first role. Before you rely on this setup, check the following:
  • End the prefix with a separator such as _ or -, because INFISICAL also matches INFISICAL2_TOKEN
  • If the key schema starts with {{secretKey}}, such as {{secretKey}}_PROD, the condition has no prefix to match, so this setup doesn’t apply
  • If the sync has no key schema, it manages every secret in the project, so it needs access to all of them
  • If the service account has another role that can read secret values, such as Owner or Secret Manager Secret Accessor, on the project or on the folder or organization above it, that role still gives it access to every secret
  • Don’t create secrets with the prefix outside Infisical, because the sync overwrites them and, unless Disable Secret Deletion is on, deletes them
  • If you change the prefix in the key schema, update the condition to match the new prefix
  • Google Cloud can take several minutes to apply IAM changes, so if the first sync fails with a permission error, wait and sync again