Hi <@ULVA73B9P>, how to use environment variables placeholder in prefect.toml?
x
Hi @Marvin, how to use environment variables placeholder in prefect.toml?
m
thought for 126.2 seconds
Short answer: you can’t. In Prefect 3.x,
prefect.toml
does not support environment variable placeholders or interpolation. Here are the supported ways to use environment-specific values: - Use environment variables directly (they take precedence over
prefect.toml
):
Copy code
# shell
  export PREFECT_API_URL="<https://my-api.example.com/api>"
  export PREFECT_LOGGING_LEVEL="DEBUG"
Then keep plain values (or defaults) in `prefect.toml`:
Copy code
[logging]
  level = "INFO"  # overridden by PREFECT_LOGGING_LEVEL if set
- For deployments, use environment variables in
prefect.yaml
with templating:
Copy code
deployments:
    - name: my-deployment
      tags:
        - "{{ $MY_DEPLOYMENT_TAG }}"   # reads the MY_DEPLOYMENT_TAG env var
      work_pool:
        name: "my-pool"
The
{{ $ENV_VAR_NAME }}
syntax is supported in
prefect.yaml
only (not in
prefect.toml
). - If you need different settings per environment, consider multiple profiles (no placeholders in
profiles.toml
either) and switch with
prefect profile use <name>
. If you can share which setting you’re trying to parameterize in
prefect.toml
, I can suggest the cleanest pattern for your setup.