3
votes

I want to create a rule in Cloudwatch that listens for the events when ECS fails to place a task.

I see examples in the AWS documentation about when a task fails, or when the state of a container instance changes. But this is not what I want. I want specifically to listen for when ECS emits the event "failed to place task". I know it will have to be some sort of event pattern that matches it, but I am not sure about the specifics of the event pattern.

This example matches a task state change, but is not what I want. But I think it is similar:

{
  "source": [
    "aws.ecs"
  ],
  "detail-type": [
    "ECS Task State Change"
  ],
  "detail": {
    "lastStatus": [
      "STOPPED"
    ],
    "stoppedReason": [
      "Essential container in task exited"
    ],
    "containers": {
      "exitCode": ["1", "2", "3", and so on...]
    }
  }
}

I would like to be able to match the event "failed to place task".

1
Would this workaround suit your needs?Tiago Martins Peres
I think that will work. So, the answer to my question is: you currently cannot do this in Cloudwatch, but there is a workaround using Lambda, and this feature has been requested from AWS and they are working on implementing it. Yeah? If you type that up I'll mark the question as answered with your response! Thanks!adamkgray

1 Answers

4
votes

You currently cannot do this in Cloudwatch, but there is a workaround using Lambda. This feature has been requested from AWS and they are working on implementing it.