Skip to content

Flack74/IAC-Vpro

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

23 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ VProfile EKS Infrastructure as Code

Terraform AWS Kubernetes CI/CD

A production-ready Infrastructure as Code (IaC) solution for deploying a scalable Amazon EKS cluster with automated CI/CD pipeline using Terraform and GitHub Actions.

πŸ“‹ Table of Contents

🎯 Overview

This project demonstrates enterprise-level Infrastructure as Code practices by provisioning a complete Amazon EKS (Elastic Kubernetes Service) environment on AWS. The infrastructure is designed with scalability, security, and cost-efficiency in mind, featuring automated deployment through GitHub Actions.

Key Highlights:

  • πŸ—οΈ Infrastructure as Code: Complete AWS EKS cluster provisioning using Terraform
  • πŸ”„ Automated CI/CD: GitHub Actions workflow for continuous deployment
  • πŸ›‘οΈ Security First: Private subnets, security groups, and IAM roles following AWS best practices
  • πŸ“ˆ Auto Scaling: Managed node groups with automatic scaling capabilities
  • πŸ’° Cost Optimized: t3.small instances with efficient resource allocation

πŸ›οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                        AWS Cloud                             β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚                VPC (172.20.0.0/16)                     β”‚  β”‚
β”‚  β”‚                                                        β”‚  β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚  β”‚
β”‚  β”‚  β”‚ Public Subnetβ”‚  β”‚ Public Subnetβ”‚  β”‚ Public Subnetβ”‚  β”‚  β”‚
β”‚  β”‚  β”‚   AZ-1       β”‚  β”‚   AZ-2       β”‚  β”‚   AZ-3       β”‚  β”‚  β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚  β”‚
β”‚  β”‚         β”‚                  β”‚                  β”‚        β”‚  β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚  β”‚
β”‚  β”‚  β”‚Private Subnetβ”‚  β”‚Private Subnetβ”‚  β”‚Private Subnetβ”‚  β”‚  β”‚
β”‚  β”‚  β”‚   EKS Nodes  β”‚  β”‚   EKS Nodes  β”‚  β”‚   EKS Nodes  β”‚  β”‚  β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚  β”‚
β”‚  β”‚                                                        β”‚  β”‚
β”‚  β”‚              EKS Control Plane                         β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

✨ Features

Infrastructure Features

  • 🌐 Multi-AZ VPC: High availability across 3 availability zones
  • πŸ”’ Private EKS Nodes: Worker nodes deployed in private subnets for enhanced security
  • πŸšͺ NAT Gateway: Single NAT gateway for cost optimization
  • πŸ“Š Auto Scaling: Managed node groups with configurable scaling policies
  • 🏷️ Resource Tagging: Comprehensive tagging strategy for resource management

DevOps Features

  • πŸ”„ GitOps Workflow: Infrastructure changes triggered by Git commits
  • βœ… Automated Testing: Terraform validation, formatting, and planning
  • πŸš€ Zero-Downtime Deployment: Automated apply on main branch
  • πŸ“¦ State Management: Remote state storage in S3 with locking
  • πŸŽ›οΈ Environment Separation: Support for multiple environments (main/stage)

πŸ› οΈ Prerequisites

  • AWS Account with appropriate permissions
  • Terraform >= 1.6.6
  • AWS CLI configured
  • kubectl for cluster management
  • GitHub repository with secrets configured

Required AWS Permissions

  • EKS cluster creation and management
  • VPC and networking resources
  • IAM roles and policies
  • EC2 instances and security groups

πŸš€ Quick Start

1. Clone the Repository

git clone https://github.com/Flack74/IAC-Vpro.git
cd IAC-Vpro

2. Configure GitHub Secrets

Set up the following secrets in your GitHub repository:

  • AWS_ACCESS_KEY_ID
  • AWS_SECRET_ACCESS_KEY
  • BUCKET_TF_STATE (S3 bucket for Terraform state)

3. Customize Variables

Edit terraform/variables.tf to match your requirements:

variable "region" {
  default = "us-east-1"  # Change to your preferred region
}

variable "clusterName" {
  default = "vprofile-eks74"  # Customize cluster name
}

4. Deploy Infrastructure

Push changes to the main branch to trigger automatic deployment:

git add .
git commit -m "Deploy EKS infrastructure"
git push origin main

πŸ—οΈ Infrastructure Components

VPC Configuration

  • CIDR Block: 172.20.0.0/16
  • Public Subnets: 3 subnets across different AZs
  • Private Subnets: 3 subnets for EKS worker nodes
  • Internet Gateway: For public subnet internet access
  • NAT Gateway: Single gateway for cost optimization

EKS Cluster

  • Kubernetes Version: 1.27
  • Node Groups: 2 managed node groups
    • Group 1: 1-3 t3.small instances (desired: 2)
    • Group 2: 1-2 t3.small instances (desired: 1)
  • AMI Type: Amazon Linux 2 (AL2_x86_64)

Security Features

  • Private subnets for worker nodes
  • Security groups with least privilege access
  • IAM roles following AWS best practices
  • Cluster endpoint accessible from public internet (configurable)

πŸ”„ CI/CD Pipeline

The GitHub Actions workflow (terraform.yml) provides:

Trigger Conditions

  • Push to main or stage branches
  • Pull Request to main branch
  • Path filtering: Only triggers on terraform/** changes

Pipeline Stages

  1. πŸ” Code Checkout: Retrieves latest code
  2. βš™οΈ Terraform Setup: Installs Terraform CLI
  3. πŸ”§ Initialize: Configures backend and providers
  4. πŸ“ Format Check: Ensures code formatting standards
  5. βœ… Validation: Validates Terraform configuration
  6. πŸ“‹ Planning: Creates execution plan
  7. πŸš€ Apply: Deploys infrastructure (main branch only)
  8. πŸŽ›οΈ Kubectl Config: Configures cluster access
  9. 🌐 Ingress Setup: Installs NGINX ingress controller

βš™οΈ Configuration

Environment Variables

AWS_REGION: us-east-1
EKS_CLUSTER: vprofile-eks74
BUCKET_TF_STATE: vprofileactions74

Terraform Backend

backend "s3" {
  bucket = "vprofileactions74"
  key    = "terraform.tfstate"
  region = "us-east-1"
}

Customization Options

  • Instance Types: Modify in eks-cluster.tf
  • Scaling Policies: Adjust min/max/desired sizes
  • Network CIDR: Update VPC and subnet ranges
  • Kubernetes Version: Change cluster version

πŸ›‘οΈ Monitoring & Security

Security Best Practices Implemented

  • βœ… Private subnets for worker nodes
  • βœ… IAM roles with minimal required permissions
  • βœ… Security groups with restricted access
  • βœ… Encrypted communication between components
  • βœ… Regular security updates through managed node groups

Monitoring Capabilities

  • CloudWatch integration for cluster metrics
  • EKS control plane logging
  • Node group health monitoring
  • Resource utilization tracking

πŸ’° Cost Optimization

Implemented Strategies

  • Single NAT Gateway: Reduces NAT gateway costs
  • t3.small Instances: Cost-effective compute resources
  • Auto Scaling: Scales down during low usage
  • Spot Instances: Can be configured for additional savings
  • Resource Tagging: Enables cost allocation and tracking

Estimated Monthly Cost

  • EKS Control Plane: ~$73/month
  • Worker Nodes: ~$30-60/month (depending on usage)
  • Networking: ~$45/month (NAT Gateway)
  • Total: ~$150-180/month

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™‹β€β™‚οΈ Support

For questions or support, please open an issue in the GitHub repository.


Built with ❀️ using Terraform, AWS EKS, and GitHub Actions

This project demonstrates production-ready Infrastructure as Code practices suitable for enterprise environments.

About

Scalable EKS Infrastructure as Code with Terraform and GitHub Actions for automated CI/CD on AWS. Designed for production-ready, cost-optimized, and secure Kubernetes deployments.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages