Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ DevOps Rescue Lab

End-to-end DevOps project demonstrating infrastructure provisioning, configuration management, and application deployment.

Terraform Ansible AWS Nginx Ubuntu


πŸ“‘ Table of Contents


πŸ“Œ Workflow

flowchart LR
    A[πŸ—οΈ Provision Infrastructure<br/>Terraform] --> B[βš™οΈ Configure Server<br/>Ansible]
    B --> C[🌐 Deploy Application<br/>Nginx]
    C --> D[πŸ–₯️ Access via Browser]
    D --> E[🧹 Destroy Resources]
Loading

πŸ“Έ Architecture

flowchart TD
    U((πŸ‘€ User)) --> I[🌍 Internet]
    I --> IGW[Internet Gateway]

    subgraph VPC["VPC β€” 10.0.0.0/16"]
        IGW --> RT[Route Table]
        RT --> SUB[Public Subnet]
        SUB --> SG[Security Group<br/>Firewall Rules]
        SG --> EC2[EC2 Instance<br/>Ubuntu + Nginx]
    end
Loading

🧰 Tech Stack

Category Tools
☁️ Cloud AWS (EC2, VPC, Subnets, IGW, Security Groups)
πŸ—οΈ Infrastructure as Code Terraform
βš™οΈ Configuration Management Ansible
πŸ–₯️ OS Ubuntu Server 22.04
🌐 Web Server Nginx
πŸ”§ Version Control Git + GitHub

πŸ“Έ Screenshots

Add screenshots to the /screenshots folder and link them below.

Step Description
terraform apply Infrastructure creation success
AWS EC2 Console Running instance
Ansible Run Nginx installation success
Browser Output Nginx landing page

βš™οΈ Terraform Workflow

# Initialize the working directory
terraform init

# Validate the configuration
terraform validate

# Preview the execution plan
terraform plan

# Apply the changes
terraform apply

πŸ—οΈ What Terraform Creates

  • βœ… VPC (10.0.0.0/16)
  • βœ… Public & Private Subnets
  • βœ… Internet Gateway
  • βœ… Route Table
  • βœ… Security Group (HTTP, HTTPS, SSH)
  • βœ… EC2 Instance (Ubuntu)

🌐 Networking Basics

Concept Description
VPC Isolated network inside AWS
Subnet Defines resource placement (public/private)
Internet Gateway Allows internet access
Route Table Controls traffic flow

πŸ” Security Group Rules

Port Protocol Purpose
22 SSH Remote access
80 HTTP Web traffic
443 HTTPS Secure traffic

βš™οΈ Ansible Deployment

# Test connection
ansible -i inventory.ini web -m ping

# Install Nginx
ansible-playbook -i inventory.ini install-nginx.yml

🧠 What Ansible Does

  • Connects via SSH
  • Installs Nginx
  • Starts the service
  • Ensures idempotency

🌍 Final Output

http://<EC2_PUBLIC_IP>

Nginx web server is now live πŸŽ‰


🧹 Cleanup (IMPORTANT)

terraform destroy

Removes:

  • EC2 instance
  • VPC
  • Subnets
  • Security groups
  • Internet Gateway

πŸ’‘ Always destroy resources after testing to avoid unnecessary AWS charges.


❓ FAQ (Interview Style)

☁️ AWS & Infrastructure Basics

What is EC2?
EC2 (Elastic Compute Cloud) is a virtual server in AWS used to run applications β€” just like a physical computer, but hosted in the cloud.
What is a VPC?
A Virtual Private Cloud (VPC) is an isolated network in AWS where all resources (EC2, subnets, gateways) live.
What is a subnet, and why does EC2 need one?
A subnet defines the network location of an instance inside a VPC, and determines whether it's public or private. EC2 needs a subnet so AWS knows where to place it on the network.
What is an Internet Gateway?
It allows communication between resources inside a VPC and the internet.
What is a Route Table?
It controls traffic flow inside a VPC and decides where network traffic should go.
What's the difference between an AMI and an Instance Type?
  • AMI (Amazon Machine Image) β€” the template used to launch an EC2 instance (the operating system image)
  • Instance Type β€” defines the hardware resources, like CPU, RAM, and performance level
What is a Key Pair, and why is it needed?
A Key Pair is a private/public key used for SSH authentication into EC2, allowing you to securely log in without a password.

πŸ” Security Groups & Networking

What is a Security Group?
A virtual firewall that controls inbound and outbound traffic to an instance.
Why do we still need a Security Group if we already have a VPC and Subnet?

Each layer plays a different role:

  • VPC β†’ network boundary
  • Subnet β†’ placement zone
  • Security Group β†’ traffic control (who can enter, on which port)

The Security Group is the final access layer before the instance.

What are ports 22, 80, and 443 used for?
  • 22 (SSH) β€” remote access to manage the server securely
  • 80 (HTTP) β€” normal web browsing traffic
  • 443 (HTTPS) β€” encrypted, secure web traffic
Why is outbound traffic usually left open?

Because servers need to:

  • download updates
  • install packages
  • access external APIs

βš™οΈ Terraform Concepts

What is Terraform, and why use it over manual AWS setup?

Terraform is a tool for defining and managing infrastructure as code. Compared to manual setup, it provides:

  • repeatability
  • automation
  • version control
  • consistency across environments
Why is Terraform syntax split into many blocks?

Because Terraform is declarative β€” each block represents one resource, each resource is managed independently, and dependencies are resolved automatically.

Why did terraform init take time or sometimes hang?

Usually due to provider plugin downloads (the AWS SDK for Terraform), slow network latency, or a first-time plugin install.

Why do we add .terraform/ to .gitignore?

Because it contains downloaded provider plugins and large cached binaries (sometimes hundreds of MB) that GitHub will reject and that should never be committed.

Why did terraform destroy fail initially, or show "no credentials found"?

Typically because the provider plugins weren't initialized yet, or because AWS credentials weren't configured in the environment or CLI.

πŸ§ͺ EC2 & Deployment

Why did EC2 creation fail before, and succeed later?

Usually a combination of: missing credentials/config, the AWS provider not being fully initialized, or incomplete networking/security rules.

Why does EC2 need both a subnet and a security group?

The subnet determines the network location, while the security group determines the traffic rules. Both are required for correct networking and access control.

βš™οΈ Ansible Concepts

What is Ansible, and what does it do in this project?

Ansible is a configuration management tool used to automate server setup. In this project it connects to EC2 over SSH, installs Nginx, and starts the service.

What does ansible ... -m ping do?

It tests SSH connectivity to a remote host.

Why did SSH initially fail, and why did it work after a retry?

The first failure was usually a host key verification mismatch. It succeeded afterward once the SSH fingerprint was accepted and stored.

🧠 Debugging Notes

Why did the AWS CLI install fail in Codespaces?

Because the awscli package name/version differs in the default Ubuntu repository.

Why did git push fail with a large file error?

Because a Terraform provider binary (~800MB) was accidentally tracked by Git instead of being ignored.

🧹 Cost & Cleanup

Why do we run terraform destroy, and what does it remove?

Running it prevents AWS from billing for unused resources. It removes the EC2 instance, VPC, subnets, security groups, route tables, and the Internet Gateway.

πŸš€ DevOps Concepts

What is Infrastructure as Code?
Managing infrastructure using code instead of manual setup.
What is Configuration Management?
Automating software installation and server setup.
What's the full DevOps flow in this project?
Terraform β†’ AWS Infrastructure
Ansible   β†’ Server Configuration
Nginx     β†’ Application Layer
Browser   β†’ Validation
Destroy   β†’ Cost Control

πŸ‘€ Author

Nkechi Anna Ahanonye DevOps Engineer | Cloud & Automation

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages