2015-06-17 19:58:08 +02:00
|
|
|
---
|
|
|
|
layout: "aws"
|
|
|
|
page_title: "AWS: aws_flow_log"
|
|
|
|
sidebar_current: "docs-aws-resource-flow-log"
|
|
|
|
description: |-
|
|
|
|
Provides a VPC/Subnet/ENI Flow Log
|
|
|
|
---
|
|
|
|
|
|
|
|
# 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" {
|
2016-09-23 19:18:17 +02:00
|
|
|
log_group_name = "${aws_cloudwatch_log_group.test_log_group.name}"
|
2017-02-18 23:48:50 +01:00
|
|
|
iam_role_arn = "${aws_iam_role.test_role.arn}"
|
|
|
|
vpc_id = "${aws_vpc.default.id}"
|
|
|
|
traffic_type = "ALL"
|
2015-06-17 19:58:08 +02:00
|
|
|
}
|
2015-06-22 17:07:43 +02:00
|
|
|
|
2016-09-23 19:18:17 +02:00
|
|
|
resource "aws_cloudwatch_log_group" "test_log_group" {
|
2017-02-18 23:48:50 +01:00
|
|
|
name = "test_log_group"
|
2016-09-23 19:18:17 +02:00
|
|
|
}
|
|
|
|
|
2015-06-22 17:07:43 +02:00
|
|
|
resource "aws_iam_role" "test_role" {
|
2017-02-18 23:48:50 +01:00
|
|
|
name = "test_role"
|
|
|
|
|
|
|
|
assume_role_policy = <<EOF
|
2015-06-22 17:07:43 +02:00
|
|
|
{
|
|
|
|
"Version": "2012-10-17",
|
|
|
|
"Statement": [
|
|
|
|
{
|
|
|
|
"Sid": "",
|
|
|
|
"Effect": "Allow",
|
|
|
|
"Principal": {
|
|
|
|
"Service": "vpc-flow-logs.amazonaws.com"
|
|
|
|
},
|
|
|
|
"Action": "sts:AssumeRole"
|
|
|
|
}
|
|
|
|
]
|
2017-02-18 23:48:50 +01:00
|
|
|
}
|
2015-06-22 17:07:43 +02:00
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "aws_iam_role_policy" "test_policy" {
|
2017-02-18 23:48:50 +01:00
|
|
|
name = "test_policy"
|
|
|
|
role = "${aws_iam_role.test_role.id}"
|
|
|
|
|
|
|
|
policy = <<EOF
|
2015-06-22 17:07:43 +02:00
|
|
|
{
|
|
|
|
"Version": "2012-10-17",
|
|
|
|
"Statement": [
|
|
|
|
{
|
|
|
|
"Action": [
|
|
|
|
"logs:CreateLogGroup",
|
|
|
|
"logs:CreateLogStream",
|
|
|
|
"logs:PutLogEvents",
|
|
|
|
"logs:DescribeLogGroups",
|
|
|
|
"logs:DescribeLogStreams"
|
|
|
|
],
|
|
|
|
"Effect": "Allow",
|
|
|
|
"Resource": "*"
|
|
|
|
}
|
|
|
|
]
|
2017-02-18 23:48:50 +01:00
|
|
|
}
|
2015-06-22 17:07:43 +02:00
|
|
|
EOF
|
|
|
|
}
|
2015-06-17 19:58:08 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
## Argument Reference
|
|
|
|
|
|
|
|
The following arguments are supported:
|
|
|
|
|
2015-06-22 16:25:27 +02:00
|
|
|
* `log_group_name` - (Required) The name of the CloudWatch log group
|
|
|
|
* `iam_role_arn` - (Required) The ARN for the IAM role that's used to post flow
|
2015-06-17 19:58:08 +02:00
|
|
|
logs to a CloudWatch Logs log group
|
|
|
|
* `vpc_id` - (Optional) VPC ID to attach to
|
|
|
|
* `subnet_id` - (Optional) Subnet ID to attach to
|
|
|
|
* `eni_id` - (Optional) Elastic Network Interface ID to attach to
|
|
|
|
* `traffic_type` - (Required) The type of traffic to capture. Valid values:
|
|
|
|
`ACCEPT`,`REJECT`, `ALL`
|
|
|
|
|
|
|
|
## Attributes Reference
|
|
|
|
|
|
|
|
The following attributes are exported:
|
|
|
|
|
|
|
|
* `id` - The Flow Log ID
|
2016-07-21 00:28:59 +02:00
|
|
|
|
|
|
|
## Import
|
|
|
|
|
2017-02-18 23:48:50 +01:00
|
|
|
Flow Logs can be imported using the `id`, e.g.
|
2016-07-21 00:28:59 +02:00
|
|
|
|
|
|
|
```
|
|
|
|
$ terraform import aws_flow_log.test_flow_log fl-1a2b3c4d
|
2016-09-23 19:18:17 +02:00
|
|
|
```
|