jason
05/07/2024, 5:34 PMDylan
jason
05/07/2024, 6:19 PMDylan
Dylan
jason
05/07/2024, 6:30 PMjason
05/07/2024, 6:30 PMDylan
Dylan
jason
05/07/2024, 6:40 PMEdward Park
05/07/2024, 6:47 PMprefect_work_pools
terraform resourcejason
05/07/2024, 6:48 PMEdward Park
05/07/2024, 6:57 PMworker
Fargate recipe, which should give you a good example of the necessary TF / AWS resources (eg. iam, execution policy, ecs cluster/service)
you may need to tweak it a bit for your specific requirements, but our recipes are created from working examples that we’ve set up with our users/customers
https://github.com/PrefectHQ/prefect-recipes/tree/main/devops/infrastructure-as-code/aws/tf-prefect2-ecs-workerjason
05/07/2024, 6:58 PMjason
05/07/2024, 8:55 PMEdward Park
05/07/2024, 9:00 PMjason
05/07/2024, 9:01 PMFailed to submit flow run 'a8411c17-0f0e-40c4-b0e8-062dc7b02b1c' to infrastructure.
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/prefect/workers/base.py", line 904, in _submit_run_and_capture_errors
result = await self.run(
File "/usr/local/lib/python3.10/site-packages/prefect_aws/workers/ecs_worker.py", line 639, in run
) = await run_sync_in_worker_thread(
File "/usr/local/lib/python3.10/site-packages/prefect/utilities/asyncutils.py", line 136, in run_sync_in_worker_thread
return await anyio.to_thread.run_sync(
File "/usr/local/lib/python3.10/site-packages/anyio/to_thread.py", line 33, in run_sync
return await get_asynclib().run_sync_in_worker_thread(
File "/usr/local/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 877, in run_sync_in_worker_thread
return await future
File "/usr/local/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 807, in run
result = context.run(func, *args)
File "/usr/local/lib/python3.10/site-packages/prefect_aws/workers/ecs_worker.py", line 755, in _create_task_and_wait_for_start
self._wait_for_task_start(
File "/usr/local/lib/python3.10/site-packages/prefect_aws/workers/ecs_worker.py", line 1033, in _wait_for_task_start
raise type(code, (RuntimeError,), {})(reason)
prefect_aws.workers.ecs_worker.TaskFailedToStart: CannotPullContainerError: pull image manifest has been retried 5 time(s): failed to resolve ref docker.io/prefecthq/prefect:2.18.3-python3.10: failed to do request: Head "https://registry-1.docker.io/v2/prefecthq/prefect/manifests/2.18.3-python3.10": dial tcp 54.227.20.253443 i/o timeout
025944 PM
prefect.flow_runs.worker
INFO
Completed submission of flow run 'a8411c17-0f0e-40c4-b0e8-062dc7b02b1c'
jason
05/07/2024, 9:02 PMjason
05/07/2024, 9:02 PMEdward Park
05/07/2024, 9:02 PMEdward Park
05/07/2024, 9:02 PMjason
05/07/2024, 9:02 PMjason
05/07/2024, 9:04 PMjason
05/07/2024, 9:10 PMjason
05/07/2024, 9:19 PMEdward Park
05/07/2024, 9:22 PMaws_ecs_service
TF resource? if so, you may need to set this to true
https://github.com/PrefectHQ/prefect-recipes/blob/main/devops/infrastructure-as-code/aws/tf-prefect2-ecs-worker/ecs.tf#L69
assign_public_ip = true
jason
05/07/2024, 9:23 PMEdward Park
05/07/2024, 9:25 PMjason
05/08/2024, 2:56 PMprefect_ecs_worker
jason
05/08/2024, 2:59 PMjason
05/08/2024, 3:05 PMaws_ecs_service
config which appears to be correct:
resource "aws_ecs_service" "prefect_worker_service" {
name = "prefect-worker-${var.name}"
cluster = aws_ecs_cluster.prefect_worker_cluster.id
desired_count = var.worker_desired_count
launch_type = "FARGATE"
// Public IP required for pulling secrets and images
// https://aws.amazon.com/premiumsupport/knowledge-center/ecs-unable-to-pull-secrets/
network_configuration {
security_groups = [aws_security_group.prefect_worker.id]
assign_public_ip = true
subnets = var.worker_subnets
}
task_definition = aws_ecs_task_definition.prefect_worker_task_definition.arn
}
jason
05/08/2024, 3:30 PMEdward Park
05/08/2024, 8:37 PMEdward Park
05/08/2024, 8:37 PMEdward Park
05/08/2024, 8:37 PMjason
05/08/2024, 9:13 PM