Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AWS Ruby Application Infrastructure

Introduction

This project demonstrates enterprise-grade Infrastructure as Code (IaC) for deploying a production-ready Ruby application on AWS. It showcases a well-architected, modular Terraform configuration that provisions a complete cloud infrastructure with high availability, security, and scalability as core design principles.

The infrastructure is designed to support a containerized Ruby application running behind a load balancer, with a managed PostgreSQL database, all within an isolated VPC environment. The configuration follows AWS Well-Architected Framework principles and Terraform best practices to ensure maintainability, reusability, and operational excellence.

Overview

This project provisions a complete AWS infrastructure including:

  • Custom VPC with public subnets and Internet Gateway
  • RDS PostgreSQL database with multi-AZ support
  • Auto Scaling Group with EC2 instances for the Ruby application
  • Application Load Balancer for traffic distribution
  • IAM roles for EC2 with ECR and S3 access
  • Security Groups for network isolation

Architecture

Internet → ALB → EC2 Auto Scaling Group (Ruby App) → RDS PostgreSQL

Modules

  • modules/vpc - VPC, subnets, security groups, and routing
  • modules/ec2 - Launch template, ASG, ALB, and target groups

Best Practices Implemented

1. Modular Architecture

  • Infrastructure split into reusable modules (vpc, ec2) for better organization and maintainability
  • Each module has clear inputs/outputs and handles specific infrastructure concerns
  • Promotes code reusability across different environments

2. Security First

  • IAM Least Privilege: EC2 instances use IAM roles with read-only access to ECR and S3
  • Network Isolation: Resources deployed in custom VPC with security groups controlling traffic
  • Defense in Depth: Multiple security layers (VPC, Security Groups, IAM)
  • Database deployed in private subnets with restricted security group rules

3. High Availability & Resilience

  • Multi-AZ RDS: Database configured with Multi-AZ for automatic failover
  • Auto Scaling Group: Application scales horizontally based on demand
  • Load Balancing: ALB distributes traffic across multiple availability zones
  • EC2 instances deployed across multiple subnets for fault tolerance

4. Infrastructure as Code Principles

  • Parameterization: All configurations externalized via variables in terraform.tfvars
  • DRY Principle: Use of for_each loops to avoid code duplication
  • Data Sources: Leverages data blocks for dynamic policy generation
  • Explicit Dependencies: Clear depends_on declarations for proper resource ordering

5. Automation & DevOps

  • User data scripts automate EC2 configuration (Docker installation)
  • Launch templates ensure consistent instance configuration
  • Infrastructure provisioning is fully automated and repeatable

Notes

  • RDS skip_final_snapshot is enabled for development purposes
  • EC2 instances are configured with Docker via user data script

About

This repository contains Terraform configuration for Ruby Application Deployment in AWS.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages