Zivile
07/06/2025, 3:50 PMMarvin
07/06/2025, 3:50 PMMarvin
07/06/2025, 3:51 PMZivile
07/06/2025, 8:40 PMMarvin
07/06/2025, 8:40 PMMarvin
07/06/2025, 8:41 PMhcl
resource "prefect_deployment" "my_deployment" {
name = "my-deployment"
flow_path = "/path/to/flow.py"
entrypoint = "flow.py:my_flow"
work_pool_name = "my-work-pool"
infrastructure = {
type = "ecs" # or "kubernetes", depending on your infrastructure
env = {
MY_ENV_VAR = "value"
}
# Infrastructure-specific settings follow
}
}
2. For ECS-specific Configuration
hcl
resource "prefect_deployment" "ecs_deployment" {
# ... basic configuration ...
infrastructure = {
type = "ecs"
capacity_provider_strategy = [
{
capacity_provider = "your-capacity-provider"
weight = 1
base = 0
}
]
cluster = "your-ecs-cluster"
task_role_arn = "your-task-role-arn"
# Other ECS-specific settings as needed
}
}
Key considerations:
1. Work Pool Type Matters:
- For ECS: Use either Push work pools (for Fargate) or Hybrid work pools (for EC2)
- For GPU workloads: Must use Hybrid work pools with proper capacity provider strategy
2. Important Infrastructure Settings:
- Specify environment variables using the env
block
- Include necessary IAM roles and permissions
- Configure networking settings if required
- Specify resource requirements (CPU, memory)
3. Best Practices:
- Keep sensitive values in Terraform variables or secrets management
- Use data sources to reference existing AWS resources
- Consider using workspaces for different environments
4. Common Gotchas:
- For ECS GPU workloads, you must use capacity provider strategy, not launch type
- Ensure all referenced resources (clusters, roles, etc.) exist before deployment
- Check that the specified image contains all necessary dependencies
For more detailed information about managing Prefect deployments with Terraform, you can refer to the official blog post.
Would you like more specific details about any particular infrastructure type or configuration?