<@ULVA73B9P> can i define blocks in prefect.yaml?
# ask-marvin
i
@Marvin can i define blocks in prefect.yaml?
m
thought for 318.8 seconds
Short answer: No. In Prefect 3.x, you cannot define or create blocks inside prefect.yaml. That file is for configuring deployments (build/push/pull steps, schedules, work pool, etc.). Blocks must be created via the UI, Python, or the CLI. Ways to create/manage blocks - UI: Create and configure blocks directly in the Prefect UI. - CLI (verified): - List block types:
prefect block type ls
- Register block types from a module/file:
prefect block register -m <module>
or
-f <file.py>
- Open a link to create a block in the UI:
prefect block create <block_type_slug>
- List configured blocks:
prefect block ls
- Inspect a block:
prefect block inspect
- Delete a block:
prefect block delete
Docs: CLI: prefect block - Python API (example):
Copy code
from prefect.blocks.system import Secret

  Secret(value="super-secret").save("my-secret", overwrite=True)
Referencing blocks from prefect.yaml - While you can’t define blocks in YAML, you can reference existing blocks in your deployment steps (e.g., to pull code with credentials or read from object storage). If you share which integration you’re using (AWS, GitHub, GCS, etc.), I can provide a precise snippet for your case. Related docs - Blocks overview: Blocks concepts - prefect.yaml guide: prefect.yaml guide