-
Notifications
You must be signed in to change notification settings - Fork 0
/
iam.tf
50 lines (46 loc) · 1.23 KB
/
iam.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
data "aws_iam_policy_document" "vpc_flow" {
version = "2012-10-17"
statement {
actions = [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents",
"logs:DescribeLogGroups",
"logs:DescribeLogStreams"
]
resources = [
"*"
]
effect = "Allow"
}
}
resource "aws_iam_role_policy" "vpc_flow" {
name = "vpc_flow_${var.name}_${var.project}_${var.environment}"
role = aws_iam_role.vpc_flow.name
policy = data.aws_iam_policy_document.vpc_flow.json
}
data "aws_iam_policy_document" "cloudwatch_vpc_flow" {
version = "2012-10-17"
statement {
actions = [
"sts:AssumeRole"
]
principals {
type = "Service"
identifiers = ["vpc-flow-logs.amazonaws.com"]
}
effect = "Allow"
}
}
resource "aws_iam_role" "vpc_flow" {
path = "/${var.project}/${var.environment}/"
name = "vpc_flow_${var.name}_${var.project}_${var.environment}"
description = "manages vpc flow log writing"
assume_role_policy = data.aws_iam_policy_document.cloudwatch_vpc_flow.json
tags = {
Name = "${var.name} cloudwatch vpc flow"
terraform = "true"
project = var.project
environment = var.environment
}
}