Skip to content

Instantly share code, notes, and snippets.

@100daysofdevops
Created March 10, 2019 17:38
Show Gist options
  • Select an option

  • Save 100daysofdevops/71ed57066e1a6c89011fb698fb600938 to your computer and use it in GitHub Desktop.

Select an option

Save 100daysofdevops/71ed57066e1a6c89011fb698fb600938 to your computer and use it in GitHub Desktop.
resource "aws_flow_log" "example" {
iam_role_arn = "${aws_iam_role.example.arn}"
log_destination = "${aws_cloudwatch_log_group.example.arn}"
traffic_type = "ALL"
vpc_id = "${var.vpc_id}"
}
resource "aws_cloudwatch_log_group" "example" {
name = "example"
}
resource "aws_iam_role" "example" {
name = "example"
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" "example" {
name = "example"
role = "${aws_iam_role.example.id}"
policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents",
"logs:DescribeLogGroups",
"logs:DescribeLogStreams"
],
"Effect": "Allow",
"Resource": "*"
}
]
}
EOF
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment