Task definition file not found for deploying to AWS ECS

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 that AWS provides on GitHub Marketplace to push docker images to AWS ECR, 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: task-def.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:
Here’s me checking the existence of file and pushing the task from my terminal to AWS ECS:

And here’s the part of my “.github/workflows/aws.yml” in my repo for task definition (full 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 during executing tasks to deploy and start containers.

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

I couldn’t post more screenshots. So, for all the information: https://github.com/aws-actions/amazon-ecs-render-task-definition/issues/68#issue-729342570

@naveen-9697,

You can try to check with the steps below:

  1. Before the “Fill in the new image ID in the Amazon ECS task definition” step, set up a step to like as this.

    - name: List files
      run: ls -R
    

    This will list all the files in the working directory.

  2. From the listed files, check if the task definition file (ecs-task-definition.json) is existing.

    • If task definition file is existing, the problem should be that the “aws-actions/amazon-ecs-render-task-definition” action can’t recognize this file. There may be some issues occur the action. If so, I recommend that you can report an issue the appropriate engineering team for further investigation and evaluation on the action repository.

    • If the definition file isn’t existing, make sure it indeed is existing in the source files of your repository and have checkout the source files.
      If it is indeed existing in the repository, maybe the previous steps have deleted the task definition file.

1 Like

Thank you very much for trying to help me.

I fixed it. It had happened because, there was no file named ‘ecs-task-definition.json’ in github repo. I haven’t uploaded it with the thought that github will pull it from AWS.

1 Like