# service unable to place tasks: reason: resource CPU was insufficient

- **ID:** `aws/ecs-task-stopped-resource-cpu`
- **Domain:** aws
- **Category:** resource_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

ECS cluster or capacity provider does not have enough available CPU units to run the task definition's CPU reservation.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| ECS 1.62.0 | active | — | — |
| AWS CLI 2.15.0 | active | — | — |

## Workarounds

1. **Scale out the ECS cluster by adding more EC2 instances or increasing Auto Scaling group size:
aws autoscaling update-auto-scaling-group --auto-scaling-group-name my-asg --desired-capacity 10 --min-size 5 --max-size 20** (75% success)
   ```
   Scale out the ECS cluster by adding more EC2 instances or increasing Auto Scaling group size:
aws autoscaling update-auto-scaling-group --auto-scaling-group-name my-asg --desired-capacity 10 --min-size 5 --max-size 20
   ```
2. **Use Fargate launch type or Fargate capacity provider with automatic scaling:
aws ecs create-service --cluster my-cluster --service-name my-service --task-definition my-task --launch-type FARGATE --network-configuration ...** (85% success)
   ```
   Use Fargate launch type or Fargate capacity provider with automatic scaling:
aws ecs create-service --cluster my-cluster --service-name my-service --task-definition my-task --launch-type FARGATE --network-configuration ...
   ```
3. **Reduce CPU reservation in the task definition to fit within available cluster resources:
{
  "family": "my-task",
  "containerDefinitions": [{
    "name": "my-container",
    "cpu": 256,
    "memory": 512
  }]
}** (70% success)
   ```
   Reduce CPU reservation in the task definition to fit within available cluster resources:
{
  "family": "my-task",
  "containerDefinitions": [{
    "name": "my-container",
    "cpu": 256,
    "memory": 512
  }]
}
   ```

## Dead Ends

- **Increase task CPU reservation in task definition** — Increasing CPU reservation makes the problem worse, as it requires even more CPU from the cluster. (95% fail)
- **Set service desired count to 0 and back to original** — Recycling the service does not create new capacity; the underlying resource shortage remains. (90% fail)
- **Add more memory without adding CPU capacity** — Memory is separate from CPU; the error is explicitly about CPU, so memory adjustments don't help. (85% fail)
