AWS has announced support for custom VPC Flow Logs format, which now allows to inclusion of additional metadata fields like vpc-id
, subnet-id
, instance-id
, tcp-flags
, type
, pkt-srcaddr
, pkt-dstaddr
in Amazon Virtual Private Cloud (Amazon VPC) flow logs to better understand network flows.
Usage of additional metadata fields like vpc-id
, subnet-id
, Transmission Control Protocol (TCP) bitmask reduce the number of computations and look-ups required to extract meaningful information from the log data. For example, you can use TCP bitmask to identify the resource initiating at TCP connection. Similarly, you can use the packet source and destination IP fields to identify the source resource and the intended target of a connection passing through a network interface attached to NAT Gateway or an AWS Transit Gateway.
resource "aws_flow_log" "example" {
log_destination = "${aws_s3_bucket.example.arn}"
log_destination_type = "s3"
traffic_type = "ALL"
vpc_id = "${aws_vpc.example.id}"
log_format = "$${version} $${vpc-id} $${subnet-id} $${instance-id} $${interface-id} $${account-id} $${type} $${srcaddr} $${dstaddr} $${srcport} $${dstport} $${pkt-srcaddr} $${pkt-dstaddr} $${protocol} $${bytes} $${packets} $${start} $${end} $${action} $${tcp-flags} $${log-status}"
}
Note: the use of ${}
in flow log configuration format conflicts with Terraform variable interpolation syntax, so there may be a need to use different symbols to denote log metadata attributes and escape them like I did in the above example.
Support for the new log_format
argument in the aws_flow_log
resource has been merged and will release with version 2.34.0 of the Terraform AWS Provider, tomorrow. Thanks to @nebi-frame for the implementation. 👍
This has been released in version 2.34.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.
Could you also update the doc with an example of the format required here?
I'm going to lock this issue because it has been closed for _30 days_ ⏳. This helps our maintainers find and focus on the active issues.
If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!
Most helpful comment
Could you also update the doc with an example of the format required here?