-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
51 lines (46 loc) · 1.11 KB
/
main.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
51
resource "aws_iam_policy" "aws_cluster_fluentbit" {
name = var.policy_name
path = "/"
description = "Allows access to resources needed to run kubernetes cluster fluentbit."
policy = <<JSON
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:DescribeLogStreams",
"logs:PutLogEvents",
"logs:PutRetentionPolicy"
],
"Resource": "*"
}
]
}
JSON
}
resource "aws_iam_role" "aws_cluster_fluentbit" {
count = var.ec2_role_name == null ? 1 : 0
name = var.role_name
path = "/"
assume_role_policy = <<JSON
{
"Version": "2012-10-17",
"Statement": [
{
"Action": "sts:AssumeRoleWithWebIdentity",
"Effect": "Allow",
"Principal": {
"Federated": "${var.oidc_assume_role_arn}"
}
}
]
}
JSON
}
resource "aws_iam_role_policy_attachment" "aws_cluster_fluentbit" {
policy_arn = aws_iam_policy.aws_cluster_fluentbit.arn
role = var.ec2_role_name == null ? aws_iam_role.aws_cluster_fluentbit[0].name : var.ec2_role_name
}