For AI agents: A markdown version of this page is available at https://docs.datadoghq.com/security/code_security/iac_security/iac_rules/ansible/aws/auto_scaling_group_with_no_associated_elb.md.
A documentation index is available at /llms.txt.
Auto Scaling Groups must be associated with a load balancer so new instances receive traffic and health checks can detect and replace unhealthy instances. Without a load balancer, instances may not serve requests, and application availability and scaling behavior can be impacted.
For Ansible autoscaling_group tasks (modules amazon.aws.autoscaling_group and autoscaling_group), the load_balancers property must be defined and set to a non-empty list of Classic ELB names. Tasks missing the load_balancers property or with load_balancers: [] are flagged. If you use Application Load Balancers with target groups instead of Classic ELBs, configure target_group_arns accordingly—this rule only validates the load_balancers attribute.
Secure example:
- name:Create Auto Scaling Group with ELBamazon.aws.autoscaling_group:name:my-asglaunch_template:my-launch-templatemin_size:2max_size:5load_balancers:- my-classic-elb