EKS Deployment by Terraform

How to provision a production-ready Amazon EKS cluster using Terraform and deploy your first application.

By Ali Bashir · Kubernetes · Feb 14, 2022 · 2 min read

Amazon Elastic Kubernetes Service (EKS) is a managed service that lets you run Kubernetes on AWS without needing to install, operate, or maintain your own control plane.

What Amazon EKS Provides

  • Runs and scales the Kubernetes control plane across multiple AWS Availability Zones
  • Automatically scales control plane instances based on load
  • Detects and replaces unhealthy control plane instances
  • Patches the control plane; you choose when to upgrade the Kubernetes version
  • Integrates natively with Amazon ECR, Elastic Load Balancing, IAM, and VPC

EC2 vs Node Group vs Fargate

EKS with EC2 (self-managed) - You manage the worker node infrastructure directly.

EKS with Node Groups (semi-managed) - AWS creates and deletes EC2 instances based on your configuration.

EKS with Fargate (fully-managed) - Serverless container deployment, no server provisioning required.

Infrastructure Deployment with Terraform

Terraform is an Infrastructure as Code tool. Instead of clicking through the console, you define your desired resources in HCL (HashiCorp Configuration Language) and Terraform executes them.

terraform init
terraform validate
terraform plan
terraform apply -auto-approve

-auto-approve skips the interactive "yes" prompt that normally lets you review the plan before anything changes, so only use it in automation, after you have checked the terraform plan output.

Connecting to Your Cluster

Once the cluster is provisioned, update your kubeconfig:

aws eks --region us-east-1 update-kubeconfig --name my-cluster

Then deploy your application using standard Kubernetes manifests:

kubectl apply -f deployment.yaml
kubectl apply -f service.yaml
kubectl get svc

Why Terraform for EKS?

Using Terraform to provision EKS means your entire cluster configuration - VPC, subnets, node groups, IAM roles - is version-controlled, reviewable, and reproducible. Spinning up a new environment becomes a single command. Tearing it down is the same.

This is the foundation of treating infrastructure as software - and it's how modern DevOps teams move fast without breaking things.