Back to projects
AWSEC2VPCBashInfrastructure

Automated Web Server Deployment on AWS

Automated infrastructure setup for deploying web servers on AWS EC2 with secure VPC architecture and scalable configuration.

Problem

Manual AWS infrastructure setup is error-prone, inconsistent, and not reproducible. Developers often click through the console to set up VPCs, subnets, security groups, and EC2 instances — producing environments that can't be reliably recreated or version-controlled.

Solution

Scripted the complete infrastructure provisioning using the AWS CLI and Bash, creating a fully automated, repeatable deployment pipeline:

  • VPC creation with public/private subnet segmentation
  • Internet Gateway and route table configuration
  • Security group rules following least-privilege principle
  • EC2 launch with user-data scripts for nginx/app setup
  • Bastion host configuration for secure SSH access
  • Optional Auto Scaling Group integration

Architecture


# AWS Web Server Deployment Architecture

┌──────────────────────────────────────────────────┐
│                    VPC (10.0.0.0/16)             │
│                                                  │
│  ┌────────────────┐    ┌─────────────────────┐  │
│  │  Public Subnet │    │  Private Subnet     │  │
│  │  10.0.1.0/24  │    │  10.0.2.0/24        │  │
│  │                │    │                     │  │
│  │  Internet GW  │    │  App Servers        │  │
│  │  Bastion Host │    │  RDS (optional)     │  │
│  │  Load Balancer│    │                     │  │
│  └───────┬────────┘    └──────────┬──────────┘  │
│          │                        │              │
│          └────────────────────────┘              │
└──────────────────────────────────────────────────┘
            │
            ▼
  ┌─────────────────┐
  │  Security Groups │
  │                 │
  │  SSH: 22 (Bastion only)
  │  HTTP: 80 (ALB)
  │  HTTPS: 443 (ALB)
  │  App: 8080 (internal)
  └─────────────────┘
            │
            ▼
  ┌─────────────────┐
  │  EC2 Instances  │
  │                 │
  │  User Data script → nginx install
  │  Auto-configure → app deploy
  └─────────────────┘

Tech Stack

AWS CLI

Infrastructure provisioning

EC2

Compute instances

VPC

Network isolation

Bash

Automation scripts

nginx

Web server

IAM

Roles & permissions

Challenges

Idempotency

Scripts needed to be safe to re-run. Implemented checks for existing resources before creation to avoid duplicates.

Security Group Ordering

AWS security groups have dependency constraints. Solved by ordering creation and using references rather than hardcoded IDs.

User Data Debugging

EC2 user-data scripts fail silently. Integrated CloudWatch log streaming for bootstrap script output.

View on GitHub