The Multi-Cloud Infrastructure Cloner is a production-grade IaC system designed for high-availability and disaster recovery. It allows for the instantaneous recreation of a full production environment across multiple VPS providers (AWS, Hetzner, Contabo) with a single command.
- Provider Abstraction: Interchangeable compute modules with a unified variable schema.
- Secure-by-Default: Automated cloud-init hardening, SSH-only access, and Fail2ban integration.
- Atomic Restoration: Custom backup engine to capture and redeploy Docker volumes and service states.
- Zero-Leak Design: Strict credential isolation and environment-specific configurations.
graph TD
User([Platform Engineer]) -->|terraform apply| Hub{TF Provider Selector}
Hub -->|target_provider=aws| AWS[AWS EC2]
Hub -->|target_provider=hetzner| HZ[Hetzner Cloud]
Hub -->|target_provider=contabo| CON[Contabo VPS]
subgraph "Secure Bootstrap"
AWS & HZ & CON --> CI[Cloud-Init Engine]
CI --> UserM[Non-root User]
CI --> Hard[Sec Hardening / Firewall]
CI --> Docker[Docker Runtime]
end
subgraph "Recovery Pipeline"
Docker --> Restore[Restore Script]
Backup[(External Backup)] --> Restore
Restore --> Apps[Running Containers]
Apps --> Vol[(Persistent Volumes)]
end
- HashiCorp Terraform 1.5+
- Cloud provider API credentials
- SSH Key Pair
Clone the .env.example and fill in your secrets:
cp .env.example .env
source .envcd infra/terraform/environments/prod
terraform init
terraform apply -var="target_provider=hetzner" -var="ssh_public_key=$(cat ~/.ssh/id_rsa.pub)"- Identity: No root login. All operations performed via
sudousers. - Network: Minimal exposure. UFW configured for SSH, HTTP, and HTTPS only.
- Runtime: Docker containers run with resource limits and restart policies.
- Secrets: Encrypted variable injection via Terraform environment variables.
Important
For a deep dive into our hardening process and zero-leak strategy, see the Full Security Architecture.
Run on the running server to export state:
./backup/scripts/capture.shRun on the newly provisioned server:
./backup/scripts/restore.sh infra-export-YYYYMMDD.tar.gzBy abaasi256


