FEATURES OPEN SOURCE ABOUT DOCS LOGIN REGISTER

aws_flow_log

Provides a VPC/Subnet/ENI Flow Log to capture IP traffic for a specific network interface, subnet, or VPC. Logs are sent to a CloudWatch Log Group.

resource "aws_flow_log" "test_flow_log" {
  log_group_name = "${aws_cloudwatch_log_group.test_log_group.name}"
  iam_role_arn = "${aws_iam_role.test_role.arn}"
  vpc_id = "${aws_vpc.default.id}"
  traffic_type = "ALL"
}

resource "aws_cloudwatch_log_group" "test_log_group" {
    name = "test_log_group"
}

resource "aws_iam_role" "test_role" {
    name = "test_role"
    assume_role_policy = <<EOF
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "",
      "Effect": "Allow",
      "Principal": {
        "Service": "vpc-flow-logs.amazonaws.com"
      },
      "Action": "sts:AssumeRole"
    }
  ]
} 
EOF
}

resource "aws_iam_role_policy" "test_policy" {
    name = "test_policy"
    role = "${aws_iam_role.test_role.id}"
    policy = <<EOF
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Action": [
        "logs:CreateLogGroup",
        "logs:CreateLogStream",
        "logs:PutLogEvents",
        "logs:DescribeLogGroups",
        "logs:DescribeLogStreams"
      ],
      "Effect": "Allow",
      "Resource": "*"
    }
  ]
}   
EOF
}

Argument Reference

The following arguments are supported:

Attributes Reference

The following attributes are exported:

Import

Flow Logs can be imported using the id, e.g.

$ terraform import aws_flow_log.test_flow_log fl-1a2b3c4d

See the source of this document at Terraform.io