question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

“Error: Task definition file does not exist: ” when deploying Docker images to AWS ECS

See original GitHub issue

I am trying to push docker images from GitHub Actions to AWS ECR then to ECS with a task to deploy the latest container in AWS ECS.

I am using the default aws.config file with changes only for AWS ECR repository name, AWS ECS cluster name and it’s service name and docker image details to push docker images to AWS ECR to which could then to deployed as containers to AWS ECS by defining tasks. And I got an error message with defining tasks to deploy to ECS(in the section “Fill in the new image ID in the Amazon ECS task definition” in aws.yml) and it is:

Error: Task definition file does not exist: ecs-task-definition.json

Some information to prove everything is in place(presumably):
Here’s me checking the existence of file and pushing the task from my terminal to AWS ECS: enter image description here

And here’s that very task definition with the revision number and task’s family name shown in screenshot above: enter image description here

So, as you can see task-definition file does exist, but GitHub doesn’t recognise it. What has caused this error and how do I fix this?

Here’s the complete build screenshot: enter image description here

and this is the error: enter image description here

And here’s the part of my “.github/workflows/aws.yml” in my repo for task definition (file can be found here in my repository)

    - name: Fill in the new image ID in the Amazon ECS task definition
      id: task-def
      uses: aws-actions/amazon-ecs-render-task-definition@v1
      with:
        task-definition: ecs-task-definition.json
        container-name: aws-dock-p-cont
        image: ${{ steps.build-image.outputs.image }}

Images are being pushed to my ECR repository without any problems, but the problem comes right before executing tasks to use those images and deploy as containers.

EDIT: Here’s the cluster I have used in aws.yml file: enter image description here Here’s the role I have specified in the task json file: enter image description here

I have done as described in this article.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6

github_iconTop GitHub Comments

11reactions
chorsnellcommented, Jul 16, 2021

for anyone else finding this, it turns out task-definition: does not obey working_directory, so the relative path needs to be from the root of your repo

1reaction
RulerOfcommented, Aug 27, 2022

In my case, I had forgotten to run the checkout step.

Read more comments on GitHub >

github_iconTop Results From Across the Web

defining the name of task definition json to run ecs task in ...
... of deploying a container with image stored in my repo in ECR. The error I get is: Error: Task definition file does...
Read more >
Thank you so much for this blog. Very very comprehensive and I ...
Deploy your Node app to AWS Container Service via GitHub Actions & build a pipeline ... Error: Task definition file does not exist:...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found