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
touch my_cluster.tf
my_cluster.tf
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

hello-k8s-deploy.yaml

Deploy the Pods

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

Create Service Manifest

hello-k8s-svc.yaml

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

References

Terraform Related

Kubectl Install

Creating EKS Cluster without AWS EKS Module

Conclusion

--

--

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