Review ECS service deployment availability

Check the required task count and capacity to retain during rolling deployments.

Description

For an ECS REPLICA service, DesiredCount is the task count to maintain. Zero is appropriate for an intentional stop. Omitting DeploymentConfiguration uses the deployment defaults.

Potential impact

Requests can fail if no healthy tasks remain during a rolling replacement.

Remediation

Set DesiredCount for the workload. Choose MinimumHealthyPercent and MaximumPercent to fit the capacity available for replacement, then check the actual healthy task count during rollout.

Examples

Define Cluster and TaskDefinition separately. The second excerpt requires one healthy task during rollout and allows up to two tasks if capacity is available.

Before

yaml
Resources:
  Service:
    Type: AWS::ECS::Service
    Properties:
      Cluster: !Ref Cluster
      TaskDefinition: !Ref TaskDefinition
      DesiredCount: 0

After

yaml
Resources:
  Service:
    Type: AWS::ECS::Service
    Properties:
      Cluster: !Ref Cluster
      TaskDefinition: !Ref TaskDefinition
      DesiredCount: 1
      DeploymentConfiguration:
        MinimumHealthyPercent: 100
        MaximumPercent: 200

References