Listen for ECS failed to place task in Cloudwatch

Viewed 442

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 Answers

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.

Related