batuan
09/26/2025, 11:18 AMMarvin
09/26/2025, 11:18 AMMarvin
09/26/2025, 11:39 AMprefect deployment ls
- The CLI does not currently support creating automations, so create this via the Prefect Cloud UI (Automations) or the Automations API. Docs: Event triggers concept
JSON (replace the placeholders):
{
"name": "Run B when A completes",
"description": "When deployment A completes successfully, run deployment B.",
"enabled": true,
"triggers": [
{
"type": "event",
"match": {
"all": [
{
"event": "prefect.flow-run.Completed"
}
]
},
"match_related": {
"any": [
{
"resource": "prefect.deployment.DEPLOYMENT_A_UUID"
}
]
}
}
],
"actions": [
{
"type": "run-deployment",
"deployment_id": "DEPLOYMENT_B_UUID",
"parameters": {},
"job_variables": {}
}
]
}
YAML (same fields, different format):
name: Run B when A completes
description: When deployment A completes successfully, run deployment B.
enabled: true
triggers:
- type: event
match:
all:
- event: prefect.flow-run.Completed
match_related:
any:
- resource: prefect.deployment.DEPLOYMENT_A_UUID
actions:
- type: run-deployment
deployment_id: DEPLOYMENT_B_UUID
parameters: {}
job_variables: {}
Would you like me to fill these in if you share the names/IDs of Deployment A and B?batuan
09/26/2025, 3:37 PMMarvin
09/26/2025, 3:37 PMMarvin
09/26/2025, 3:38 PMdeployment_id
(UUID). It does not accept a deployment name/slug.
Why this is okay:
- Deployment IDs are stable. Updating code or schedules doesn’t change the ID; it only changes if you delete and recreate the deployment.
Workarounds if you really want to drive by name:
- Use a small webhook you control: have the automation call your webhook (via CallWebhook
), your service resolves the name → ID using Prefect’s API, then calls the Prefect “create flow run for deployment” endpoint. Helpful API docs:
- Read deployment by name
- Create flow run from deployment
- Or, just look up the ID once and keep using it; it’s usually the simplest.
If you want, share the names of Deployment A and B and I’ll grab their IDs and drop in a ready-to-use JSON/YAML automation for you. You can also get them yourself with:
prefect deployment ls
# or, for details including ID
prefect deployment inspect "flow-name/deployment-name"