Skip to main content

ECS Task Doctor

CI PyPI version Python 3.9+ License: MIT

Diagnose why your ECS tasks fail to start or keep crashing — in one command.

ECS Task Doctor aggregates information from ECS, CloudWatch, ECR, IAM, and EC2 into a single, human-readable diagnosis report. No more jumping between 7 AWS console tabs.

Installation

pip install ecs-task-doctor

Quick Start

# Diagnose a specific service
ecs-doctor diagnose --cluster my-cluster --service my-service

# Diagnose a specific task
ecs-doctor diagnose --cluster my-cluster --task arn:aws:ecs:us-east-1:123:task/my-cluster/abc123

# Scan all services in a cluster for issues
ecs-doctor scan --cluster my-cluster

# Quick health check
ecs-doctor health --cluster my-cluster

What It Checks

Check What it does
Task Status Parses stopped reasons and container exit codes (OOM, segfault, etc.)
Service Events Detects crash loops, placement failures, and capacity issues
CloudWatch Logs Scans recent logs for error patterns (OOM, connection refused, etc.)
Image Verifies ECR images exist and are pullable
IAM Validates task execution and task roles exist
Resources Checks CPU/memory constraints and cluster capacity
Networking Verifies subnets have IPs, security groups allow egress

Example Output

╭─────────────────────────────────────────────────╮
│  ECS Task Doctor — Diagnosis Report             │
│  Cluster: production  Service: api-server       │
╰─────────────────────────────────────────────────╯

🔴 CRITICAL: Container keeps crashing (3 restarts in 10 min)

📋 Checks:
  ✅ Image: 123456789.dkr.ecr.us-east-1.amazonaws.com/api:v2.1.0 — exists and pullable
  ✅ IAM: Task execution role has required permissions
  ✅ Network: Subnets have available IPs, security groups allow egress
  ❌ Task Status: Essential container exited with code 137 (OOM Kill)
  ⚠️  Resources: Container memory limit (512MB) is close to task memory (512MB)
  ❌ Logs: Last error — "JavaScript heap out of memory"

💡 Recommendation:
  1. Increase container memory limit from 512MB to 1024MB
  2. Update task definition memory from 512 to 1024
  3. Consider adding --max-old-space-size=768 to Node.js startup

📝 Full logs: aws logs tail /ecs/api-server --since 1h

Output Formats

# Rich terminal output (default)
ecs-doctor diagnose --cluster my-cluster --service my-service

# JSON (for scripting/automation)
ecs-doctor diagnose --cluster my-cluster --service my-service --format json

# Markdown (for reports/PRs)
ecs-doctor diagnose --cluster my-cluster --service my-service --format markdown

Commands

ecs-doctor diagnose

Run a full diagnosis on a service or task.

ecs-doctor diagnose --cluster CLUSTER --service SERVICE [--region REGION] [--format FORMAT]
ecs-doctor diagnose --cluster CLUSTER --task TASK_ARN [--region REGION] [--format FORMAT]

ecs-doctor scan

Scan all services in a cluster and diagnose any unhealthy ones.

ecs-doctor scan --cluster CLUSTER [--region REGION] [--format FORMAT]

ecs-doctor health

Quick health overview of all services in a cluster.

ecs-doctor health --cluster CLUSTER [--region REGION] [--format FORMAT]

Required AWS Permissions

ECS Task Doctor needs read-only access to several AWS services:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "ecs:DescribeClusters",
        "ecs:DescribeServices",
        "ecs:DescribeTasks",
        "ecs:DescribeTaskDefinition",
        "ecs:ListServices",
        "ecs:ListTasks",
        "ecs:ListContainerInstances",
        "ecs:DescribeContainerInstances",
        "logs:DescribeLogStreams",
        "logs:GetLogEvents",
        "ecr:DescribeRepositories",
        "ecr:DescribeImages",
        "iam:GetRole",
        "ec2:DescribeSubnets",
        "ec2:DescribeSecurityGroups"
      ],
      "Resource": "*"
    }
  ]
}

Development

# Install in dev mode
pip install -e '.[dev]'

# Run tests
pytest -v

# Lint
ruff check src/ tests/

See CONTRIBUTING.md for more details.

License

MIT — see LICENSE.

Metadata

Release files for ecs-task-doctor 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ecs-task-doctor 0.1.1
File Size Uploaded
ecs_task_doctor-0.1.1.tar.gz 27.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ecs-task-doctor 0.1.1
File Interpreter ABI Platform
ecs_task_doctor-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 54.1 kB

Release files / ecs_task_doctor-0.1.1.tar.gz

Download URL ecs_task_doctor-0.1.1.tar.gz
Size 27.7 kB
Tags Source
SHA-256 checksum
How to use checksums
6fc2e9d9f79a1a8b1cca948058f6241648bccb9b0ae65ae912955979f23ec8ca
BLAKE2b-256 checksum
How to use checksums
453a87691803e5523870d0e356a9da1964b6942f285cd9d5abde3567d3d1bfab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 23, 2026.

Transparency log

Release files / ecs_task_doctor-0.1.1-py3-none-any.whl

Download URL ecs_task_doctor-0.1.1-py3-none-any.whl
Size 26.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2bb4d0ac1323f9b5d1e97b9cd51fb5835ebbc19710ef74a39b7540a8ca9bab65
BLAKE2b-256 checksum
How to use checksums
e3ded6a80960f53f3a65548a86a5c7ed566b7f29619ce6589e867edf1d7131eb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 23, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page