-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.tf
68 lines (59 loc) · 2.03 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
resource "aws_iam_policy" "alb-ingress-controller-iam-policy" {
name = "ALBIngressControllerIAMPolicy"
policy = data.aws_iam_policy_document.policy.json
}
resource "aws_iam_role" "alb-ingress-controller-iam-role" {
name = "ALBIngressControllerIAMRole"
assume_role_policy = jsonencode(
{
Statement = [
{
Action = "sts:AssumeRoleWithWebIdentity"
Condition = {
StringEquals = {
"${var.oidc_host_path}:aud" = "sts.amazonaws.com"
}
}
Effect = "Allow",
Principal = {
Federated = "arn:aws:iam::${var.account_id}:oidc-provider/${var.oidc_host_path}"
}
},
]
Version = "2012-10-17"
}
)
}
resource "aws_iam_role_policy_attachment" "alb-ingress-controller-iam-role-policy-attachment" {
role = aws_iam_role.alb-ingress-controller-iam-role.name
policy_arn = aws_iam_policy.alb-ingress-controller-iam-policy.arn
}
resource "kubectl_manifest" "ingessclassparams" {
yaml_body = file("${path.module}/yamls/ingressclassparams.yaml")
wait = true
}
resource "kubectl_manifest" "targetgroupbindings" {
yaml_body = file("${path.module}/yamls/targetgroupbindings.yaml")
wait = true
}
resource "helm_release" "aws-load-balancer-controller" {
depends_on = [kubectl_manifest.ingessclassparams, kubectl_manifest.targetgroupbindings]
name = "aws-load-balancer-controller"
namespace = "kube-system"
repository = "https://aws.github.io/eks-charts"
chart = "aws-load-balancer-controller"
version = "1.6.2"
#This defaults to false, recreation is required when upgrading the module from version 2.1 and lower
force_update = var.force_update
values = [
templatefile(
"${path.module}/yamls/loadbalancer-values.yaml",
{
cluster_name = var.eks_cluster_name
vpc_id = var.vpc_id
region = var.region
service_account_name = kubernetes_service_account.alb_ingress_controller.metadata[0].name
}
)
]
}