Auto Scaling groups must be associated with a load balancer to distribute traffic and maintain availability during scaling and instance replacement. Without a load balancer, instances can become single points of failure and traffic may be routed unevenly.
In CloudFormation, the AWS::AutoScaling::AutoScalingGroup resource must define the LoadBalancerNames property, and it must be a non-empty list of Classic ELB names. Resources missing LoadBalancerNames or where LoadBalancerNames is an empty array will be flagged.
If your environment uses Application Load Balancers (ALBs) or Network Load Balancers (NLBs), attach the Auto Scaling group to target groups via the TargetGroupARNs property instead, since this rule only checks LoadBalancerNames.
#this code is a correct code for which the query should not find any resultAWSTemplateFormatVersion:'2010-09-09'Resources:myLaunchTemplate:Type:AWS::EC2::LaunchTemplateProperties:LaunchTemplateName:!Sub ${AWS::StackName}-launch-templateLaunchTemplateData:BlockDeviceMappings:- Ebs:VolumeSize:22VolumeType:gp2DeleteOnTermination:trueEncrypted:trueDeviceName:/dev/xvdczCreditSpecification:CpuCredits:UnlimitedImageId:ami-02354e95b39ca8decInstanceType:t2.microKeyName:my-key-pair-useast1Monitoring:Enabled:trueSecurityGroupIds:- sg-7c227019- sg-903004f8myASG:Type:AWS::AutoScaling::AutoScalingGroupProperties:AutoScalingGroupName:myASGMinSize:"1"MaxSize:"6"DesiredCapacity:"2"HealthCheckGracePeriod:300LoadBalancerNames:- elb_1- elb_2LaunchTemplate:LaunchTemplateId:!Ref myLaunchTemplateVersion:!GetAtt myLaunchTemplate.LatestVersionNumberVPCZoneIdentifier:- !Ref myPublicSubnet1- !Ref myPublicSubnet2MetricsCollection:- Granularity:"1Minute"Metrics:- "GroupMinSize"- "GroupMaxSize"Tags:- Key:EnvironmentValue:ProductionPropagateAtLaunch:"true"- Key:PurposeValue:WebServerGroupPropagateAtLaunch:"false"
Non-Compliant Code Examples
#this is a problematic code where the query should report a result(s)AWSTemplateFormatVersion:'2010-09-09'Resources:myLaunchTemplate:Type:AWS::EC2::LaunchTemplateProperties:LaunchTemplateName:!Sub ${AWS::StackName}-launch-templateLaunchTemplateData:BlockDeviceMappings:- Ebs:VolumeSize:22VolumeType:gp2DeleteOnTermination:trueEncrypted:trueDeviceName:/dev/xvdczCreditSpecification:CpuCredits:UnlimitedImageId:ami-02354e95b39ca8decInstanceType:t2.microKeyName:my-key-pair-useast1Monitoring:Enabled:trueSecurityGroupIds:- sg-7c227019- sg-903004f8myASG:Type:AWS::AutoScaling::AutoScalingGroupProperties:AutoScalingGroupName:myASGMinSize:"1"MaxSize:"6"DesiredCapacity:"2"HealthCheckGracePeriod:300LaunchTemplate:LaunchTemplateId:!Ref myLaunchTemplateVersion:!GetAtt myLaunchTemplate.LatestVersionNumberVPCZoneIdentifier:- !Ref myPublicSubnet1- !Ref myPublicSubnet2MetricsCollection:- Granularity:"1Minute"Metrics:- "GroupMinSize"- "GroupMaxSize"Tags:- Key:EnvironmentValue:ProductionPropagateAtLaunch:"true"- Key:PurposeValue:WebServerGroupPropagateAtLaunch:"false"myASG2:Type:AWS::AutoScaling::AutoScalingGroupProperties:AutoScalingGroupName:myASG2MinSize:"1"MaxSize:"6"DesiredCapacity:"2"HealthCheckGracePeriod:300LoadBalancerNames:[]LaunchTemplate:LaunchTemplateId:!Ref myLaunchTemplateVersion:!GetAtt myLaunchTemplate.LatestVersionNumberVPCZoneIdentifier:- !Ref myPublicSubnet1- !Ref myPublicSubnet2MetricsCollection:- Granularity:"1Minute"Metrics:- "GroupMinSize"- "GroupMaxSize"Tags:- Key:EnvironmentValue:ProductionPropagateAtLaunch:"true"- Key:PurposeValue:WebServerGroupPropagateAtLaunch:"false"myASG3:Type:AWS::AutoScaling::AutoScalingGroupProperties:AutoScalingGroupName:myASGMinSize:"1"MaxSize:"6"DesiredCapacity:"2"HealthCheckGracePeriod:300LoadBalancerNames:[]LaunchTemplate:LaunchTemplateId:!Ref myLaunchTemplateVersion:!GetAtt myLaunchTemplate.LatestVersionNumberVPCZoneIdentifier:- !Ref myPublicSubnet1- !Ref myPublicSubnet2MetricsCollection:- Granularity:"1Minute"Metrics:- "GroupMinSize"- "GroupMaxSize"Tags:- Key:EnvironmentValue:ProductionPropagateAtLaunch:"true"- Key:PurposeValue:WebServerGroupPropagateAtLaunch:"false"
1
2
rulesets:- CloudFormation / AWS # Rules to enforce / AWS.
맞춤형 데모 요청
Datadog 시작하기
Ask AI
AI-generated responses may be inaccurate. Verify important info.