Hi everyone, I am trying to run ECS Tasks on AWS. ...
# ask-community
a
Hi everyone, I am trying to run ECS Tasks on AWS. I setup a self-hosted Prefect server, and a worker service that submits tasks to ECS. However, these tasks are not running correctly. These tasks are Docker containers that I have deployed on the self-hosted prefect server (and I run them on there). I think the main problem is that Fargate is running on x86_64 and these are ARM. I can't figure out how to get ARM running on Fargate and if I switch the built to x86_64/AMD, then the container isn't pulled correctly from ECS. I am not sure how to remedy this and would like some help in figuring it out. I have pasted the details in the comment on the yaml/code. I have tried editing the base worker template and nothing happens. I decided to then create a custom task definition and now instead of getting the failure
exec /usr/bin/tini: exec format error
I got the PREFECT in ASCII and then nothing which I imagine is because the Prefect Task/RunId is invalid? I'm not sure what to make of the entire thing and I am at a loss of what to do from here.
Prefect.yaml:
Copy code
name: ecs-worker-guide

pull:
- prefect.deployments.steps.set_working_directory:
    directory: /opt/prefect/ecs-worker-guide

# build section allows you to manage and build docker images
build:
- prefect_docker.deployments.steps.build_docker_image:
    id: build_image
    requires: prefect-docker>=0.3.1
    image_name: <hidden>.<http://dkr.ecr.us-east-2.amazonaws.com/prefect-test-1|dkr.ecr.us-east-2.amazonaws.com/prefect-test-1>
    tag: latest
    dockerfile: auto

# push section allows you to manage if and how this project is uploaded to remote locations
push:
- prefect_docker.deployments.steps.push_docker_image:
    requires: prefect-docker>=0.3.1
    image_name: '{{ build_image.image_name }}'
    tag: '{{ build_image.tag }}'

 # the deployments section allows you to provide configuration for deploying flows
deployments:
- name: my_ecs_deployment
  version:
  tags: []
  description:
  entrypoint: flow.py:my_flow
  parameters: {}
  work_pool:
    name: my-ecs-pool
    work_queue_name:
    job_variables:
      image: '{{ build_image.image }}'
      cluster: "my-ecs-cluster"
      subnets: ["Hidden"]
      security_groups: ["Hidden"]
      execution_role_arn: "arn:aws:iam::<hidden>:role/PrefectECSRunnerTaskRole"
  schedules: []
flow.py
Copy code
from prefect import flow
from prefect.logging import get_run_logger

@flow
def my_flow():
    logger = get_run_logger()
    <http://logger.info|logger.info>("Hello from ECS!!")

if __name__ == "__main__":
    my_flow()
More details in this thread: https://prefect-community.slack.com/archives/C079VLLH5D3/p1763054050035219 But I think the entry to Docker is wrong? is there a specific work pool I should be configuring to work with docker?