A Terraform-based IaC that provisions an Amazon EKS cluster on AWS with VPC, subnets, managed node groups, and add-ons (AWS Load Balancer Controller & Amazon EBS CSI Driver) using IRSA and Kubernetes RBAC best practices.
blog: https://adityadubey.tech/deploying-an-amazon-eks-cluster-with-terraform
The infrastructure follows a resilient, secure, and highly available design spanning multiple AWS Availability Zones.
- Public Subnets: These subnets house NAT Gateways that allow outbound internet access for resources in private subnets.
- Private Subnets: These subnets contain the EKS worker nodes, providing an additional layer of security by isolating them from direct internet access.
- Ingress Controller: Deployed as part of the EKS cluster to manage external access to services running within the cluster.
- Terraform: v1.11.3+
- AWS ~> 5.0: EKS, VPC, IAM
- Kubernetes: v2.0+
- Automated provisioning of an EKS cluster with VPC, subnets, and managed node groups
- A highly available Multi-AZ VPC with public/private subnets and NAT gateways
- Integration of critical EKS add-ons: CoreDNS, kube-proxy, AWS VPC CNI, and EBS CSI Driver
- Kubernetes RBAC best practices for secure access control
- Automated deployment of add-ons with proper IAM permissions
- Deployed the AWS Load Balancer Controller with full Ingress support
- Configured DNS + ALB Ingress to expose workloads securely
- Cluster Autoscaler for automatic scaling of EKS node groups based on pod resource demands
- Terraform CLI
- AWS CLI
- Kubernetes CLI
- Clone the repository:
git clone https://github.com/yourusername/terraform-eks-infrastructure.git
cd terraform-eks-infrastructure
- Configure AWS CLI:
aws configure
- Create a terraform.tfvars file:
cp terraform.tfvars.example terraform.tfvars
-
Customize the variables in terraform.tfvars
Edit the terraform.tfvars file to tailor the variables to your specific needs.
- Initialize Terraform:
terraform init
- Plan the deployment:
terraform plan
- Apply the configuration:
terraform apply
- Set the AWS CLI profile:
Run the following command to update your kubeconfig file, allowing kubectl
to communicate with the EKS cluster:
aws eks update-kubeconfig --name <eks_cluster_name> --region <aws_region>
- Verify the connection:
kubectl get nodes
Contributions are welcome! Please open an issue or submit a pull request.