Deploy your first compute instance
12 min tutorial
What you'll build
By the end of this tutorial you'll have a Compute Instance running in your account, reachable over SSH and over HTTP, ready to host a real application.
Prerequisites
- A SonicInfra account with billing enabled.
- An SSH key pair on your local machine.
- The
sonicCLI installed.
Open Compute Instances
Click Compute Instances in the sidebar.
Create a new instance
Click + Create Compute Instance.
Fill out the instance details
Fill in the fields:
- Instance Type — CPU and memory size, as
{family}.{cores}(4Gi RAM per core). Pickne.2for this tutorial. - Image — the OS image to use for the root disk. Pick
ubuntu-24-04.
Add an SSH key
Under SSH Authorized Keys, click + Add.
Choose the key
Click the field and pick an existing key from the list.
Don't have one yet? Click + Create SSH Key at the bottom of the list to add one without leaving this page — it opens the same form as this standalone guide, if you'd rather follow it on its own:
Create an SSH keyBefore you create it
Compute instances are a paid resource — your organization needs billing set up before you can create one.
Haven't set up billing yet? Here's how to add a payment method first.
Create the instance
- Web
- CLI
- Terraform
Click Create Compute Instance.
instanceType—ne.2— 2 cores, 8Gi RAM. Sized for this tutorial; pick a larger type for a real workload.cloudInit.ssh_authorized_keys— The key you picked in the previous step. SonicInfra injects it into the instance at boot, which is what makessonic sshwork in the next step with no extra setup.
sonic instances create web-01 \
--instanceType ne.2 \
--image dWJ1bnR1LTI0LTA0 \
--cloudInit.ssh_authorized_keys "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDemoOnlyDoNotUseThisKeyGkPZ user@example.com"
# Generated by SonicInfra
# Review before applying — some fields may need adjustment
# (e.g. cloud_init requires a YAML string in the Terraform provider)
resource "sonicinfra_compute_instance" "web_01" {
name = "web-01"
instance_type = "ne.2"
image = "ubuntu-24-04"
cloud_init {
ssh_authorized_keys = ["ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDemoOnlyDoNotUseThisKeyGkPZ user@example.com"]
}
}
Connect over SSH
If you added an SSH key in the previous step, connect directly. sonic tunnels the connection through our gateway, so there's no public IP to look up:
sonic ssh web-01
Didn't add a key yet? Attach one after the fact instead:
sonic ssh-copy-id web-01
sonic ssh web-01
Run sonic setup-ssh once, then you can run this instead:
ssh web-01.sonicinfra
Install your app
Install a runtime and pull your application code. This example uses Node.js:
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo bash -
sudo apt-get install -y nodejs git
git clone https://github.com/you/your-app.git
cd your-app && npm ci && npm run build
Use a process manager like systemd or pm2 so your app restarts on reboot or crash.
Open L7 Load Balancers
Instances don't have public IPs directly — create an L7 load balancer to route a domain to your app over HTTP/HTTPS. Click L7 Load Balancers in the sidebar.
Create a new load balancer
Click + Create L7 Load Balancer.
Expose it to the internet
- Web
- CLI
- Terraform
Fill in the fields, then click Create L7 Load Balancer:
- Instance Name — the compute instance to expose. Pick
web-01. - Port — the port your app listens on. Use
3000for this tutorial's Node.js example. - URLs — the domain (and optional path) to route to it. Use a domain you actually control, e.g.
app.example.com.
sonic networking-l7-load-balancers create web-l7-lb \
--instanceName web-01 \
--port 3000 \
--urls '{"host":"app.example.com","path":"/"}'
# Generated by SonicInfra
# Review before applying — some fields may need adjustment
# (e.g. cloud_init requires a YAML string in the Terraform provider)
resource "sonicinfra_l7_load_balancer" "web_l7_lb" {
name = "web-l7-lb"
instance_name = "web-01"
port = 3000
urls {
host = "app.example.com"
path = "/"
}
}
Point your domain
Its row is highlighted below — click it to open the details panel.
Find the address to point to
Find the assigned address under External IP, use that to add an A record to your domain registrar. This happens outside SonicInfra, so come back here once it's done.