-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRole.tf
More file actions
executable file
·62 lines (55 loc) · 1.11 KB
/
Role.tf
File metadata and controls
executable file
·62 lines (55 loc) · 1.11 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
## Variables
variable "IAM_VPC_Flow_Logs_Prefix" {
default = "VPC_Flow_Logs"
}
variable "Role_Suffix" {
default = "role"
}
variable "Policy_Suffix" {
default = "policy"
}
## Resources
resource "aws_iam_role" "defined" {
name = "${var.IAM_VPC_Flow_Logs_Prefix}_${var.Role_Suffix}"
assume_role_policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "",
"Effect": "Allow",
"Action": "sts:AssumeRole",
"Principal": {
"Service": "vpc-flow-logs.amazonaws.com"
}
}
]
}
EOF
}
resource "aws_iam_role_policy" "defined" {
name = "${var.IAM_VPC_Flow_Logs_Prefix}_${var.Policy_Suffix}"
role = aws_iam_role.defined.id
policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [{
"Action": [
"logs:CreateLogGroup","logs:CreateLogStream",
"logs:PutLogEvents","logs:DescribeLogGroups",
"logs:DescribeLogStreams"
],
"Effect": "Allow",
"Resource": "*"
}
]
}
EOF
}
## Outputs
output "aws_iam_role_defined" {
value = aws_iam_role.defined
}
output "aws_iam_role_defined_arn" {
value = aws_iam_role.defined.arn
}