forked from helium/helium-foundation-k8s
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlb.tf
57 lines (52 loc) · 1.39 KB
/
lb.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
locals {
lb_role_name = "${local.cluster_name}-aws-load-balancer-controller"
}
resource "aws_iam_role" "lb" {
name = local.lb_role_name
assume_role_policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Federated": "arn:aws:iam::${data.aws_caller_identity.current.account_id}:oidc-provider/${local.oidc_url}"
},
"Action": "sts:AssumeRoleWithWebIdentity",
"Condition": {
"StringEquals": {
"${local.oidc_url}:sub": "system:serviceaccount:default:lb"
}
}
}
]
}
EOF
}
resource "aws_iam_role_policy" "lb" {
name_prefix = local.lb_role_name
role = aws_iam_role.lb.name
policy = file("${path.module}/policies/lb.json")
}
resource "helm_release" "lbc" {
name = "aws-load-balancer-controller"
chart = "aws-load-balancer-controller"
version = "1.4.5"
namespace = "default"
repository = "https://aws.github.io/eks-charts"
create_namespace = true
cleanup_on_fail = true
set {
name = "clusterName"
value = local.cluster_name
}
set {
name = "serviceAccount.name"
value = "lb"
}
}
resource "kubectl_manifest" "nginx" {
depends_on = [helm_release.argocd]
count = length(data.kubectl_path_documents.nginx.documents)
yaml_body = element(data.kubectl_path_documents.nginx.documents, count.index)
}