Creating deployment triggers
To enable the simple configuration of event-driven deployments, Prefect provides deployment triggers—a shorthand for creating automations that are linked to specific deployments to run them based on the presence or absence of events.Deployment triggers are a special case of automations where the configured action is always running a deployment.
prefect.yaml, .serve, and .deploy. At deployment time,
specified trigger definitions create linked automations triggered by events matching your chosen
grammar. Each trigger definition may include a jinja template
to render the triggering event as the parameters of your deployment’s flow run.
Define triggers in prefect.yaml
You can include a list of triggers on any deployment in a prefect.yaml file:
Scheduling delayed deployment runs
You can configure deployment triggers to run after a specified delay using theschedule_after field. This is useful for implementing opt-out workflows or providing review windows before automated actions:
schedule_after field accepts:
- ISO 8601 durations (e.g., “PT2H” for 2 hours, “PT30M” for 30 minutes)
- Seconds as integer (e.g., 7200 for 2 hours)
- Python timedelta objects in code
external.resource.pinged event and an external.resource.replied
event have been seen from my.external.resource:
Define deployment triggers using Terraform
You can also set up a deployment trigger via Terraform resources, specifically via theprefect_automation resource.
Define triggers in .serve and .deploy
To create deployments with triggers in Python, the trigger types DeploymentEventTrigger,
DeploymentMetricTrigger, DeploymentCompoundTrigger, and DeploymentSequenceTrigger can be imported
from prefect.events:
Pass triggers to prefect deploy
You can pass one or more --trigger arguments to prefect deploy as either a JSON string or a
path to a .yaml or .json file.
triggers.yaml file could have many triggers defined:
test-deployment after running prefect deploy.
Note that deployment triggers contribute to the total number of automations in your workspace.