-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathmain.tf
88 lines (73 loc) · 2.08 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
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
locals {
metadata = {
package = "terraform-aws-container"
version = trimspace(file("${path.module}/../../VERSION"))
module = basename(path.module)
name = "eks/${var.cluster_name}/iam-access"
}
module_tags = var.module_tags_enabled ? {
"module.terraform.io/package" = local.metadata.package
"module.terraform.io/version" = local.metadata.version
"module.terraform.io/name" = local.metadata.module
"module.terraform.io/full-name" = "${local.metadata.package}/${local.metadata.module}"
"module.terraform.io/instance" = local.metadata.name
} : {}
}
###################################################
# Node Access Entries
###################################################
# INFO: Not supported attributes
# - `kubernetes_username`
# - `kubernetes_groups`
module "node" {
for_each = {
for entry in var.node_access_entries :
entry.name => entry
}
source = "../eks-access-entry"
name = each.key
cluster_name = var.cluster_name
type = each.value.type
principal = each.value.principal
resource_group_enabled = false
module_tags_enabled = false
tags = merge(
{
"Name" = each.key
},
local.module_tags,
var.tags,
)
}
###################################################
# User Access Entries
###################################################
module "user" {
for_each = {
for entry in var.user_access_entries :
entry.name => entry
}
source = "../eks-access-entry"
name = each.key
cluster_name = var.cluster_name
type = "STANDARD"
principal = each.value.principal
kubernetes_username = each.value.kubernetes_username
kubernetes_groups = each.value.kubernetes_groups
kubernetes_permissions = [
for permission in each.value.kubernetes_permissions : {
policy = permission.policy
scope = permission.scope
namespaces = permission.namespaces
}
]
resource_group_enabled = false
module_tags_enabled = false
tags = merge(
{
"Name" = each.key
},
local.module_tags,
var.tags,
)
}