forked from lablabs/terraform-aws-eks-external-dns
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
52 lines (46 loc) · 1.28 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
locals {
k8s_irsa_role_create = var.enabled && var.k8s_rbac_create && var.k8s_service_account_create && var.k8s_irsa_role_create
values = yamlencode({
"aws" : {
"region" : data.aws_region.current.name
"assumeRoleArn" : var.k8s_assume_role_arn
}
"rbac" : {
"create" : var.k8s_rbac_create
}
"serviceAccount" : {
"create" : var.k8s_service_account_create
"name" : var.k8s_service_account_name
"annotations" : {
"eks.amazonaws.com/role-arn" : local.k8s_irsa_role_create ? aws_iam_role.external_dns[0].arn : ""
}
}
})
}
data "aws_region" "current" {}
data "utils_deep_merge_yaml" "values" {
count = var.enabled ? 1 : 0
input = compact([
local.values,
var.values
])
}
resource "helm_release" "external_dns" {
count = var.enabled && !var.argo_application_enabled ? 1 : 0
chart = var.helm_chart_name
create_namespace = var.helm_create_namespace
namespace = var.k8s_namespace
name = var.helm_release_name
version = var.helm_chart_version
repository = var.helm_repo_url
values = [
data.utils_deep_merge_yaml.values[0].output
]
dynamic "set" {
for_each = var.settings
content {
name = set.key
value = set.value
}
}
}