DEV Community

sagark
sagark

Posted on • Edited on

Deploying AWS EKS with ALB Using Terraform

πŸ”₯ Introduction
In cloud-native architectures, Amazon EKS (Elastic Kubernetes Service) is a powerful way to manage containerized applications at scale. When combined with AWS ALB (Application Load Balancer), it ensures seamless traffic management, automatic scaling, and security.

In this guide, I'll walk you through setting up an EKS cluster and deploying an ALB Ingress Controller using Terraform.

πŸ“Œ Why Use ALB with EKS?
Amazon's Application Load Balancer (ALB) integrates well with Kubernetes to:
βœ… Distribute traffic efficiently across multiple pods
βœ… Enable SSL/TLS termination for security
βœ… Support path-based & host-based routing
βœ… Improve scalability with auto-healing features

πŸ› οΈ Tech Stack
Terraform – Infrastructure as Code
AWS EKS – Kubernetes Cluster
AWS ALB – Load Balancer
IAM Roles & Policies – Secure Access
Helm – Package Manager for Kubernetes

πŸš€ Step 1: Setting Up AWS EKS with Terraform
First, define the EKS cluster in Terraform:

resource "aws_eks_cluster" "eks" {
  name     = "my-eks-cluster"
  role_arn = aws_iam_role.eks_role.arn

  vpc_config {
    subnet_ids = [aws_subnet.public_1.id, aws_subnet.public_2.id]
  }
}
Enter fullscreen mode Exit fullscreen mode

Create IAM Role for the ALB Controller:

resource "aws_iam_role" "alb_controller" {
  name = "alb-controller-role"
  assume_role_policy = jsonencode({
    Statement = [{
      Effect = "Allow"
      Principal = {
        Service = "eks.amazonaws.com"
      }
      Action = "sts:AssumeRole"
    }]
  })
}
Enter fullscreen mode Exit fullscreen mode

πŸš€ Step 2: Deploy ALB Ingress Controller
Once EKS is up and running, install the ALB Ingress Controller using Helm:

helm repo add eks https://aws.github.io/eks-charts

Enter fullscreen mode Exit fullscreen mode
helm install aws-load-balancer-controller eks/aws-load-balancer-controller \
  --set clusterName=my-eks-cluster \
  --set serviceAccount.create=false \
  --set serviceAccount.name=alb-controller \
  -n kube-system
Enter fullscreen mode Exit fullscreen mode

πŸš€ Step 3: Define Ingress Rules
Now, create an Ingress resource to route traffic via ALB:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: my-ingress
  annotations:
    alb.ingress.kubernetes.io/scheme: internet-facing
    alb.ingress.kubernetes.io/target-type: ip
spec:
  rules:
  - host: my-app.example.com
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: my-service
            port:
              number: 80
Enter fullscreen mode Exit fullscreen mode

Apply the changes:

kubectl apply -f ingress.yaml

Enter fullscreen mode Exit fullscreen mode

βœ… Verify Deployment
Check if the ALB is created:

kubectl get ingress -A

Enter fullscreen mode Exit fullscreen mode

Head over to AWS Console β†’ EC2 β†’ Load Balancers and verify the ALB instance.

🎯 Conclusion
With Terraform and Helm, deploying EKS with ALB is now streamlined and automated. This setup ensures a highly scalable, secure, and manageable cloud-native architecture.

If you found this guide helpful, drop a comment or share your experience! πŸš€

Top comments (0)