Load balancers that are attached to security groups with no outbound rules, or without explicitly defined egress, may be unable to reach backend targets, perform health checks, or connect to logging and monitoring services. This can cause availability and operational failures.
For load balancer resources (AWS::ElasticLoadBalancing::LoadBalancer and AWS::ElasticLoadBalancingV2::LoadBalancer), examine each security group referenced in the resource’s SecurityGroups list and validate the corresponding AWS::EC2::SecurityGroup defines the SecurityGroupEgress property. Resources missing SecurityGroupEgress or with SecurityGroupEgress set to an empty list will be flagged. The SecurityGroupEgress list must contain at least one egress rule that permits the required outbound traffic and should use narrow CIDRs, ports, or security-group destinations rather than broad 0.0.0.0/0 when possible.
Secure example with an explicit outbound rule allowing HTTPS egress:
MySecurityGroup:Type:AWS::EC2::SecurityGroupProperties:GroupDescription:Allow load balancer outbound HTTPS to targetsVpcId:vpc-01234567SecurityGroupEgress:- IpProtocol:tcpFromPort:443ToPort:443CidrIp:10.0.0.0/16
Compliant Code Examples
AWSTemplateFormatVersion:2010-09-09Resources:sgwithegress:Type:AWS::EC2::SecurityGroupProperties:GroupDescription:Limits security group egress trafficSecurityGroupEgress:- IpProtocol:tcpFromPort:80ToPort:80CidrIp:0.0.0.0/0MyLoadBalancer:Type:AWS::ElasticLoadBalancing::LoadBalancerProperties:SecurityGroups:- sgwithegress
Non-Compliant Code Examples
AWSTemplateFormatVersion:2010-09-09Resources:sgwithoutegress:Type:AWS::EC2::SecurityGroupProperties:GroupDescription:Limits security group egress trafficMyLoadBalancer:Type:AWS::ElasticLoadBalancing::LoadBalancerProperties:SecurityGroups:- sgwithoutegress
1
2
rulesets:- CloudFormation / AWS # Rules to enforce / AWS.
パーソナライズされたデモをリクエスト
Datadog を始める
Ask AI
AI-generated responses may be inaccurate. Verify important info.