ECS task is not configured with a health check Affecting ECS service in AWS


Severity

0.0
medium
0
10
    Severity Framework
    Snyk CCSS
    Rule category
    Containers / Health

Is your enviroment affected by this misconfiguration?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications
    Frameworks
    ISO-27001
  • Snyk ID SNYK-CC-00199
  • credit Snyk Research Team

Description

Adding health checks to your ECS tasks gives you more visibility in monitoring the health of your tasks and improves your ability to know that your ECS tasks are healthy.

How to fix?

Set the container_definitions json document healthcheck key to an appropriate value.

Example Configuration

resource "aws_ecs_task_definition" "valid_container_healthcheck" {
  family = "valid_container_healthcheck"

  container_definitions = <<EOF
[
  {
    "name": "valid_container_healthcheck",
    "image": "hello-world",
    "memory": 128,
    "healthcheck": {
      "command": ["CMD-SHELL", "echo 'healthy' || exit 1"]
    }
  }
]
EOF

  requires_compatibilities = ["EC2"]
}