1- resource "kubernetes_service_account_v1" "alb_controller" {
2- metadata {
3- name = " aws-load-balancer-controller"
4- namespace = " kube-system"
5-
6- annotations = {
7- " eks.amazonaws.com/role-arn" = aws_iam_role.alb_controller.arn
8- }
9- }
10- }
11-
12- resource "helm_release" "alb_controller" {
13- depends_on = [
14- aws_eks_cluster . nginx ,
15- aws_eks_fargate_profile . nginx ,
16- aws_eks_node_group . system_nodes ,
17- kubernetes_service_account_v1 . alb_controller
18- ]
19-
20- name = " aws-load-balancer-controller"
21- repository = " https://aws.github.io/eks-charts"
22- chart = " aws-load-balancer-controller"
23- namespace = " kube-system"
24-
25- values = [
26- templatefile (" ${ path . module } /files/alb-values.yaml" , {
27- CLUSTER_NAME = aws_eks_cluster.nginx.name
28- SERVICE_ACCOUNT_NAME = kubernetes_service_account_v1.alb_controller.metadata[0 ].name
29- AWS_REGION = var.aws_region
30- VPC_ID = aws_vpc.eks.id
31- SUBNET_1 = aws_subnet.eks[0 ].id
32- SUBNET_2 = aws_subnet.eks[1 ].id
33- })
34- ]
35- }
36-
371resource "helm_release" "html-db" {
38- depends_on = [helm_release . alb_controller ]
2+ depends_on = [module . eks_cluster ]
393
404 name = " html-db"
415 repository = " https://falltrades.github.io/cloud-example"
@@ -47,9 +11,9 @@ resource "helm_release" "html-db" {
4711
4812 values = [
4913 templatefile (" ${ path . module } /files/html-db-values.yaml" , {
50- SUBNET_1 = aws_subnet.public [0 ].id
51- SUBNET_2 = aws_subnet.public [1 ].id
52- ALB_SG_ID = aws_security_group.alb.id
14+ SUBNET_1 = module.eks_cluster.public_subnets [0 ]
15+ SUBNET_2 = module.eks_cluster.public_subnets [1 ]
16+ ALB_SG_ID = module.eks_cluster.alb_security_group_id
5317 DB_NAME = var.db_name
5418 DB_USER = var.db_username
5519 DB_PASSWORD = var.db_password
0 commit comments