> For the complete documentation index, see [llms.txt](https://stakpak.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://stakpak.gitbook.io/docs/how-it-works/rulebooks/simple-deployment-on-vm.md).

# Simple Deployment On VM

## Introduction

This rulebook defines a simple but secure methodology for deploying applications on virtual machines, ensuring reliable, production-ready environments through:

* Following clear core principles to minimize risk and avoid disruptions
* Using CLI tools and environment variables for consistent automation
* Securing access with SSH keys and safe credential handling
* Ensuring proper infrastructure, networking, and database configurations
* Verifying deployments with thorough quality assurance checks

## Goal

### Why did we make this rule book?

* To avoid insecure, inconsistent, or incomplete VM-based deployments.
* To prevent operational disruptions by protecting existing cloud resources.
* To create a clear, CLI-driven deployment process for repeatable results.

### What will you achieve?

* Secure, production-ready VM deployments.
* Consistent infrastructure, networking, and database configurations.
* Documented access credentials and verified application functionality.

### Who is this for?

Anyone responsible for deploying applications on virtual machines who needs a simple, secure, and repeatable process that works across environments.

## Workflow

This process ensures applications are deployed on virtual machines securely and efficiently without disrupting existing resources.

1. Follow core principles: Avoid assumptions, use only CLI tools, and never delete existing resources.
2. Provision virtual machines: Prefer VMs over PaaS, place them in public subnets with public IPs, enable SSH access, and size them with the required CPU/memory.
3. Configure networking: Set up domains and DNS records, configure TLS/HTTPS (Let’s Encrypt by default), ensure required ports are open, and apply provider-specific networking settings (e.g., AWS VPC DNS, Cloudflare proxy mode).
4. Set up database (if needed): Choose the correct type/version, prefer managed services, configure environment variables, generate secure passwords, and store them safely.
5. Perform quality assurance: Wait for resources to be ready, check application logs, perform HTTP 200 health checks, and confirm production readiness.
6. Get user confirmation: Confirm domain, TLS, and database preferences before executing the deployment.
7. Finalize & document: Verify all success criteria are met and document credentials, endpoints, and configuration details.

## Use Cases

### Deploying a New Application

Launch a secure, production-ready application on virtual machines.

### **Migrating Applications**&#x20;

Move an application to new virtual machines with minimal downtime.

### **Setting Up a Staging Environment**

Create a secure staging VM environment for pre-production testing.

### **Redeploying After Updates**

Deploy the updated version of an application while preserving access and configurations.

## References

* [Let’s Encrypt Documentation](https://letsencrypt.org/docs/)
* [AWS VPC DNS Documentation](https://docs.aws.amazon.com/vpc/latest/userguide/vpc-dns.html)
* [Cloudflare Proxy Mode Guide](https://developers.cloudflare.com/dns/proxy-status/)
* [OpenSSL Command Reference](https://docs.openssl.org/master/)
