For AI agents: A markdown version of this page is available at https://docs.datadoghq.com/security/code_security/iac_security/iac_rules/cloudformation-aws-security-group-rule-without-description.md.
A documentation index is available at /llms.txt.
Security groups and their ingress/egress rules should include descriptive metadata to document their purpose and scope. Missing descriptions hinder audits and change reviews and make it easier for overly permissive or unintended rules to persist unnoticed.
In CloudFormation, the GroupDescription property on AWS::EC2::SecurityGroup must be defined. Every rule must also set a Description, either as entries in SecurityGroupIngress/SecurityGroupEgress on the security group resource or on standalone AWS::EC2::SecurityGroupIngress/AWS::EC2::SecurityGroupEgress resources. Resources or array entries missing these properties will be flagged. Use concise, intent-revealing descriptions that explain the allowed traffic and the rationale for the rule.
Secure configuration example:
MySecurityGroup:Type:AWS::EC2::SecurityGroupProperties:GroupDescription:Web server security group for production environmentVpcId:!Ref MyVPCSecurityGroupIngress:- IpProtocol:tcpFromPort:443ToPort:443CidrIp:0.0.0.0/0Description:Allow HTTPS traffic from internet- IpProtocol:tcpFromPort:22ToPort:22SourceSecurityGroupId:!Ref BastionSGDescription:Allow SSH from bastion host for admin access
{"Resources":{"InstanceSecurityGroup":{"Type":"AWS::EC2::SecurityGroup","Properties":{"GroupDescription":"Allow http to client host","VpcId":{"Ref":"myVPC"},"SecurityGroupIngress":[{"IpProtocol":"tcp","Description":"TCP","FromPort":80,"ToPort":80,"CidrIp":"0.0.0.0/0"}],"SecurityGroupEgress":[{"FromPort":80,"ToPort":80,"CidrIp":"0.0.0.0/0","IpProtocol":"tcp","Description":"TCP"}]}},"OutboundRule":{"Type":"AWS::EC2::SecurityGroupEgress","Properties":{"GroupId":{"Fn::GetAtt":["SourceSG","GroupId"]},"Description":"TCP","IpProtocol":"tcp","FromPort":0,"ToPort":65535,"DestinationSecurityGroupId":{"Fn::GetAtt":["TargetSG","GroupId"]}}},"InboundRule":{"Type":"AWS::EC2::SecurityGroupIngress","Properties":{"Description":"TCP","IpProtocol":"tcp","FromPort":0,"ToPort":65535,"SourceSecurityGroupId":{"Fn::GetAtt":["SourceSG","GroupId"]},"GroupId":{"Fn::GetAtt":["TargetSG","GroupId"]}}}}}