Hey everyone! I managed to write the necessary In...
# prefect-community
k
Hey everyone! I managed to write the necessary Infrastructure as Code (via Pulumi) for a light-weight Prefect agent that runs as an ECS Service. I was hoping to get a nice welcome message in the logs. Unfortunately, I get the
prefect
cli help message over and over again. ECS console shows a list of
STOPPED
tasks, which I'm assuming are various attempts to start the service and keep it running.
โœ… 2
Dockerfile for Prefect Agent
Copy code
FROM prefecthq/prefect:2-python3.10

# Install dependencies for AWS
RUN pip install s3fs prefect-aws

# Register AWS block types
RUN prefect block register -m prefect_aws.ecs
Relevant container configuration, from ECS Task Definition for Prefect Agent, ECS Service
Copy code
{
  "name": "container",
  "image": "long-image-identifier",
  "cpu": 0,
  "portMappings": [],
  "essential": true,
  "entryPoint": [
    "bash",
    "-c"
  ],
  "command": [
    "prefect",
    "agent",
    "start",
    "-q",
    "main"
  ],
  "environment": [],
  "mountPoints": [],
  "volumesFrom": [],
  "secrets": [
    {
      "name": "PREFECT_API_URL",
      "valueFrom": "long-arn"
    },
    {
      "name": "PREFECT_API_KEY",
      "valueFrom": "long-arn"
    }
  ],
  "stopTimeout": 120,
  "logConfiguration": {
    "logDriver": "awslogs",
    "options": {
      "awslogs-group": "my-log-group",
      "awslogs-region": "us-east-1",
      "awslogs-stream-prefix": "container"
    }
  }
}
I think
prefect
is installed correctly, because I'm getting the CLI help message. This makes me wonder if my supplied
command
is wrong. I'd want the service to run
Copy code
prefect agent start -q main
c
Hi Kelvin, not sure if you saw this, but we have some existing recipes that tackle this? https://github.com/PrefectHQ/prefect-recipes/tree/main/devops/infrastructure-as-code/aws/tf-prefect2-ecs-agent
Here is an example task definition:
I donโ€™t think you need the bash entrypoint
โœ… 1
๐ŸŽ‰ 1
k
Hey! Thanks so much for the quick reply I just noticed that I'm using
entryPoint: ["bash" "-c"]
which is wrong. I have been setting up my team's resources by following the
dataflow-ops
repository. Thank you for these additional links!
FIXED!
๐Ÿ™Œ 1