<@ULVA73B9P> how do disable auto work pool creatio...
# ask-marvin
f
@Marvin how do disable auto work pool creation for ecs worker?
m
thought for 548.9 seconds
Short answer: you can’t with the CLI. In Prefect 3.x,
prefect worker start
will auto-create the work pool if it doesn’t exist, and there’s no flag or env var to disable that for the ECS worker. Two ways to get the behavior you want: - Pre-create the ECS work pool (no auto-creation will occur if the pool already exists):
Copy code
# Ensure prefect-aws is installed so the ECS worker type is registered
pip install prefect-aws

prefect work-pool create "my-ecs-pool" --type ecs
prefect worker start --pool my-ecs-pool
- Start the worker programmatically and disable pool auto-creation:
Copy code
from prefect_aws.workers.ecs_worker import ECSWorker
import asyncio

async def main():
    worker = ECSWorker(
        work_pool_name="my-ecs-pool",
        name="my-ecs-worker",
        create_pool_if_not_found=False,  # disable auto-creation
    )
    await worker.start()

if __name__ == "__main__":
    asyncio.run(main())
Run that script in your ECS task container instead of the CLI. If the pool does not exist, the worker will log a warning and exit instead of creating it. If you want, I can share an example ECS task definition/CMD that invokes the Python entrypoint instead of
prefect worker start
.