Certopolis

AWS Certified CloudOps Engineer – Associate

VPC Flow Logs: levels, aggregation interval and REJECT

The Amazon VPC User Guide says a flow log captures IP traffic data for a VPC, a subnet or a single network interface, and publishes it to CloudWatch Logs, Amazon S3 or Amazon Data Firehose. Records are aggregated over an interval of up to 10 minutes by default, or 1 minute if you choose. Each record shows ACCEPT or REJECT.

What can a flow log be attached to?

You create a flow log for a VPC, a subnet or a network interface. At the VPC or subnet level, every network interface in it is monitored. To limit records to one instance, create the flow log on its network interface.

For each flow log you choose the resource, the traffic to capture (accepted, rejected or all) and the destination. Network interfaces created by other services, such as Elastic Load Balancing, Amazon RDS and NAT gateways, can have flow logs too.

Flow log data is collected outside the path of the traffic, so creating or deleting a flow log does not affect throughput or latency. Deleting a flow log stops new records but does not delete data already published.

How fresh are the records?

A record covers one flow within an aggregation interval. The default maximum interval is 10 minutes. When you create the flow log you can set a maximum of 1 minute, which produces more records.

For a network interface attached to a Nitro-based instance, the interval is always 1 minute or less, whatever maximum was specified.

Flow logs are not a real-time stream. After capture, delivery typically takes about 5 minutes to CloudWatch Logs and about 10 minutes to Amazon S3, on a best-effort basis. A new flow log can take several minutes to start collecting.

How do you read ACCEPT and REJECT?

The default format contains the version 2 fields in a fixed order and cannot be changed. A custom format lets you pick the fields and their order. The action field is ACCEPT or REJECT.

Security groups are stateful and network ACLs are stateless, and the records show it. If a request appears as ACCEPT and its reply appears as REJECT, a network ACL denied the reply; a security group would have let the response through.

If a security group denies an inbound request, there is a single REJECT record, because the traffic never reached the instance. AWS lists diagnosing overly restrictive security group rules as one of the uses of flow logs.

Where the exam catches people

  • Expecting flow logs in real time: records are aggregated, then delivered in about 5 to 10 minutes.
  • Leaving the default interval when 1-minute records are required: the default maximum aggregation interval is 10 minutes.
  • Blaming a security group for an ACCEPT request with a REJECT reply: that pattern is a stateless network ACL.
  • Creating a second VPC-level flow log to watch one instance: scope the flow log to the network interface.
  • Believing a flow log slows the network: flow log data is collected outside the traffic path.

Written from these sources

Try 3 questions on this

Pick an answer to see why each option is right or wrong.

  1. A VPC flow log for a subnet publishes to Amazon S3 and was created with default settings. Records for most network interfaces in the subnet span 60 seconds or less, but records for two interfaces on an older instance type span up to 600 seconds. A SysOps administrator must make every record from the subnet's interfaces span no more than 1 minute. Which solution will meet this requirement?

    Right. In the game that’s Renown for your Networking and Content Delivery building.

    Not that one: B is right. In the game your Networking and Content Delivery building would lose a little Renown, and this question would come back later.

    Show the full explanation and doc quotes

    To bring the others down, the flow log needs a maximum aggregation interval of 1 minute, and because a flow log's configuration cannot be changed after creation, that means creating a replacement flow log with the setting and deleting the old one.

    Written from docs.aws.amazon.com/vpc/latest/userguide/flow-log-records.html

  2. A VPC already has a flow log that captures all traffic for the whole VPC and publishes to Amazon CloudWatch Logs. The security team now needs a separate set of flow records for one EC2 instance, delivered to an Amazon S3 bucket for Athena queries. Records from other instances in the same subnet must not appear in the new set. Which action should the SysOps administrator take to meet these requirements?

    Right. In the game that’s Renown for your Networking and Content Delivery building.

    Not that one: D is right. In the game your Networking and Content Delivery building would lose a little Renown, and this question would come back later.

    Show the full explanation and doc quotes

    Only the network interface level limits the records to a single instance, and each flow log has its own destination, so a new interface-level flow log can publish to S3 while the existing VPC flow log keeps feeding CloudWatch Logs.

    Written from docs.aws.amazon.com/vpc/latest/userguide/flow-logs-basics.html

  3. Application servers in subnet App-1 (10.0.1.0/24) connect to a PostgreSQL database on an EC2 instance in subnet DB-1. After a security change, the connections time out. A flow log on the database instance's network interface, with the fields srcaddr dstaddr srcport dstport action, shows: 10.0.1.25 10.0.2.40 51744 5432 ACCEPT 10.0.2.40 10.0.1.25 5432 51744 REJECT What is a reason for this issue?

    Right. In the game that’s Renown for your Networking and Content Delivery building.

    Not that one: C is right. In the game your Networking and Content Delivery building would lose a little Renown, and this question would come back later.

    Show the full explanation and doc quotes

    A security group cannot do that, because it remembers the allowed request and lets the reply out automatically. A network ACL keeps no such memory, so DB-1's network ACL needs an outbound rule for the clients' ephemeral ports.

    Written from docs.aws.amazon.com/vpc/latest/userguide/flow-logs-records-examples.html

Ask for something