Back to Checks
Amazon EC2 Auto Scaling group has Capacity Rebalancing enabled
autoscaling_group_capacity_rebalance_enabled
Service: autoscalingSeverity: medium
OfficialBuilt-inVerified
Categories:resilience
Resource Type:AwsAutoScalingAutoScalingGroup
EC2 Auto Scaling groups use Capacity Rebalancing to act on EC2 rebalance recommendations by launching replacement Spot instances and terminating at-risk ones after they are healthy.
Assesses whether this proactive replacement behavior is enabled.
Risk
Without Capacity Rebalancing, Spot interruptions can drop targets and reduce capacity, causing timeouts, 5xx spikes, and backlog growth. The two-minute notice is often insufficient, reducing service availability and increasing the chance of cascading failures and slow recovery.
Run this check with Prowler
Run in Prowler CloudRun
prowler aws --checks autoscaling_group_capacity_rebalance_enabledRecommendation
Enable Capacity Rebalancing for ASGs that use Spot.
Apply resilience practices:
- Prefer
price-capacity-optimizedallocation - Keep headroom below
MaxSize - Use lifecycle hooks to drain/deregister
- Design stateless, interruption-tolerant workloads (least privilege and defense-in-depth for dependencies)
Remediation
CLI
aws autoscaling update-auto-scaling-group --auto-scaling-group-name <example_resource_name> --capacity-rebalanceTerraform
# Terraform: Enable Capacity Rebalancing on an Auto Scaling group
resource "aws_autoscaling_group" "<example_resource_name>" {
name = "<example_resource_name>"
min_size = 1
max_size = 1
desired_capacity = 1
availability_zones = ["<example_az>"]
launch_template {
id = "<example_resource_id>"
version = "$Latest"
}
capacity_rebalance = true # CRITICAL: Turns on Capacity Rebalancing
}NativeIaC
# CloudFormation: Enable Capacity Rebalancing on an Auto Scaling group
Resources:
<example_resource_name>:
Type: AWS::AutoScaling::AutoScalingGroup
Properties:
MinSize: "1"
MaxSize: "1"
AvailabilityZones: ["<example_az>"]
LaunchTemplate:
LaunchTemplateName: <example_resource_name>
Version: "$Default"
CapacityRebalance: true # CRITICAL: Enables proactive replacement of at-risk Spot instancesOther
1In the AWS Console, go to EC2 > Auto Scaling Groups
2Select <example_resource_name> and open the Details tab
3Click Allocation strategies > Edit, check Capacity rebalancing
4Click Update/Save
Check Code
from prowler.lib.check.models import Check, Check_Report_AWS
from prowler.providers.aws.services.autoscaling.autoscaling_client import (
autoscaling_client,
)
class autoscaling_group_capacity_rebalance_enabled(Check):
def execute(self):
findings = []
for group in autoscaling_client.groups:
if group.load_balancers and group.target_groups:
report = Check_Report_AWS(metadata=self.metadata(), resource=group)
report.status = "FAIL"
report.status_extended = f"Autoscaling group {group.name} does not have capacity rebalance enabled."
if group.capacity_rebalance:
report.status = "PASS"
report.status_extended = f"Autoscaling group {group.name} has capacity rebalance enabled."
findings.append(report)
return findingsReferences
- https://docs.aws.amazon.com/awssupport/latest/user/fault-tolerance-checks.html#amazon-ec2-auto-scaling-group-capacity-rebalance-enabled
- https://docs.aws.amazon.com/autoscaling/ec2/userguide/ec2-auto-scaling-capacity-rebalancing.html
- https://trendmicro.com/trendaivisiononecloudriskmanagement/knowledge-base/aws/EC2/enable-capacity-rebalancing.html
- https://docs.aws.amazon.com/autoscaling/ec2/userguide/enable-capacity-rebalancing-console-cli.html