Duplicate network ACL rule number

Use unique rule numbers within each ACL direction.

Description

Give each inbound rule a unique RuleNumber within its network ACL. Do the same for outbound rules. The two directions can reuse a number.

Potential impact

A duplicate in the same direction prevents creation of the new rule and can fail a stack update.

Remediation

List the ACL entries by direction and number. Choose an unused number and verify that the intended allow or deny rule matches first.

Examples

Despite its name, OutboundRule2 sets Egress: false, so both entries are inbound rule 112. The second template uses 100 once per direction. Keep existing logical IDs when correcting the same ACL, supply VpcId, and check whether outbound access to all IPv4 destinations is necessary.

Before

yaml
Resources:
  MyNACL2:
    Type: AWS::EC2::NetworkAcl
    Properties:
      VpcId: !Ref VpcId
  InboundRule2:
    Type: AWS::EC2::NetworkAclEntry
    Properties:
      NetworkAclId:
        Ref: MyNACL2
      RuleNumber: "112"
      Protocol: 6
      PortRange:
        From: 22
        To: 22
      Egress: false
      RuleAction: allow
      CidrBlock: 172.16.0.0/24
  OutboundRule2:
    Type: AWS::EC2::NetworkAclEntry
    Properties:
      NetworkAclId:
        Ref: MyNACL2
      RuleNumber: "112"
      Protocol: -1
      Egress: false
      RuleAction: allow
      CidrBlock: 0.0.0.0/0

After

yaml
Resources:
  MyNACL:
    Type: AWS::EC2::NetworkAcl
    Properties:
      VpcId: !Ref VpcId
  InboundRule:
    Type: AWS::EC2::NetworkAclEntry
    Properties:
      NetworkAclId:
        Ref: MyNACL
      RuleNumber: 100
      Protocol: 6
      RuleAction: allow
      CidrBlock: 172.16.0.0/24
      PortRange:
        From: 22
        To: 22
  OutboundRule:
    Type: AWS::EC2::NetworkAclEntry
    Properties:
      NetworkAclId:
        Ref: MyNACL
      RuleNumber: 100
      Protocol: -1
      Egress: true
      RuleAction: allow
      CidrBlock: 0.0.0.0/0

References