Hi folks. I'm trying to get my tasks to log to Clo...
# ask-community
s
Hi folks. I'm trying to get my tasks to log to Cloudwatch through the ECSRun configuration. I'm testing out specifying a yaml config in
task_definition_path
, and running into an issue. My flows run on different ECR images, so I don't want to specify the image in the Task Definition file. However, when I leave it out, and specify it in the constructor:
Copy code
run_config = ECS_RUN(image=ECR_IMAGE, task_definition_path='s3://<path>'
I get an error that container.image should not be empty. My task definition file that I'd like to use is:
Copy code
networkMode: awsvpc
cpu: 1024
memory: 2048
containerDefinitions:
  - name: flow
    logConfiguration:
      logDriver: awslogs
      options:
        awslogs-group: test_prefect_log_group
        awslogs-region: us-east-1
        awslogs-stream-prefix: ecs-prefect
        awslogs-create-group: "True"
Is there any way to use a Task Definition file without specifying an image? Or is there another/better way to make sure my ECS tasks get logged? Thanks for any help.
discourse 1
k
Even if it’s in the task_definition, it will get overriden by the RunConfig
s
Oh, interesting. So I can put a non-existent image name in the task_definition to get past the error, and the RunConfig will override it?
k
I believe so because 3 things are merged before the ECS task is registered. The agent task_definition , the run config task definition, and the run configuration like cpu and memory. The priority is in that order also, so the RunConfig should override. Still though, I am not seeing why you get this error because the default task definition has none, but I guess we must be filling it.
upvote 2
s
Yep, it worked like I wanted with a non-existent image
The full error when I tried to leave the image name out of the task_definition file was:
Copy code
An error occurred (ClientException) when calling the RegisterTaskDefinition operation: Container.image should not be null or empty.
k
Ah ok. Does that work for you then?
s
Yep, I am all set
🙌 1
k
Nice!
s
Thanks as always for the quick help, Kevin!
153 Views