Devih
12/10/2025, 4:22 AMMarvin
12/10/2025, 4:22 AMMarvin
12/10/2025, 4:28 AMDevih
12/10/2025, 4:47 AMMarvin
12/10/2025, 4:47 AMMarvin
12/10/2025, 4:50 AMNate
12/10/2025, 5:12 AMDevih
12/10/2025, 7:28 AMMarvin
12/10/2025, 7:28 AMMarvin
12/10/2025, 7:31 AM# If the automation is in your current workspace
terraform import prefect_automation.my_auto "automation-id-uuid"
# If it lives in another workspace
terraform import prefect_automation.my_auto "automation-id-uuid,workspace-id-uuid"
Example Terraform Automation (runs a deployment when a custom event arrives):
resource "prefect_automation" "webhook_trigger" {
name = "webhook-triggered-deployment"
description = "Runs deployment on external webhook event"
enabled = true
trigger = {
event = {
posture = "Reactive"
expect = ["external.event.happened"]
match = jsonencode({ "prefect.resource.id" = "prefect.flow-run.*" })
threshold = 1
within = 0
}
}
actions = [
{
type = "run-deployment"
source = "selected"
deployment_id = prefect_deployment.example_deployment.id
parameters = jsonencode({})
}
]
}
Tips to avoid conflicts:
- One owner per resource: Terraform OR Python, not both.
- If switching ownership to Terraform, import existing resources and remove Python code that mutates them.
- Use Terraform for stable config (Automations, Work Pools, Variables, Service Accounts). Use Python for runtime behavior (trigger runs, read state).
- If you absolutely must mix, consider Terraform lifecycle { ignore_changes = [...] } for specific fields — but this weakens IaC guarantees.
Useful links:
- Provider docs: Terraform Registry: Prefect provider
- Automation resource docs: prefect_automation
- Examples: provider examples
- API parity tracker: API parity matrix
- Prefect IaC guidance (Prefect 3.x): Infrastructure as Code with Prefect
If you share how you’re defining the Automation in Python (trigger + actions), I can translate it into a Terraform resource for you and outline the exact import steps for your workspace.