Skip to content

17J/IAC-EKS-Cluster

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚀 Terraform EKS Cluster Deployment on AWS

This guide provisions an Amazon Elastic Kubernetes Service (EKS) cluster using Terraform, including configurations for accessing and managing the cluster.


🛠️ Prerequisites

Ensure the following are installed and configured before starting:

  • AWS CLI: Version 2.x. Install guide.
  • Kubectl: Compatible with your EKS cluster version (e.g., 1.30). Install guide.
  • Terraform CLI: Version 1.x (recommended: 1.5 or later). Install guide.
  • AWS IAM User: With programmatic access and sufficient permissions (e.g., a custom policy with EKS, VPC, IAM, and EC2 permissions).
  • AWS Credentials: Configured via ~/.aws/credentials or environment variables:
    export AWS_ACCESS_KEY_ID="your-access-key"
    export AWS_SECRET_ACCESS_KEY="your-secret-key"
    export AWS_DEFAULT_REGION="us-east-1"

🧪 Steps to Deploy EKS Using Terraform

1️⃣ Authenticate with AWS CLI

Configure your AWS CLI with the appropriate credentials:

aws configure

Provide:

  • AWS Access Key ID
  • AWS Secret Access Key
  • Default region (e.g., us-east-1)
  • Output format (e.g., json)

Verify authentication:

aws sts get-caller-identity

2️⃣ Clone or Set Up Terraform Code

Navigate to your Terraform project directory containing the EKS configuration (e.g., main.tf, variables.tf, outputs.tf). If you don’t have one, use or adapt the AWS EKS Terraform module.

Example directory setup:

cd IAC-EKS-Cluster

Ensure your Terraform configuration includes:

  • VPC setup (subnets, route tables, NAT gateway, etc.)
  • EKS cluster with managed node groups or Fargate profiles
  • IAM roles for EKS and node groups
  • Security group rules for cluster communication

3️⃣ Initialize Terraform

Initialize the Terraform working directory to download providers and modules:

terraform init

4️⃣ Preview the Terraform Execution Plan

Review the resources Terraform will create or modify:

terraform plan

Check the output for correctness (e.g., cluster name, region, node group size).

5️⃣ Deploy the EKS Cluster

Apply the Terraform configuration to provision the EKS cluster:

terraform apply

Type yes when prompted to confirm. This may take 10–15 minutes.

6️⃣ Configure Kubeconfig for EKS

Update your kubectl configuration to connect to the EKS cluster. Replace ap-south-1 and cluster-name with your region and EKS cluster name (as defined in your Terraform config):

aws eks --region ap-south-1 update-kubeconfig --name cluster-name

Verify cluster access:

kubectl get nodes

You should see the nodes in your EKS cluster.


🧹 Cleanup

To destroy the EKS cluster and associated resources, run:

terraform destroy

Type yes when prompted. Ensure you’ve backed up any critical data before destroying.


About

IAC EKS Cluster

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages