Project · Infrastructure as Code

DevOps Bootcamp Project

Final project — Infrastructure as Code (IaC) with Terraform, Ansible & Docker

Terraform Ansible Docker GitHub Actions

Overview

Final project for the DevOps bootcamp. It sets up cloud infrastructure using Infrastructure as Code (IaC):

Architecture

Project Structure

.
├── .github/workflows/  # GitHub Actions CI/CD pipeline
├── terraform/          # AWS infrastructure (VPC, EC2, security groups, inventory)
├── ansible/            # Server setup (playbooks, templates, docker compose)
├── app/                # Web app (front-end "ship")
└── opencode.json       # opencode config (terraform MCP)

Terraform — Create the Infrastructure

FilePurpose
providers.tfAWS provider, S3 backend
network.tfVPC, public/private subnets, NAT gateway
security.tfSecurity groups (HTTP 80, SSH 22, exporters, Prometheus, Grafana)
ec2.tf3 EC2 instances (ubuntu AMI, SSM role, user_data)
inventory.tfGenerates inventory.ini for Ansible
userdata.shInstalls Docker + adds user to docker group
userdata-tunnel.shInstalls Docker + runs Cloudflare Tunnel (node1)

How to run

cd terraform
terraform init
terraform apply -auto-approve

Ansible — Configure the Servers

PlaybookHostPurpose
playbook-web.yamlnode3Runs nginx in Docker
playbook-stack.yamlnode1Runs Prometheus + Grafana via Docker Compose
playbook-prometheus.yamlnode1Installs Prometheus
playbook-exporter.yamlnodesInstalls node_exporter

How to run

cd ansible
ansible-playbook playbook-web.yaml
ansible-playbook playbook-stack.yaml
ansible-playbook playbook-exporter.yaml

Application (app/)

The ship web app is a front-end built with Vite. The index.html content is generated from index.html.j2 during web deployment.

Prerequisites

Deploy Flow

  1. Terraform: terraform apply — creates the VPC, security groups, 3 EC2 instances, and generates inventory.ini
  2. Ansible: run the playbooks you need (web or monitoring)
  3. Access: node3 via public IP; node1/node2 via SSM

CI/CD (GitHub Actions)

A minimal commit pipeline in .github/workflows/commit-pipeline.yml runs on every push to main:

StepCommand
Install dependenciesnpm ci
Preflight testnpm test
Unit testsnpm run test:unit
Buildnpm run build

Notes

Architecture Diagram

To update this diagram later, just replace img/architecture-diagram.png with your own .png or .jpg — keep the same filename, or edit the src below.

DevOps Bootcamp Project architecture diagram

View the repository on GitHub