Project: KICS (Provisioning / Security & Compliance)
File: ad21e616-5026-4b9d-990d-5b007bfe679c.md

title: Auto Scaling Group With No Associated ELB hide: toc: true navigation: true <style> .highlight .hll { background-color: #ff171742; } .md-content { max-width: 1100px; margin: 0 auto; } </style> Query id: ad21e616-5026-4b9d-990d-5b007bfe679c Query name: Auto Scaling Group With No Associated ELB Platform: CloudFormation Severity: <span style="color:#ff7213">Medium</span> Category: Availability URL: AWS Auto Scaling Groups must have associated ELBs to ensure high availability and improve application performance. This means the attribute 'LoadBalancerNames' must be defined and not empty.<br> ```yaml title="Positive test num. 1 - yaml file" hl_lines="28 60 87" AWSTemplateFormatVersion: '2010-09-09' Resources: myLaunchTemplate: Type: AWS::EC2::LaunchTemplate Properties: LaunchTemplateName: !Sub ${AWS::StackName}-launch-template LaunchTemplateData: BlockDeviceMappings: Ebs: VolumeSize: 22 VolumeType: gp2 DeleteOnTermination: true Encrypted: true DeviceName: /dev/xvdcz CreditSpecification: CpuCredits: Unlimited ImageId: ami-02354e95b39ca8dec InstanceType: t2.micro KeyName: my-key-pair-useast1 Monitoring: Enabled: true SecurityGroupIds: sg-7c227019 sg-903004f8 myASG: Type: AWS::AutoScaling::AutoScalingGroup Properties: AutoScalingGroupName: myASG MinSize: "1" MaxSize: "6" DesiredCapacity: "2" HealthCheckGracePeriod: 300 LaunchTemplate: LaunchTemplateId: !Ref myLaunchTemplate Version: !GetAtt myLaunchTemplate.LatestVersionNumber VPCZoneIdentifier: !Ref myPublicSubnet1 !Ref myPublicSubnet2 MetricsCollection: Granularity: "1Minute" Metrics: "GroupMinSize" "GroupMaxSize" Tags: Key: Environment Value: Production PropagateAtLaunch: "true" Key: Purpose Value: WebServerGroup PropagateAtLaunch: "false" myASG2: Type: AWS::AutoScaling::AutoScalingGroup Properties: AutoScalingGroupName: myASG2 MinSize: "1" MaxSize: "6" DesiredCapacity: "2" HealthCheckGracePeriod: 300 LoadBalancerNames: [] LaunchTemplate: LaunchTemplateId: !Ref myLaunchTemplate Version: !GetAtt myLaunchTemplate.LatestVersionNumber VPCZoneIdentifier: !Ref myPublicSubnet1 !Ref myPublicSubnet2 MetricsCollection: Granularity: "1Minute" Metrics: "GroupMinSize" "GroupMaxSize" Tags: Key: Environment Value: Production PropagateAtLaunch: "true" Key: Purpose Value: WebServerGroup PropagateAtLaunch: "false" myASG3: Type: AWS::AutoScaling::AutoScalingGroup Properties: AutoScalingGroupName: myASG MinSize: "1" MaxSize: "6" DesiredCapacity: "2" HealthCheckGracePeriod: 300 LoadBalancerNames: [] LaunchTemplate: LaunchTemplateId: !Ref myLaunchTemplate Version: !GetAtt myLaunchTemplate.LatestVersionNumber VPCZoneIdentifier: !Ref myPublicSubnet1 !Ref myPublicSubnet2 MetricsCollection: Granularity: "1Minute" Metrics: "GroupMinSize" "GroupMaxSize" Tags: Key: Environment Value: Production PropagateAtLaunch: "true" Key: Purpose Value: WebServerGroup PropagateAtLaunch: "false" ``` ```json title="Positive test num. 2 - json file" hl_lines="78 126 38" { "AWSTemplateFormatVersion": "2010-09-09", "Resources": { "myLaunchTemplate": { "Type": "AWS::EC2::LaunchTemplate", "Properties": { "LaunchTemplateName": "${AWS::StackName}-launch-template", "LaunchTemplateData": { "InstanceType": "t2.micro", "KeyName": "my-key-pair-useast1", "Monitoring": { "Enabled": true }, "SecurityGroupIds": [ "sg-7c227019", "sg-903004f8" ], "BlockDeviceMappings": [ { "Ebs": { "VolumeSize": 22, "VolumeType": "gp2", "DeleteOnTermination": true, "Encrypted": true }, "DeviceName": "/dev/xvdcz" } ], "CreditSpecification": { "CpuCredits": "Unlimited" }, "ImageId": "ami-02354e95b39ca8dec" } } }, "myASG": { "Type": "AWS::AutoScaling::AutoScalingGroup", "Properties": { "HealthCheckGracePeriod": 300, "LaunchTemplate": { "LaunchTemplateId": "myLaunchTemplate", "Version":

}, "VPCZoneIdentifier": [ "myPublicSubnet1", "myPublicSubnet2" ], "MetricsCollection": [ { "Granularity": "1Minute", "Metrics": [ "GroupMinSize", "GroupMaxSize" ] } ], "AutoScalingGroupName": "myASG", "MaxSize": "6", "DesiredCapacity": "2", "MinSize": "1", "Tags": [ { "Key": "Environment", "Value": "Production", "PropagateAtLaunch": "true" }, { "Key": "Purpose", "Value": "WebServerGroup", "PropagateAtLaunch": "false" } ] } }, "myASG2": { "Type": "AWS::AutoScaling::AutoScalingGroup", "Properties": { "LoadBalancerNames": [], "LaunchTemplate": { "Version": "myLaunchTemplate.LatestVersionNumber", "LaunchTemplateId": "myLaunchTemplate" }, "VPCZoneIdentifier": [ "myPublicSubnet1", "myPublicSubnet2" ], "MinSize": "1", "MaxSize": "6", "HealthCheckGracePeriod": 300, "Tags": [ { "Value": "Production", "PropagateAtLaunch": "true", "Key": "Environment" }, { "Key": "Purpose", "Value": "WebServerGroup", "PropagateAtLaunch": "false" } ], "AutoScalingGroupName": "myASG2", "DesiredCapacity": "2", "MetricsCollection": [ { "Granularity": "1Minute", "Metrics": [ "GroupMinSize", "GroupMaxSize" ] } ] } }, "myASG3": { "Type": "AWS::AutoScaling::AutoScalingGroup", "Properties": { "VPCZoneIdentifier": [ "myPublicSubnet1", "myPublicSubnet2" ], "MaxSize": "6", "MinSize": "1", "DesiredCapacity": "2", "HealthCheckGracePeriod": 300, "LoadBalancerNames": [], "LaunchTemplate": { "LaunchTemplateId": "myLaunchTemplate", "Version": "myLaunchTemplate.LatestVersionNumber" }, "MetricsCollection": [ { "Granularity": "1Minute", "Metrics": [ "GroupMinSize", "GroupMaxSize" ] } ], "Tags": [ { "Key": "Environment", "Value": "Production", "PropagateAtLaunch": "true" }, { "Key": "Purpose", "Value": "WebServerGroup", "PropagateAtLaunch": "false" } ], "AutoScalingGroupName": "myASG" } } } } ``` ```yaml title="Negative test num. 1 - yaml file" AWSTemplateFormatVersion: '2010-09-09' Resources: myLaunchTemplate: Type: AWS::EC2::LaunchTemplate Properties: LaunchTemplateName: !Sub ${AWS::StackName}-launch-template LaunchTemplateData: BlockDeviceMappings: Ebs: VolumeSize: 22 VolumeType: gp2 DeleteOnTermination: true Encrypted: true DeviceName: /dev/xvdcz CreditSpecification: CpuCredits: Unlimited ImageId: ami-02354e95b39ca8dec InstanceType: t2.micro KeyName: my-key-pair-useast1 Monitoring: Enabled: true SecurityGroupIds: sg-7c227019 sg-903004f8 myASG: Type: AWS::AutoScaling::AutoScalingGroup Properties: AutoScalingGroupName: myASG MinSize: "1" MaxSize: "6" DesiredCapacity: "2" HealthCheckGracePeriod: 300 LoadBalancerNames: elb_1 elb_2 LaunchTemplate: LaunchTemplateId: !Ref myLaunchTemplate Version: !GetAtt myLaunchTemplate.LatestVersionNumber VPCZoneIdentifier: !Ref myPublicSubnet1 !Ref myPublicSubnet2 MetricsCollection: Granularity: "1Minute" Metrics: "GroupMinSize" "GroupMaxSize" Tags: Key: Environment Value: Production PropagateAtLaunch: "true" Key: Purpose Value: WebServerGroup PropagateAtLaunch: "false" ``` ```json title="Negative test num. 2 - json file" { "Resources": { "myLaunchTemplate": { "Type": "AWS::EC2::LaunchTemplate", "Properties": { "LaunchTemplateName": "${AWS::StackName}-launch-template", "LaunchTemplateData": { "ImageId": "ami-02354e95b39ca8dec", "InstanceType": "t2.micro", "KeyName": "my-key-pair-useast1", "Monitoring": { "Enabled": true }, "SecurityGroupIds": [ "sg-7c227019", "sg-903004f8" ], "BlockDeviceMappings": [ { "Ebs": { "Encrypted": true, "VolumeSize": 22, "VolumeType": "gp2", "DeleteOnTermination": true }, "DeviceName": "/dev/xvdcz" } ], "CreditSpecification": { "CpuCredits": "Unlimited" } } } }, "myASG": { "Type": "AWS::AutoScaling::AutoScalingGroup", "Properties": { "Tags": [ { "Key": "Environment", "Value": "Production", "PropagateAtLaunch": "true" }, { "Key": "Purpose", "Value": "WebServerGroup", "PropagateAtLaunch": "false" } ], "AutoScalingGroupName": "myASG", "MaxSize": "6", "HealthCheckGracePeriod": 300, "LoadBalancerNames": [ "elb_1", "elb_2" ], "LaunchTemplate": { "LaunchTemplateId": "myLaunchTemplate", "Version": "myLaunchTemplate.LatestVersionNumber" }, "VPCZoneIdentifier": [ "myPublicSubnet1", "myPublicSubnet2" ], "MetricsCollection": [ { "Granularity": "1Minute", "Metrics": [ "GroupMinSize", "GroupMaxSize" ] } ], "MinSize": "1", "DesiredCapacity": "2" } } }, "AWSTemplateFormatVersion": "2010-09-09" } ```