---
title: "Deploy a web server"
sidebarTitle: "Deploy a web server"
description: "Provision a compute instance with Terraform, then install Nginx and serve a page — end to end."
---
A complete walkthrough: define a compute instance in Terraform, apply it, connect over SSH, and serve a web page with Nginx.
New to the provider? Run through the [Quickstart](/terraform/quickstart) and [Authentication](/terraform/authentication) first — this guide assumes Terraform is installed and `STRETTCH_CLOUD_API_KEY` is set.
## What you'll build
- A compute instance with a public IP
- SSH access with your own key
- Nginx serving a page over HTTP
Create a new directory with three files:
```hcl main.tf
terraform {
required_providers {
strettchcloud = {
source = "strettch-cloud/strettchcloud"
version = "~> 1.0"
}
}
}
provider "strettchcloud" {
# api_key is read from STRETTCH_CLOUD_API_KEY
}
resource "strettchcloud_compute" "web" {
host_name = "web-01"
image = "UBUNTU-24.04"
region = "KGL-1"
specification = "S-1C-1G"
public_keys = [var.ssh_public_key]
with_public_ip = true
tags = ["web", "demo"]
}
```
```hcl variables.tf
variable "ssh_public_key" {
description = "Your SSH public key (contents of e.g. ~/.ssh/id_ed25519.pub)."
type = string
}
```
```hcl outputs.tf
output "public_ip" {
value = strettchcloud_compute.web.ipv4
}
```
Set your API key and keep your SSH public key handy:
```bash
export STRETTCH_CLOUD_API_KEY=""
```
Don't have an SSH key yet? Generate one with `ssh-keygen`, then your public key is at `~/.ssh/id_ed25519.pub`. See [SSH Keys](/services/compute/ssh-keys) for the full walkthrough.
Download the provider and create the instance, passing your public key in:
```bash
terraform init
terraform apply -var="ssh_public_key=$(cat ~/.ssh/id_ed25519.pub)"
```
Review the plan, type `yes`, and Terraform prints the `public_ip` when the instance is up.
Strettch Cloud exposes SSH on port **222**. Connect as `root`:
```bash
ssh root@$(terraform output -raw public_ip) -p 222
```
On the instance, install and start Nginx:
```bash
apt update && apt install -y nginx
```
Replace the default page with your own:
```bash
echo "Hello from Strettch Cloud 🚀
" > /var/www/html/index.html
```
Open `http://` in a browser — you'll see your page. Your web server is live, defined entirely in Terraform.
When you're finished, destroy everything you created:
```bash
terraform destroy -var="ssh_public_key=$(cat ~/.ssh/id_ed25519.pub)"
```
---
## Make it repeatable
Because the whole server is now described in code, you can:
- **Version it** — commit `main.tf`, `variables.tf`, and `outputs.tf` to Git.
- **Review changes** — run `terraform plan` before every change to see exactly what will happen.
- **Reproduce it** — apply the same files to stand up an identical instance any time, or for a second environment.
Avoid hardcoding `image`, `region`, or `specification`. Look them up as data sources instead — see [Look up catalog values](/terraform/quickstart#look-up-catalog-values) in the Quickstart.
---
## Next steps
The full catalog of what the provider can manage.
Every argument and attribute on the Terraform Registry.