Fugo Takefusa
11/03/2025, 1:32 AMMarvin
11/03/2025, 1:32 AMMarvin
11/03/2025, 1:44 AM{{ prefect.variables.* }} in prefect.yaml are rendered when you run prefect deploy. There isn’t a flag or escape to keep them for runtime evaluation, and workers do not re-template deployment job variables at run time.
Details and options:
- What gets rendered when:
- build and push sections: all placeholders are resolved at deploy time
- pull section: block references (and variables used there) are resolved at runtime by the worker
- deployment.job_variables (e.g., ECS image): treated as static infra overrides; they’re not re-rendered at runtime
Docs:
- prefect.yaml mechanics
- Prefect Variables
What you can do instead:
- If you truly need runtime resolution, move that usage into the pull section (that code runs on the worker at execution time and can reference Prefect Variables).
- If this value is for infrastructure (e.g., ECS job_variables.image), it must be concrete when the worker submits the run. In that case you’ll need to:
- re-run prefect deploy when the variable changes, or
- programmatically update the deployment’s infra overrides via the API before runs
- For values used inside your flow code (not infra), fetch at runtime:
from prefect import flow
from prefect.variables import Variable
@flow
def my_flow():
registry = Variable.get("ecr-registry")
# build your string here at runtime
Could you share where in your prefect.yaml you’re using {{ prefect.variables.ecr-registry }}? For example, is it in deployment: job_variables.image for an ECS work pool, or inside a pull step? With that, I can suggest the best pattern for your setup.