aws-actions/amazon-ecs-render-task-definition

Q: Error: Invalid task definition: Could not find container definition with matching name

Closed this issue ยท 14 comments

I'm using this action recently and it works fine for many services. But yesterday I added a new one, and rendering fails with "Error: Invalid task definition: Could not find container definition with matching name".
As far as I see, my task definition uses the same container name as I pass to the action, so I couldn't understand what is wrong here.

"containerDefinitions": [
        {
            "name": "fc-core-pay-bin-server",
Run aws-actions/amazon-ecs-render-task-definition@v1
  with:
    task-definition: xxxx-task-definition.json
    container-name: fc-core-pay-bin-server

TIA,
Vitaly

Update: the same task definition and GH workflow work with amazon-ecs-render-task-definition@v1.1.2.
I'll be glad to send you debug output in private.

Any updates?

v1.1.2 appears to work, thanks @vitalykarasik. But it has set-output deprecation notice and might stop working after May 31.
v1.1.3 has this bug, described in the issue.

@roman-parkhunovskyi - it's good news for me, so I'm not crazy :-)
My plan B is forking v1.1.2, update @actions/core and rebuild - I already did that for about GHA (Slack notification). Of course, I'll publish it.

set-output deprecation notice and might stop working after May 31

Did GH already announce this date?

I'm also having this issue. When will they fix this?

Was able to resolve. Issue was lack of quotes around the name in the yaml file. The yaml file would parse but this would fail. Make sure that your container name is quoted.

@brennh-animoca - thanks! Can you please provide more details:

  1. "I'm also having this issue" - your original config didn't work with v1.1.3, but worked with v1.1.2?
  2. "Issue was lack of quotes around the name in the yaml file" - do you mean task definition file? I'm using JSON format, and as far as I see all strings are quoted. Can you please share some example?

I'm unclear what fixed it but i changed the task definition to have ALL hardcoded values until I got it working. Then when i went back through slowly, the only thing that I think could have changed is this:
"image": "${{ INPUT_IMAGE }}",

originally, there were not quotes around "${{ INPUT IMAGE }}". However, looking quickly at the code for the plugin, I'm still not sure.

Once I got it working, I moved back to v1.1.3 and it still was functioning.

@brennh-animoca - thank you for the details.
Weird...
As far as I can see, all my task definitions are 99% similar, and I had an issue with one of them with v1.1.3.
It's more or less

"containerDefinitions": [
        {
            "name": "servicename",
            "image": "XXXXXXXX.dkr.ecr.us-east-1.amazonaws.com/server-name:hashhashhashhashhash",

I was able to render a task def with this action. In one project it works just fine, in the other it does not work, and it throws Invalid task definition: Could not find container definition with matching name

Both projects have the same task def. Structure. This is super confusing.

Any fix or workaround?

I rechecked this issue today and I'm going to close my issue.
According to my today's tests, all my task definitions are compatible with amazon-ecs-render-task-definition@v1, i.e. with 1.1.3.
(I have no idea what happened to me in February :-)

Strange...
Even with Run aws-actions/amazon-ecs-render-task-definition@v1 getting same: Error: Invalid task definition: Could not find container definition with matching name

Here my current action step:

      - name: Create new AWS ECS task definition on Stage (DEV)
        id: dev-task-def
        uses: aws-actions/amazon-ecs-render-task-definition@v1.1.3
        with:
          task-definition: task-definition.json
          container-name: ${{ inputs.ECS_CONTAINER_NAME }}
          image: ${{ steps.dev-image-build.outputs.image }}

I'm wondering if you really want to keep this issue closed.

@Abdullah-Shahen - does your workflow works with v1.1.2?
My workflow seems almost the same:

- 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: ${{ env.ECS_TASK_DEFINITION }}
        container-name: ${{ env.CONTAINER_NAME }}
        image: ${{ steps.build-image.outputs.image }}

and relevant of a task definition is

"containerDefinitions": [
        {
            "name": "core-p",
            "image": "xxxxxx.dkr.ecr.us-east-1.amazonaws.com/core-p:7da9b252999a69d0cc1ab1ed52f769f29f960e1d",

Again - I have no idea why I met this issue in Feb, but cannot reproduce now - neither action not my task definitions weren't modified as far as I see...

As for this issue - I prefer not to be an owner of it as far as I cannot reproduce it. Of course, you're welcome to reference or just copy-paste my issue in yours.

I'll copy the issue and reference to it as well. Thanks for the approval to do so.