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

Registers an Amazon ECS task definition and deploys it to an ECS service.
MIT License
651 stars 239 forks source link

Unable to deploy via Actions: Cannot read property 'name' of null #53

Closed pvasilyev closed 4 years ago

pvasilyev commented 4 years ago

Trying to use this action in my personal project (private repo so far). YML file is as follows: https://gist.github.com/pvasilyev/ceaf81d6943464bf77ac2a6a0b7602ad

I've verified that my aws user has all permissions listed in the https://github.com/aws-actions/amazon-ecs-deploy-task-definition#permissions but still w/o luck.

Logs excerpt:

Run aws-actions/amazon-ecs-deploy-task-definition@v1
  with:
    task-definition: /home/runner/work/_temp/task-definition-3216nPr47VbD5lae.json
    service: tgbot-webhook-service
    cluster: tgbot-springboot-cluster
    wait-for-service-stability: true
  env:
    AWS_DEFAULT_REGION: us-east-1
    AWS_REGION: us-east-1
    AWS_ACCESS_KEY_ID: ***
    AWS_SECRET_ACCESS_KEY: ***
##[error]Cannot read property 'name' of null
clareliguori commented 4 years ago

This is likely a failure to parse your task definition file, for example a missing required field. To confirm, you can turn on debug logs by setting the secret ACTIONS_STEP_DEBUG to true in your repo.

clareliguori commented 4 years ago

Added troubleshooting directions in 7dc1449a482e7ab2af6512344efcdfd4fc64ddb6

kaischwanke commented 4 years ago

I have the same issue. Thanks for putting in the debug option @clareliguori ! But even though I can now see the task definition file being used, I still don't know what's wrong with it. I'm aware the error is being thrown in the aws sdk, but can someone give any more clues on how analyse/validate what could be wrong with the file?

clareliguori commented 4 years ago

This will give you the format: aws ecs register-task-definition --generate-cli-skeleton

If you'd like to paste your generated task def here from the debug log (removing any sensitive info), I can take a look

kaischwanke commented 4 years ago

Hi @clareliguori , thanks so much for getting back to me. I was already using a file generate using the command you have suggested. I have uploaded it here: https://gist.github.com/kaischwanke/aef290d2e90c0ff071803e6631da40cd Also, with ACTIONS_STEP_DEBUG=true I can see that the modified file in failing step (Deploy Amazon ECS task definition) looks a little different: https://gist.github.com/kaischwanke/a59a3e35cdce46c96a8d6080a1e08091

clareliguori commented 4 years ago

@kaischwanke I don't see where the two task defs you pasted are different, is the second one actually the same as the first?

Anyway, the generate command adds all the possible options and expects them all to be filled in or removed if you are not using them. For example, cpu and memory should be removed or set to non-zero values.

      "cpu": 0,
      "memory": 0,

It is easier to start from a task definition that is already registered, and store that in your repo: aws ecs describe-task-definition --task-definition first-run-task-definition > ecs-task-definition.json

kaischwanke commented 4 years ago

Sorry @clareliguori , seems I did upload the same file twice. I have updated the second one now. That's the output I see in the GitHub action. The first one is the one I have in my repository.

clareliguori commented 4 years ago

@kaischwanke I put up a fix for the 'null' error, but even when that is released, this is still not a valid task definition since it's expecting you to fill in more information or remove attributes you don't need. But, at least you'll get some better validation messages once the fix is released.

kaischwanke commented 4 years ago

You're amazing, thanks @clareliguori ! I did get my service to work by using the existing task definition as you suggested: aws ecs describe-task-definition --task-definition first-run-task-definition > ecs-task-definition.json (I just had to unwrap the contents of the root key 'taskDefinition' from that JSON) Thanks again!