decK can read environment variables at runtime, allowing you to pass per-environment configuration directly in your state files.
Note: For configuring decK’s connection and behavior using environment variables (as substitutes for CLI flags), see decK configuration.
To allow decK to read environment variables, reference them as ${{ env "DECK_*" }} in your state file.
The following example configures a Vault token using a decK environment variable:
_format_version: "3.0"
vaults:
- name: hcv
description: My custom HashiCorp Vault
prefix: my-hcv
config:
host: "localhost"
kv: "v2"
mount: "secret"
port: 8200
protocol: "https"
token: ${{ env "DECK_HCV_TOKEN" }}Copied!
To test, set the DECK_HCV_TOKEN environment variable and run deck gateway sync:
export DECK_HCV_TOKEN='YOUR_TOKEN_HERE'
deck gateway sync kong.yamlCopied!