<@ULVA73B9P> in prefect.yaml file, can we have a c...
# ask-marvin
f
@Marvin in prefect.yaml file, can we have a conditional block like {if env==test} push: *ecr_push {else} push: null
m
thought for 480.0 seconds
Short answer: no—prefect.yaml does not support inline conditionals (if/else). It’s plain YAML with Prefect’s placeholder interpolation, so you can’t do something like “if env == test then use anchor, else null”. What you can do: - Use YAML anchors/aliases to DRY up config, but you must select them explicitly (no conditional activation). - Template values from environment variables using placeholders like
{{ env.MY_VAR }}
. - Define separate deployments per environment (one uses
push: *ecr_push
, another uses
push: null
) and deploy the one you need. - Or drive a boolean via an env var, e.g.
push: "{{ env.PUSH_IMAGE }}"
, then set
PUSH_IMAGE=true
or
false
in your CI/env (note: this is string-substitution; ensure the target field accepts booleans or handle accordingly). Examples - Two deployments:
Copy code
deployments:
  - name: my-flow-test
    # ...
    push: *ecr_push

  - name: my-flow-dev
    # ...
    push: null
- Environment-driven toggle:
Copy code
deployments:
  - name: my-flow
    # ...
    push: "{{ env.PUSH_IMAGE }}"
Then set
PUSH_IMAGE=true
(test) or
PUSH_IMAGE=false
(other). If you’re actually referring to a specific “push” step/packager (e.g., pushing a Docker image to ECR), share a snippet of your prefect.yaml and I can show the best pattern for that use case. Docs: - Prefect YAML reference: prefect.yaml - Settings & profiles (to manage env-specific values): Settings and profiles