How shivik0505/redis_demo works
Project Type & Purpose
• This is an Infrastructure-as-Code (IaC) project that automates deployment of a Redis cluster on AWS.
• Uses Terraform to provision AWS networking and compute resources, Ansible to configure Redis, and Jenkins/CLI scripts for CI/CD.
Key Components to Model
A. AWS Network Layout
– Custom VPC (10.0.0.0/16)
– Public Subnet (10.0.1.0/24) hosting Bastion Host
– Private Subnets (10.0.2.0/24, 10.0.3.0/24, 10.0.4.0/24) each in a different AZ, hosting Redis nodes
– Internet Gateway (IGW) behind the public subnet
– NAT Gateway in the public subnet providing egress for private subnets
– Route Tables for public and private subnets
– VPC Peering connection to an optional remote VPC
B. Compute Instances
– Bastion Host (EC2, public IP)
– Redis Node 1, 2, 3 (EC2 in private subnets)
C. Security
– Security Group for Bastion (SSH/HTTP/ICMP open as per requirements)
– Security Group for Redis cluster (ports 6379, 16379–16384, SSH/ICMP within VPC)
D. IaC & Configuration Automation
– Terraform modules (vpc, subnets, security_group, instances, vpc_peering)
– Terraform root module invoking these and outputting instance IPs
– Ansible playbook & inventory (aws_ec2.yaml) that configures Redis on each node
E. CI/CD & Deployment
– Jenkins Pipeline (Jenkinsfile)
– deploy-infrastructure.sh & cleanup scripts
– aws_ec2.yaml (dynamic inventory)
Component Relationships & Data Flow
• User/CI triggers Terraform:
→ Terraform provisions AWS resources in correct order (VPC → Subnets → Security Groups → IGW/NAT → EC2).
• Terraform outputs IP addresses to stdout/terraform output.
• Ansible uses the AWS inventory file (aws_ec2.yaml) to SSH into Bastion, then onto Redis nodes for software installation and cluster setup.
• Jenkins job checks out the repo, runs deploy-infrastructure.sh (or terraform & ansible commands), monitors status, and can trigger destroy via parameters.
Architectural Patterns & Principles
• “Infrastructure as Code” pattern: All resources defined in Terraform modules, versioned in Git.
• Layered network design: Public bastion separated from private Redis nodes.
• Immutable infrastructure: EC2 instances configured at launch time via Ansible.
• High availability: Redis cluster nodes across three AZs.
Essential Elements Checklist
[ ] Clear labels on all AWS resources (VPC, subnets, EC2).
– Network vs. Compute vs. Automation tools
[ ] AZ markers on each private subnet.
[ ] Text notes for security group rules (port ranges).