EKS Infrastructure Template
Production-ready EKS infrastructure template with Terraform, Kustomize, and CI/CD pipelines.
EKS cluster with VPC and managed node groups
AWS Load Balancer Controller for ALB Ingress
Multi-environment support (dev, qa, prod)
GitHub Actions CI/CD workflows
Pre-commit hooks with security scanning
Cost estimation with Infracost
Semantic versioning and releases
Search for # TODO: Customize comments and update:
variables.tf - Default region and project prefix
environments/*/ - Environment-specific configurations
.github/workflows/deploy-k8s-app.yml - Cluster name prefix
pre-commit install
terraform init
# Plan
terraform plan -var-file=environments/dev/dev.tfvars
# Apply
terraform apply -var-file=environments/dev/dev.tfvars
# Configure kubectl
aws eks --region < region> update-kubeconfig --name < prefix> -dev-cluster
# Build and preview manifests
kustomize build k8s/apps/nginx/overlays/dev/
# Deploy
kubectl apply -k k8s/apps/nginx/overlays/dev/
# Verify
kubectl get all -n dev -l app=nginx
flowchart TB
GH[GitHub Actions]
GH --> TF[Terraform Infrastructure]
GH --> K8S[kubectl / Kustomize Applications]
subgraph AWS
subgraph VPC
PUB[Public Subnets]
PRI[Private Subnets]
end
subgraph EKS[EKS Cluster]
ALB[ALB Controller]
SPOT[Node Group SPOT]
OD[Node Group ON_DEMAND]
end
end
TF --> VPC
TF --> EKS
K8S --> EKS
PUB --> ALB
PRI --> SPOT
PRI --> OD
Loading
Environment Configurations
Setting
Dev
QA
Prod
AZs
2
3
3
NAT Gateway
Single
Single
Per AZ
SPOT Nodes
Yes
Yes
Yes
ON_DEMAND Nodes
No
Yes
Yes
SPOT min/max
1/3
1/3
2/5
ON_DEMAND min/max
-
1/2
2/4
.
├── main.tf # Root orchestration
├── variables.tf # Input variables
├── outputs.tf # Outputs
├── locals.tf # Local values
├── versions.tf # Terraform/provider versions
├── providers.tf # Provider configuration
├── modules/
│ ├── eks/ # EKS + VPC module
│ └── aws-load-balancer-controller/
├── environments/
│ ├── dev/dev.tfvars
│ ├── qa/qa.tfvars
│ └── prod/prod.tfvars
├── k8s/apps/nginx/ # Example nginx app
│ ├── base/
│ └── overlays/{dev,qa,prod}/
└── .github/workflows/ # CI/CD pipelines
Workflow
Trigger
Purpose
deploy-eks.yml
Manual
Terraform plan/apply/destroy
deploy-k8s-app.yml
Manual
K8s app deploy/rollback
pre-commit-ci.yaml
PR
Pre-commit checks
checkov.yaml
PR/Push
Security scanning
infracost.yaml
PR
Cost estimates
tf-docs.yaml
PR
Auto-generate docs
gitleaks.yaml
PR/Push
Secret detection
release.yaml
Push to main
Semantic release
lint-pr.yaml
PR
PR title validation
docs-deploy.yaml
Push to main / PR
Build and deploy documentation
Secret
Description
AWS_ACCESS_KEY_ID
AWS access key
AWS_SECRET_ACCESS_KEY
AWS secret key
AWS_REGION
AWS region
INFRACOST_API_KEY
Infracost API key (optional)
GITLEAKS_LICENSE
GitLeaks license (optional)
WORKFLOW_TOKEN
GitHub token for pre-commit auto-fix
Create k8s/apps/{app-name}/base/ with deployment, service, configmap
Create overlays in k8s/apps/{app-name}/overlays/{dev,qa,prod}/
Add app to .github/workflows/deploy-k8s-app.yml choices
Test with kustomize build and kubectl apply --dry-run
No providers.
No resources.
Name
Description
Type
Default
Required
ami_type
AMI type for EKS nodes
string
"AL2_x86_64"
no
availability_zones_count
Number of availability zones to use for EKS VPC
number
3
no
cluster_version
Kubernetes cluster version
string
"1.31"
no
enable_alb_controller
Enable AWS Load Balancer Controller deployment
bool
false
no
enable_eks
Enable EKS cluster deployment
bool
false
no
env
The environment to deploy (dev, qa, prod)
string
n/a
yes
node_groups
EKS managed node groups configuration
any
{}
no
prefix
The prefix for all resource names
string
"my-project"
no
region
The AWS region to deploy resources
string
"ap-southeast-1"
no
single_nat_gateway
Use single NAT gateway for all private subnets (cost optimization)
bool
true
no
vpc_cidr
CIDR block for VPC
string
"10.0.0.0/16"
no