# Deploy Trino with the trino template

Source: https://docs.quake.ai/resources/deployments/deploy-trino-template
Markdown: https://docs.quake.ai/resources/deployments/deploy-trino-template.md

---

# Deploy Trino with the trino template

Stand up [Trino](https://trino.io), an open-source federated SQL query engine, on a single Quake AI instance using the [validated OpenTofu template](/docs/platform/validation#how-infrastructure-templates-are-checked) `trino`. You apply the template, run a smoke-test query against the built-in sample catalog, and wire in a Postgres warehouse when you have one.

Trino is the query layer over your lakehouse stack. You run it yourself; this is a self-hosted tool you operate, not a hosted query service.

<PricingCompanion
  components={[
    { kind: "template", slug: "trino", required: true },
  ]}
/>

## Prerequisites

You need OpenTofu 1.6.0 or later, OpenStack credentials sourced into the shell, an SSH keypair in your project, a copy of the `trino` template from [the template reference page](/resources/iac-templates/trino), and your workstation public IP for first-boot UI access.

## Step 1: Apply the template

Copy `terraform.tfvars.example` to `terraform.tfvars`, set `key_name` and `ui_allowed_cidr = "YOUR_IP/32"`, then run:

```bash
tofu init
tofu plan
tofu apply
```

Record `floating_ip` and `ui_url` from `tofu output`.

## Step 2: Run a smoke-test query

Open `ui_url` in your browser. When the Trino UI loads, run:

```sql
SELECT nationkey, name
FROM tpch.tiny.nation
ORDER BY nationkey
LIMIT 5;
```

Trino returns five rows from the built-in `tpch` sample catalog.

## Step 3: Wire in a Postgres catalog (optional)

SSH to the instance and create `/opt/trino/catalog/postgres.properties` with your warehouse connection, including `connection-password`. Restart the stack:

```bash
cd /opt/trino
sudo docker compose restart
```

See the [Trino template reference](/resources/iac-templates/trino) for ClickHouse and Iceberg catalog shapes.

## Clean up

```bash
tofu destroy
```

## Next steps

- [Trino template](/resources/iac-templates/trino)
- [Deploy self-managed PostgreSQL](/resources/deployments/deploy-self-managed-postgres-template)
