hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.85k stars 9.19k forks source link

Add support for custom Flow Logs format #10081

Closed sshvetsov closed 5 years ago

sshvetsov commented 5 years ago

Community Note

Description

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.

New or Affected Resource(s)

Potential Terraform Configuration

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.

References

bflad commented 5 years ago

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. 👍

bflad commented 5 years ago

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.

jgard commented 5 years ago

Could you also update the doc with an example of the format required here?

ghost commented 4 years ago

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!