Etienne Callies
11/25/2025, 2:10 PMprefect block register -m prefect.blocks.system
I can use terraform, or pulumi.Marvin
11/25/2025, 2:10 PMNate
11/25/2025, 2:13 PMEtienne Callies
11/25/2025, 2:15 PMNate
11/25/2025, 2:15 PMEtienne Callies
11/25/2025, 2:17 PMresource "prefect_block_type" "prefect-block-type-json" {
name = "json"
slug = "json"
}Nate
11/25/2025, 2:18 PMvariables (can be any JSON value, including a string) have superseded JSON / string blocksso, this is why i mentioned this
Marvin
11/25/2025, 2:18 PMcurl -X POST "$PREFECT_API_URL/api/block_types/install_system_block_types" \
-H "Authorization: Bearer $PREFECT_API_KEY"
- Code references:
- API route: POST /block_types/install_system_block_types
- Implementation: installs Webhook, Secret, LocalFileSystem
2) CLI in a Kubernetes init container/Job
- Still valid in 3.x:
prefect block register -m prefect.blocks.system # Secret
prefect block register -m prefect.blocks.webhook # Webhook
prefect block register -m prefect.filesystems # LocalFileSystem
- Verified CLI help:
prefect block register --help
3) Python API (init script or job)
- You can programmatically register types:
import asyncio
from prefect.blocks.system import Secret
from prefect.blocks.webhook import Webhook
from prefect.filesystems import LocalFileSystem
async def main():
for cls in (Secret, Webhook, LocalFileSystem):
await cls.register_type_and_schema()
asyncio.run(main())
- Note: saving an instance will auto-register the type/schema:
from prefect.blocks.system import Secret
Secret(value="my-secret").save("prod-secret", overwrite=True)
Code reference for auto-register in save():
Block.save registers type+schema automatically
Terraform / Pulumi patterns
- Terraform (simple, idempotent-enough for bootstrapping)
resource "null_resource" "install_system_blocks" {
provisioner "local-exec" {
command = "curl -sS -X POST ${var.prefect_api_url}/api/block_types/install_system_block_types -H 'Authorization: Bearer ${var.prefect_api_key}'"
}
}
- Then create block documents (e.g., a Secret) either:
- via a small Python script run in a provisioner
- or using an HTTP resource to POST to /api/block_documents (you’ll need to fetch the Secret block_type_id and block_schema_id first)
- Pulumi
- Use a Command/HTTP call in your stack to POST the same endpoint before any block document creation.
- Then create block documents in code, e.g.:
# run as a step in your Pulumi program or as a pre-step script
import asyncio
from prefect.client.orchestration import get_client
from prefect.blocks.system import Secret
async def setup():
async with get_client() as client:
# ensure protected system blocks exist (server-side)
await client.request("POST", "/block_types/install_system_block_types")
# create a secret block document
await Secret(value="super-secret").save("db-password", overwrite=True)
asyncio.run(setup())
Using Variables instead of the old JSON block
- Variables are the 3.x replacement for JSON config:
prefect variable set my-config '{"key": "value"}'
- Load in code:
from prefect.variables import get_variable
cfg = get_variable("my-config")
- CLI verified:
prefect variable --help
Source links for the system blocks
- Secret: prefect.blocks.system
- Webhook: prefect.blocks.webhook
- LocalFileSystem: prefect.filesystems
Quick guidanceMarvin
11/25/2025, 2:18 PMNate
11/25/2025, 2:18 PMEtienne Callies
11/25/2025, 2:21 PMNate
11/25/2025, 2:21 PMbut there are tf resources for both variables and blocks (e.g. Secret block)
Nate
11/25/2025, 2:22 PMEtienne Callies
11/25/2025, 2:23 PMNate
11/25/2025, 2:24 PMBlock subclass that is not already defined in prefectEtienne Callies
11/25/2025, 2:25 PMNate
11/25/2025, 2:28 PM» docker run -p 4200:4200 --rm -d prefecthq/prefect:3.6.2-python3.14 -- prefect server start --host 0.0.0.0
15ef8a0f5b9b560277e2c1da742a436ce229b2f91ef8f6fab0b3dc29c128a040
» uvx prefect config view
🚀 you are connected to:
<http://127.0.0.1:4200>
PREFECT_PROFILE='oss'
PREFECT_API_URL='<http://127.0.0.1:4200/api>' (from profile)
PREFECT_LOGGING_LEVEL='INFO' (from profile)
» uvx prefect block type ls | rg secret
│ aws-secret │ Manages a secret in │ prefect block create │
│ │ AWS's Secrets Manager │ aws-secret │
│ gcpsecret │ Manages a secret in │ prefect block create │
│ │ Google Cloud Platform's │ gcpsecret │
│ secret │ A block that represents │ prefect block create │
│ │ a secret value │ secretNate
11/25/2025, 2:28 PMEtienne Callies
11/25/2025, 2:54 PMEtienne Callies
11/25/2025, 3:02 PMNate
11/25/2025, 3:02 PM