Skip to content

SOPS: Secrets OPerationS

The SOPS provider integrates with SOPS to enable reading and writing of secrets encrypted at rest in local files.

sops://path/to/secret[?key=value[&key=value]...]
  • path/to/secret — required path to the encrypted file (absolute or relative)

  • ?key=value — optional query parameter, refer to the Query Parameters section for available parameters.

  • &key=value — additional parameters

Excepting the SecretSpec-specific format parameter, refer to the SOPS documentation for the purpose and usage of each parameter.

Provider URL Query Parameter NamePurpose
formatOverrides the extension-based file format detection. Valid values: dotenv env ini json yaml
Provider URL Query Parameter NameCorresponding Environment Variable
sops_configSOPS_CONFIG
sops_decryption_orderSOPS_DECRYPTION_ORDER
sops_editorSOPS_EDITOR
sops_enable_local_keyserviceSOPS_ENABLE_LOCAL_KEYSERVICE
sops_keyserviceSOPS_KEYSERVICE
Provider URL Query Parameter NameCorresponding Environment Variable
age_key_cmdSOPS_AGE_KEY_CMD
age_key_fileSOPS_AGE_KEY_FILE
age_recipientsSOPS_AGE_RECIPIENTS
age_ssh_private_key_cmdSOPS_AGE_SSH_PRIVATE_KEY_CMD
age_ssh_private_key_fileSOPS_AGE_SSH_PRIVATE_KEY_FILE
Provider URL Query Parameter NameCorresponding Environment Variable
aws_access_key_idAWS_ACCESS_KEY_ID
aws_profileAWS_PROFILE
aws_regionAWS_REGION
kms_arnSOPS_KMS_ARN
Provider URL Query Parameter NameCorresponding Environment Variable
gcp_kms_client_typeSOPS_GCP_KMS_CLIENT_TYPE
gcp_kms_endpointSOPS_GCP_KMS_ENDPOINT
gcp_kms_idsSOPS_GCP_KMS_IDS
gcp_kms_universe_domainSOPS_GCP_KMS_UNIVERSE_DOMAIN
Provider URL Query Parameter NameCorresponding Environment Variable
azure_client_idAZURE_CLIENT_ID
azure_keyvault_urlsSOPS_AZURE_KEYVAULT_URLS
azure_tenant_idAZURE_TENANT_ID
Provider URL Query Parameter NameCorresponding Environment Variable
pgp_fpSOPS_PGP_FP
Provider URL Query Parameter NameCorresponding Environment Variable
gpg_execSOPS_GPG_EXEC
Provider URL Query Parameter NameCorresponding Environment Variable
hc_vault_addrVAULT_ADDR
hc_vault_allowlistSOPS_HC_VAULT_ALLOWLIST
Provider URL Query Parameter NameCorresponding Environment Variable
huawei_kms_idsSOPS_HUAWEICLOUD_KMS_IDS
huawei_sdk_project_idHUAWEICLOUD_SDK_PROJECT_ID

Secret values used to authenticate SOPS belong in a provider alias’s credentials map, not in the SOPS URI.

Credential Environment fallback Available since
age_key SOPS_AGE_KEY 0.17+
aws_secret_access_key AWS_SECRET_ACCESS_KEY 0.17+
azure_client_secret AZURE_CLIENT_SECRET 0.17+
hc_vault_token VAULT_TOKEN 0.17+
huawei_sdk_ak HUAWEICLOUD_SDK_AK 0.17+
huawei_sdk_sk HUAWEICLOUD_SDK_SK 0.17+
google_oauth_access_token GOOGLE_OAUTH_ACCESS_TOKEN 0.17+

See the complete provider credential reference for all supported providers and environment fallbacks.

For example, this alias loads an age identity from the system keyring and passes it only to the SOPS child process:

secretspec.toml
[providers.sops_age]
uri = "sops://secrets.enc.yaml?age_recipients=age1example"
[providers.sops_age.credentials]
age_key = "keyring"
[profiles.production.defaults]
providers = ["sops_age"]

When a credential is not declared on the alias, SOPS can still use its normal environment variable.

SecretSpec asks SOPS to emit JSON when decrypting, then uses one lookup path for YAML, JSON, dotenv, and INI files. When ?format= is present, SecretSpec also passes the corresponding SOPS input type so filenames such as .env.production.enc?format=dotenv work correctly.

SOPS does not support --input-type ini, so ?format=ini is accepted only when the filename itself ends in .ini. Without ?format=, the filename must end in .yaml, .yml, .json, .env, .dotenv, or .ini; an unrecognized extension is reported as a configuration error.

YAML and JSON single-file layouts can nest values by project and profile. INI uses profile sections, while dotenv is always flat; in a single dotenv file, the same key therefore cannot hold different values for different profiles. Use a templated path such as secrets/{project}/.env.{profile}.enc?format=dotenv when profiles need separate dotenv values.

Terminal window
$ secretspec set DATABASE_URL --provider 'sops://secrets.enc.json?age_key_file=key.txt&age_recipients=age1jpa8rf5qmrg6pw444fcgpkaxg8x4neueszrexzagdjpunjlgeyzq304w34'

Or, if keys.txt exists in a place discoverable by SOPS and .sops.yaml exists next to the project’s secretspec.toml, configure a creation rule:

.sops.yaml
creation_rules:
- path_regex: secrets\.enc\.json$
age: "age1jpa8rf5qmrg6pw444fcgpkaxg8x4neueszrexzagdjpunjlgeyzq304w34"

then:

Terminal window
$ secretspec set DATABASE_URL --provider sops://secrets.enc.json