This repository contains the Infrastructure as Code (IaC) and automation logic for a highly secure, self-healing, zero-ingress cloud architecture.
Unlike traditional "ClickOps" setups, this entire environment—from VPC networking and firewall rules to the compute node and its internal GitOps pipeline—is defined in code, ensuring idempotent deployments and instant disaster recovery.
[Public Internet]
│ (Strict HTTPS / DNSSEC / HSTS)
▼
[Cloudflare Edge / WAF] ─── (Blocks AI Scrapers & Botnets)
│
│ (Encrypted Outbound Egress Tunnel)
▼
[GCP VPC Firewall] ─── (ALL Inbound Ingress Rules DROPPED)
│
[GCP e2-micro Node] ◀─── [Terraform Provisioned] ◀─── [GCS Remote State]
│
├─ [cloudflared daemon] ── (Bridges Tunnel to Localhost:80)
├─ [systemd.timer] ─── (Polls GitHub Native every 2 mins)
└─ [Docker Engine] ─── (Runs hardened nginx:alpine)
The environment is provisioned using Terraform. To enable cross-platform collaboration (e.g., switching between Windows and Linux development machines), I implemented a Remote Backend using Google Cloud Storage (GCS) with object versioning. This prevents state loss and ensures architectural consistency.
The origin server is 100% invisible to the public internet. By utilizing Cloudflare Zero Trust Tunnels, the GCP VPC firewall is configured to drop all inbound TCP traffic. Reconnaissance tools like Shodan or automated port scanners see no open ports, mitigating direct-to-IP DDoS and brute-force vectors.
Running heavy CI/CD runners (Jenkins/GitHub Actions) on a 1GB RAM micro-instance is inefficient. I engineered a Native GitOps poller using Linux systemd and bash. It uses git ls-remote to detect SHA deltas with minimal CPU/RAM overhead, triggering automated Docker rebuilds only when changes are merged.
To remediate upstream vulnerabilities in the nginx:alpine base image, the build process injects an automated OS-level package patch (apk upgrade) during the containerization phase.
main.tf: Terraform configuration for VPC, Firewalls, and Compute.main.html: The frontend portfolio case study.Dockerfile: Nginx-Alpine configuration with integrated security patching.deploy.sh: The core CD logic. Uses native Git to poll SHAs and manage Docker lifecycles.setup.sh: Provisioning script that bootstraps the native Systemd GitOps timer.
- State Check: Queries the remote origin natively via
git ls-remote(using a secure PAT). - Evaluation: Compares remote SHA against
git rev-parse HEAD. - Synchronization: Executes a
git reset --hardif a delta is detected. - Hardened Build: Rebuilds the Docker image with fresh OS patches (
--no-cache). - Orchestration: Seamlessly swaps the container bound to
localhost:80.
Requires Terraform CLI and an authenticated GCP project.
# 1. Initialize and connect to Remote GCS State
terraform init
# 2. Review the plan
terraform plan
# 3. Provision the entire stack
terraform applyArchitected and maintained by Sreeram K R. finished architecting my Zero-Trust GitOps environment on GCP via Terraform. Live case study here: sreeramkr.com