Building Amazon EKS with Terraform

Using Terraform to create an Elastic Kubernetes Service Cluster

Previous Article

Required Tools

Doing it the Terraform Way

Setup Project Environment

mkdir -p ~/projects/eks-basic && cd ~/projects/eks-basic
export TF_VAR_eks_cluster_name=adorable-unicorn
export TF_VAR_region=us-east-2

Preparation for EKS Cluster

terraform init
terraform plan

Create the EKS Cluster

terraform apply

Configure Kubernetes CLI

export KUBECONFIG=$PWD/kubeconfig_${TF_VAR_eks_cluster_name}
kubectl get all --all-namespaces
Output of kubectl get all command

Deploying Applications

Create Deploy Manifest


Deploy the Pods

kubectl apply -f hello-k8s-deploy.yaml
kubectl get pods
Output of kubectl get pods

Create Service Manifest


Deploy the Service

kubectl apply -f hello-k8s-svc.yaml
kubectl get svc
Output of kubectl get svc

Connecting to the Application

Cleaning Up

kubectl delete -f hello-k8s-deploy.yaml
kubectl delete -f hello-k8s-svc.yaml
terraform destroy


Terraform Related

Kubectl Install

Creating EKS Cluster without AWS EKS Module




Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Joaquín Menchaca (智裕)

Linux NinjaPants Automation Engineering Mutant — exploring DevOps, o11y, k8s, progressive deployment (ci/cd), cloud native infra, infra as code