forked from lean-delivery/terraform-module-aws-eks
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathiam.tf
100 lines (79 loc) · 2.33 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
data "aws_iam_policy_document" "external-dns-policy" {
statement {
effect = "Allow"
actions = [
"route53:ListHostedZones",
"route53:ListResourceRecordSets",
]
resources = [
"*",
]
}
statement {
effect = "Allow"
actions = [
"route53:ChangeResourceRecordSets",
]
resources = [
"*",
]
}
}
resource "aws_iam_policy" "external-dns-policy" {
count = "${ var.deploy_external_dns ? 1 : 0 }"
name = "${var.project}-${var.environment}-external-dns-policy"
policy = "${data.aws_iam_policy_document.external-dns-policy.json}"
}
resource "aws_iam_role_policy_attachment" "external-dns-policy" {
count = "${ var.deploy_external_dns ? 1 : 0 }"
role = "${module.eks.worker_iam_role_name}"
policy_arn = "${aws_iam_policy.external-dns-policy.arn}"
}
data "aws_iam_policy_document" "k8s-autoscaler" {
statement {
effect = "Allow"
actions = [
"autoscaling:DescribeAutoScalingGroups",
"autoscaling:DescribeAutoScalingInstances",
"autoscaling:SetDesiredCapacity",
"autoscaling:TerminateInstanceInAutoScalingGroup",
"autoscaling:DescribeTags",
"autoscaling:DescribeLaunchConfigurations",
]
resources = [
"*",
]
}
}
resource "aws_iam_policy" "k8s-autoscaler" {
name = "${var.project}-${var.environment}-k8s-autoscaler-policy"
policy = "${data.aws_iam_policy_document.k8s-autoscaler.json}"
}
resource "aws_iam_role_policy_attachment" "k8s-autoscaler" {
role = "${module.eks.worker_iam_role_name}"
policy_arn = "${aws_iam_policy.k8s-autoscaler.arn}"
}
data "aws_iam_policy_document" "cloudwatch-access" {
statement {
effect = "Allow"
actions = [
"logs:CreateLogStream",
"logs:PutLogEvents",
"logs:DescribeLogGroups",
"logs:DescribeLogStreams",
]
resources = [
"arn:aws:logs:*:*:*",
]
}
}
resource "aws_iam_policy" "cloudwatch-access" {
count = "${ var.enable_container_logs ? 1 : 0 }"
name = "${var.project}-${var.environment}-cloudwatch-access-policy"
policy = "${data.aws_iam_policy_document.cloudwatch-access.json}"
}
resource "aws_iam_role_policy_attachment" "cloudwatch-access" {
count = "${ var.enable_container_logs ? 1 : 0 }"
role = "${module.eks.worker_iam_role_name}"
policy_arn = "${aws_iam_policy.cloudwatch-access.arn}"
}