github.com/ves/terraform@v0.8.0-beta2/website/source/docs/providers/aws/r/flow_log.html.markdown (about) 1 --- 2 layout: "aws" 3 page_title: "AWS: aws_flow_log" 4 sidebar_current: "docs-aws-resource-flow-log" 5 description: |- 6 Provides a VPC/Subnet/ENI Flow Log 7 --- 8 9 # aws\_flow\_log 10 11 Provides a VPC/Subnet/ENI Flow Log to capture IP traffic for a specific network 12 interface, subnet, or VPC. Logs are sent to a CloudWatch Log Group. 13 14 ``` 15 resource "aws_flow_log" "test_flow_log" { 16 log_group_name = "${aws_cloudwatch_log_group.test_log_group.name}" 17 iam_role_arn = "${aws_iam_role.test_role.arn}" 18 vpc_id = "${aws_vpc.default.id}" 19 traffic_type = "ALL" 20 } 21 22 resource "aws_cloudwatch_log_group" "test_log_group" { 23 name = "test_log_group" 24 } 25 26 resource "aws_iam_role" "test_role" { 27 name = "test_role" 28 assume_role_policy = <<EOF 29 { 30 "Version": "2012-10-17", 31 "Statement": [ 32 { 33 "Sid": "", 34 "Effect": "Allow", 35 "Principal": { 36 "Service": "vpc-flow-logs.amazonaws.com" 37 }, 38 "Action": "sts:AssumeRole" 39 } 40 ] 41 } 42 EOF 43 } 44 45 resource "aws_iam_role_policy" "test_policy" { 46 name = "test_policy" 47 role = "${aws_iam_role.test_role.id}" 48 policy = <<EOF 49 { 50 "Version": "2012-10-17", 51 "Statement": [ 52 { 53 "Action": [ 54 "logs:CreateLogGroup", 55 "logs:CreateLogStream", 56 "logs:PutLogEvents", 57 "logs:DescribeLogGroups", 58 "logs:DescribeLogStreams" 59 ], 60 "Effect": "Allow", 61 "Resource": "*" 62 } 63 ] 64 } 65 EOF 66 } 67 ``` 68 69 ## Argument Reference 70 71 The following arguments are supported: 72 73 * `log_group_name` - (Required) The name of the CloudWatch log group 74 * `iam_role_arn` - (Required) The ARN for the IAM role that's used to post flow 75 logs to a CloudWatch Logs log group 76 * `vpc_id` - (Optional) VPC ID to attach to 77 * `subnet_id` - (Optional) Subnet ID to attach to 78 * `eni_id` - (Optional) Elastic Network Interface ID to attach to 79 * `traffic_type` - (Required) The type of traffic to capture. Valid values: 80 `ACCEPT`,`REJECT`, `ALL` 81 82 ## Attributes Reference 83 84 The following attributes are exported: 85 86 * `id` - The Flow Log ID 87 88 ## Import 89 90 Flow Logs can be imported using the `id`, e.g. 91 92 ``` 93 $ terraform import aws_flow_log.test_flow_log fl-1a2b3c4d 94 ```