End-to-end DevOps project demonstrating infrastructure provisioning, configuration management, and application deployment.
- Workflow
- Architecture
- Tech Stack
- Screenshots
- Terraform Workflow
- What Terraform Creates
- Networking Basics
- Security Group Rules
- Ansible Deployment
- Final Output
- Cleanup
- FAQ
- Author
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]
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
| 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 |
Add screenshots to the
/screenshotsfolder 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 |
# Initialize the working directory
terraform init
# Validate the configuration
terraform validate
# Preview the execution plan
terraform plan
# Apply the changes
terraform apply- β
VPC (
10.0.0.0/16) - β Public & Private Subnets
- β Internet Gateway
- β Route Table
- β Security Group (HTTP, HTTPS, SSH)
- β EC2 Instance (Ubuntu)
| Concept | Description |
|---|---|
| VPC | Isolated network inside AWS |
| Subnet | Defines resource placement (public/private) |
| Internet Gateway | Allows internet access |
| Route Table | Controls traffic flow |
| Port | Protocol | Purpose |
|---|---|---|
| 22 | SSH | Remote access |
| 80 | HTTP | Web traffic |
| 443 | HTTPS | Secure traffic |
# Test connection
ansible -i inventory.ini web -m ping
# Install Nginx
ansible-playbook -i inventory.ini install-nginx.yml- Connects via SSH
- Installs Nginx
- Starts the service
- Ensures idempotency
http://<EC2_PUBLIC_IP>
Nginx web server is now live π
terraform destroyRemoves:
- EC2 instance
- VPC
- Subnets
- Security groups
- Internet Gateway
π‘ Always destroy resources after testing to avoid unnecessary AWS charges.
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.
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
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.
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.
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.
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.
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.
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
Nkechi Anna Ahanonye DevOps Engineer | Cloud & Automation