Srinivas Kandukuri
07/16/2025, 4:02 AMMarvin
07/16/2025, 4:02 AMMarvin
07/16/2025, 4:03 AMpython
from prefect import run_deployment
# Define your ECS-specific job variables
ecs_job_variables = {
"cpu": "1024", # Example: 1 vCPU
"memory": "2048" # Example: 2GB RAM
}
# Run the deployment with custom CPU and memory
flow_run = run_deployment(
name="your-deployment-name/deployment-name",
job_variables=ecs_job_variables
)
The job_variables parameter allows you to override infrastructure-specific settings on a per-run basis. When using an ECS work pool, you can specify:
- `cpu`: The CPU units (in AWS ECS units where 1024 = 1 vCPU)
- `memory`: The memory in MB
A more complete example showing different resource configurations:
python
# Example 1: Running with minimal resources
flow_run_small = run_deployment(
name="your-deployment-name/deployment-name",
job_variables={
"cpu": "256", # 0.25 vCPU
"memory": "512" # 512MB RAM
}
)
# Example 2: Running with larger resources
flow_run_large = run_deployment(
name="your-deployment-name/deployment-name",
job_variables={
"cpu": "4096", # 4 vCPU
"memory": "8192" # 8GB RAM
}
)
Important notes:
1. The values for CPU and memory must be valid according to AWS Fargate's supported configurations. Not all CPU/memory combinations are valid in Fargate.
2. These overrides will only apply to this specific flow run and won't affect the default configuration in your task definition.
3. The values should be provided as strings, following AWS ECS conventions.
4. This override will only affect the specific task/flow run you're executing, not other runs of the same deployment.
If you need to verify that the override worked, you can check the AWS ECS console for the specific task that was created for your flow run, where you should see the custom CPU and memory values being applied.
Would you like me to provide more specific examples for certain CPU/memory combinations, or would you like to know more about valid Fargate configurations that you can use?