Secrets
secrets: declares environment variables whose values are resolved when a DAG run starts.
For secrets that should be selected as part of a named runtime environment, use Runtime Profiles. Runtime profile secrets are managed outside the DAG YAML and selected with the profile at run start.
Dagu supports two secret declaration styles:
- Registry refs for secrets managed from Dagu's Web UI.
- Direct provider refs for existing DAG-based secrets such as
env,file,kubernetes,vault,aws, andgcp.
Both styles inject a target environment variable into the run. The value is resolved before steps start and is masked in Dagu-managed logs.
Registry Refs
Use ref when the secret value is managed in Dagu's secret registry:
secrets:
- name: DB_PASSWORD
ref: prod/db-passwordname is the environment variable exposed to steps. ref is the registry key. The DAG does not store the plaintext value or provider details.
Create or rotate the value from the standalone Secrets page:
- Select Global or a named workspace.
- Create a Dagu-managed secret with ref
prod/db-password. - Use
ref: prod/db-passwordin DAGs.
labels:
- workspace=payments
secrets:
- name: DB_PASSWORD
ref: prod/db-password
steps:
- name: migrate
run: ./migrate.shRegistry refs are resolved by scope:
| Secret scope | Resolution behavior |
|---|---|
| Global | Workspace-less secret available to all DAGs unless a more specific scope has the same ref |
| Named workspace | Secret for DAGs with the matching workspace=<name> label |
A DAG in workspace=payments first checks the payments secret scope, then the Global scope. It never reads another named workspace. A DAG without a workspace label uses Global directly.
Do not include the scope or workspace name in ref; use ref: prod/db-password, not ref: payments/prod/db-password. If a more specific scoped secret exists but is disabled, Dagu fails the run instead of falling back to a global secret with the same ref.
Registry refs resolve Dagu-managed secrets. For registry records backed by Vault, a cloud secret manager, or Kubernetes, request access from the Dagu team. Direct provider refs, described below, read those stores from DAG YAML.
SSH Credentials
An SSH or SFTP key, password, or passphrase can read a registry ref directly with { secret: <ref> }. The value resolves at run start together with secrets: and is masked the same way, but it is not exported as an environment variable. See Credentials from Secrets.
Direct Provider Refs
Use provider plus key when the DAG should fetch a secret directly from a provider at runtime:
secrets:
- name: DB_PASSWORD
provider: env
key: PROD_DB_PASSWORDThe current built-in direct provider registry contains:
| Provider | Source |
|---|---|
env | A variable from the context environment scope or the Dagu process environment |
file | The complete contents of one local file |
kubernetes | One data key from a Kubernetes Secret resource |
vault | One field from a HashiCorp Vault secret response |
aws | A secret value from AWS Secrets Manager |
gcp | A secret value from Google Secret Manager |
azure | A secret value from Azure Key Vault |
alibaba | A secret value from Alibaba Cloud KMS |
Existing DAGs that use provider and key continue to work. Direct provider refs do not require the Web UI secret registry.
secrets:
- name: API_TOKEN
provider: file
key: /run/secrets/api-token
- name: STRIPE_WEBHOOK_SECRET
provider: kubernetes
key: payments/stripe-webhook-secret
options:
namespace: prodSecret Reference Schema
Each item must use exactly one of these shapes:
# Registry ref
secrets:
- name: TARGET_ENV_NAME
ref: prod/example-secret# Direct provider ref
secrets:
- name: TARGET_ENV_NAME
provider: env
key: SOURCE_ENV_NAME
options:
option_name: option_value| Field | Required | Meaning |
|---|---|---|
name | Yes | Target environment variable injected into the run |
ref | Required for registry refs | Registry ref, for example prod/db-password |
provider | Required for direct provider refs | Resolver name. Built-in values are env, file, kubernetes, vault, aws, gcp, azure, and alibaba |
key | Required for direct provider refs | Provider-specific lookup key |
options | Direct provider refs only | Provider-specific string map |
Validation rules:
namemust be a valid environment variable name.namemust be unique inside the DAG.namemust not start withDAGU_.namemust not match a Dagu-managed run variable such asDAG_NAME,DAG_RUN_ID, orDAG_PARAMS_JSON.refmust be lowercase slug segments separated by/, for exampleprod/db-password.refcannot be combined withprovider,key, oroptions.- Direct provider refs require both
providerandkey.
Provider existence and backing secret availability are checked when the run resolves secrets. An unknown provider such as unknown-provider fails the run with unknown secret provider.
Literal Keys And Options
secrets[].key and secrets[].options are not evaluated with Dagu's variable engine. They are passed to the direct provider as literal strings.
This does not resolve SECRET_FILE_PATH:
env:
- SECRET_FILE_PATH: /run/secrets/api-token
secrets:
- name: API_TOKEN
provider: file
key: ${SECRET_FILE_PATH} # literal path, not expandedTo read a value loaded from .env, use the env provider:
# .env
PROD_API_TOKEN=token-from-dotenvdotenv: .env
secrets:
- name: API_TOKEN
provider: env
key: PROD_API_TOKENdotenv: is related, but it is not a secret provider. Dotenv files load normal DAG environment variables. A dotenv value becomes a masked secret only when a secrets: entry reads it through provider: env.
Resolution Time
When a DAG run starts, Dagu:
- Loads dotenv files into the DAG environment.
- Resolves all entries in
secrets:. - Adds resolved secret values to the run environment with source
secret. - Starts steps only if secret resolution succeeds.
If any secret fails to resolve, run initialization fails and steps do not execute. dagu dry attempts resolution but ignores failures, so a dry run still succeeds when a secret is missing. dagu validate checks YAML shape and DAG structure, but it does not contact providers and does not verify that a secret exists.
Distributed Runs
For distributed runs, the coordinator that owns the task resolves Dagu-managed registry refs for the active worker. It answers only refs that the DAG declares in secrets: or uses for SSH credentials. Nested child DAGs resolve refs against each child's workspace. Workers do not need the server secret store or data volume.
Direct provider refs resolve where the DAG executes. A distributed worker therefore needs the provider configuration, credentials, files, identity, and network access used by those refs. For example, a file provider path must exist on that worker.
Managed secret values travel over coordinator gRPC. Configure peer TLS or mTLS outside an isolated trusted network.
Variable Precedence
During step execution, the environment scope is layered so later layers override earlier layers:
- Step environment values, including evaluated
env:entries and container env entries for the step. - Output variables from dependency steps.
- Secrets.
- DAG-level environment values, including values loaded from dotenv files, runtime metadata, and params.
- Filtered process environment values.
This means a secret overrides DAG env: and dotenv values with the same name. This is allowed for backward compatibility with existing DAGs. A step-level env: value can still override the secret for that step.
env:
- DB_PASSWORD: visible-dag-env
secrets:
- name: DB_PASSWORD
provider: env
key: PROD_DB_PASSWORD
steps:
- name: uses-secret
run: ./migrate.sh
- name: overrides-for-one-step
env:
- DB_PASSWORD: local-test-password
run: ./test.shStorage For Dagu-Managed Secrets
Dagu-managed registry values are stored by Dagu in the internal secret store under the configured data directory:
<data_dir>/secretsThe file-backed implementation stores secret metadata and encrypted value versions. Plaintext values are write-only through the API and Web UI: after saving, Dagu does not return the value in API responses. Values are decrypted only when a run resolves the secret or dagu secret resolve reads it on the host.
The encryption key is resolved from the same data directory. Back up the data directory securely if you rely on Dagu-managed secrets.
Masking
Dagu creates a masker from non-empty resolved secret values, including SSH credentials read from the registry. The replacement string is *******.
The masker is applied to:
- Step stdout and stderr log writers.
- Step stdout and stderr redirect writers.
- Final
outputs.jsonvalues collected from string-formoutput: NAME,stdout.outputs, andoutputs.write. - Stored run status: error messages, output variables, published step outputs, including values written to
DAGU_OUTPUT_FILE, and step configuration. - Chat step messages immediately before they are sent to the LLM provider.
The matcher replaces each secret as written and as JSON escaping writes it inside a JSON string: with \", \\, \n, and \u escapes, including the HTML-safe form (< as \u003c) and the ASCII-only form (é as \u00e9). A secret inside JSON text, such as a provider's error body or a step that prints JSON, is masked in every place listed above. It does not mask empty values. It also does not mask values loaded through env: or dotenv: unless those values are resolved through secrets:.
Masking is not a process sandbox. The step process receives the raw secret in its environment and can write it to files, databases, APIs, child processes, or output variables used by later steps.
Within one run, a later step reads a published output with the secret intact. A run that reuses a stored step result instead of executing the step again reads the masked value, so each secret in a reused output reads as *******. This covers retry, resume after an approval or a human task, and runs that reuse another run's outputs.
Provider Pages
- Runtime Profiles
- Worker Deployment
- Web UI DAG Secret Refs
- Dotenv Loading
envProviderfileProvider- Kubernetes Provider
- HashiCorp Vault Provider
- AWS Secrets Manager Provider
- Google Secret Manager Provider
- Azure Key Vault Provider
- Alibaba Cloud KMS Provider
Complete Example
# /srv/app/.env
SLACK_BOT_TOKEN=xoxb-from-dotenvworking_dir: /srv/app
labels:
- workspace=payments
dotenv: .env
secrets:
# Dagu-managed registry secret in the payments workspace
- name: DB_PASSWORD
ref: prod/db-password
# Existing direct provider secrets
- name: SLACK_TOKEN
provider: env
key: SLACK_BOT_TOKEN
- name: API_KEY
provider: vault
key: kv/data/prod/api/key
- name: STRIPE_WEBHOOK_SECRET
provider: kubernetes
key: payments/stripe-webhook-secret
options:
namespace: prod
steps:
- name: deploy
run: ./deploy.sh
env:
- DATABASE_URL: postgres://app:${env.DB_PASSWORD}@db/prod
- AUTH_HEADER: "Bearer ${env.API_KEY}"
