-
-
Notifications
You must be signed in to change notification settings - Fork 28
/
alb.tf
44 lines (39 loc) · 1.27 KB
/
alb.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
module "iam_assumable_role_alb" {
source = "terraform-aws-modules/iam/aws//modules/iam-assumable-role-with-oidc"
version = "5.46.0"
create_role = true
role_name = "${var.environment_name}-${local.alb_name}"
provider_url = replace(aws_iam_openid_connect_provider.cluster.url, "https://", "")
role_policy_arns = [aws_iam_policy.alb.arn]
# namespace and service account name
oidc_fully_qualified_subjects = [
"system:serviceaccount:kube-system:${local.alb_name}"
]
tags = local.tags
}
resource "helm_release" "aws_load_balancer" {
count = var.aws_load_balancer_controller_enabled ? 1 : 0
name = local.alb_name
namespace = "kube-system"
repository = "https://aws.github.io/eks-charts"
chart = "aws-load-balancer-controller"
version = var.alb_controller_version
depends_on = [
module.iam_assumable_role_alb,
kubernetes_config_map.aws_auth
]
wait = false
values = [<<EOF
clusterName: ${var.environment_name}
region: ${data.aws_region.current.name}
vpcId: ${aws_vpc.vpc.id}
serviceAccount:
controller:
create: true
name: ${local.alb_name}
## Enable if EKS IAM for SA is used
annotations:
eks.amazonaws.com/role-arn: "${module.iam_assumable_role_alb.iam_role_arn}"
EOF
]
}