VPC Flow Logs coverage needs review

Check that VPC Flow Logs cover the intended network and traffic.

Description

Check whether existing flow logs cover the VPC, subnet or network interface you need to investigate. The records identify IP addresses, ports and whether traffic was accepted or rejected.

Potential impact

Missing records can slow connection troubleshooting. Flow logs omit packet contents and some traffic types, and an IP address alone cannot identify a user.

Remediation

Match ResourceType and ResourceId on AWS::EC2::FlowLog to the actual target and select TrafficType. Configure the destination and delivery permissions, then verify incoming records, who can read them and how long they are kept.

Examples

These excerpts deliver to CloudWatch Logs. Define the referenced Role and LogGroup separately.

Before

yaml
Resources:
  MyVPC:
    Type: AWS::EC2::VPC
    Properties:
      CidrBlock: 10.0.0.0/16

  FlowLog:
    Type: AWS::EC2::FlowLog
    Properties:
      DeliverLogsPermissionArn: !GetAtt Role.Arn
      LogGroupName: !Ref LogGroup
      ResourceId: !Ref MyVPC1
      ResourceType: VPC
      TrafficType: ACCEPT

MyVPC1 is undefined in the excerpt. Even if it refers to another VPC, this flow log does not cover MyVPC.

After

yaml
Resources:
  MyVPC:
    Type: AWS::EC2::VPC
    Properties:
      CidrBlock: 10.0.0.0/16

  FlowLog:
    Type: AWS::EC2::FlowLog
    Properties:
      DeliverLogsPermissionArn: !GetAtt Role.Arn
      LogGroupName: !Ref LogGroup
      ResourceId: !Ref MyVPC
      ResourceType: VPC
      TrafficType: ACCEPT

ResourceId now points to MyVPC. ACCEPT captures accepted traffic only. Choose ALL if you also need rejected traffic.

References