defining the name of task definition json to run ecs task in github actions

0

I haven't been able to define task definition file in GitHub actions to run the task of deploying a container with image stored in my repo in ECR. The error I get is:

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

So, I believe this happened because of incorrect path mapping or directories. So, what is the right way to specify the name of task json files?
Here's how I have done it:

    - 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: adp-ecs-container  
        image: ${{ steps.build-image.outputs.image }}  

for more information and all the relevant screenshots:
https://stackoverflow.com/questions/64538337/github-actions-error-task-definition-file-does-not-exist-when-pushing-and

asked 3 years ago2840 views
2 Answers
0

I hadn't included the task-definition file in my github repo, which github actions searched when defining task definition.

answered 3 years ago
0

I faced the same issue, then I figured out that I need to download the task definition first then update it with the new container image. that solved the issue and I was able to deploy to ECS.

- name: Download task definition
   run: |
          aws ecs describe-task-definition --task-definition ${{ secrets.ECS_TASK_DEFINITION }} \
          --query taskDefinition > task-definition.json
      
- 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: task-definition.json
          container-name: ${{ secrets.ECS_CONTAINER_NAME }}
          image: ${{ steps.build-image.outputs.image }}
answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions