# Trino federated query engine

Source: https://docs.quake.ai/resources/iac-templates/trino
Markdown: https://docs.quake.ai/resources/iac-templates/trino.md

---

# Trino federated query engine

This [validated OpenTofu template](/docs/platform/validation#how-infrastructure-templates-are-checked) composes Compute, Network, and Block Storage into a self-hosted federated SQL query engine you run on infrastructure you control.

## What this template does

Provisions a single instance running [Trino](https://trino.io), an open-source federated SQL query engine (a self-hosted alternative to Amazon Athena or Starburst):

- Multi-container Docker stack: one coordinator, one or more workers (default one), and catalog configs for Postgres, ClickHouse, and Iceberg
- Default sizing: `m2a.xlarge` (4 vCPU / 16 GiB RAM) and an 80 GiB data volume at `/var/lib/docker` for container layers and query spill
- Private network, security group, floating IP; UI restricted to `ui_allowed_cidr` by default
- Built-in `tpch` and `tpcds` sample catalogs for smoke tests after first boot

Trino federates SQL across the data sources you wire in. Point `postgres_host`, `clickhouse_host`, and the Iceberg REST/S3 settings at your warehouse, ClickHouse, and lakehouse stacks, then add credentials in the catalog files on the instance. No credential ships with this template.

## Parameters

| Parameter | Description | Default |
| --- | --- | --- |
| `key_name` | SSH keypair name (must already exist) | No default |
| `flavor_name` | Instance size (coordinator plus one worker on 4 vCPU / 16 GiB) | `m2a.xlarge` |
| `image_name` | Operating system image | `Ubuntu-24.04` |
| `app_name` | Display name prefix for resources | `trino` |
| `volume_size` | Block volume size in GiB, mounted at `/var/lib/docker` | `80` |
| `external_network` | External network for floating IP allocation | `PublicStatic` |
| `private_cidr` | CIDR for the private subnet | `10.50.0.0/24` |
| `ui_allowed_cidr` | CIDR allowed to reach the Trino UI on port 8080 | `10.50.0.0/24` |
| `worker_count` | Trino worker containers (1 to 3 on this single VM) | `1` |
| `postgres_host` | PostgreSQL host for the postgres catalog | `""` |
| `clickhouse_host` | ClickHouse host for the clickhouse catalog | `""` |
| `iceberg_rest_uri` | Iceberg REST catalog URI | `""` |
| `s3_endpoint` | S3-compatible endpoint for Iceberg | `""` |
| `postgres_port` | PostgreSQL port for the postgres catalog | `5432` |
| `postgres_database` | PostgreSQL database for the postgres catalog | `analytics` |
| `postgres_user` | PostgreSQL user for the postgres catalog | `analytics` |
| `clickhouse_port` | ClickHouse HTTP port for the clickhouse catalog | `8123` |
| `iceberg_warehouse` | Iceberg warehouse URI for the iceberg catalog | `s3://lake/warehouse` |
| `s3_region` | S3 region identifier for Iceberg object storage | `us-east-1` |

## UI access and security

The Trino web UI listens on port 8080 over plain HTTP. The security group restricts 8080 to `ui_allowed_cidr`, which defaults to the private network only. Reach the UI over an SSH tunnel, through a reverse proxy on 443, or by setting `ui_allowed_cidr` to `YOUR_IP/32`.

## Federated catalogs

cloud-init writes catalog property files under `/opt/trino/catalog/` on the instance. Built-in `tpch` and `tpcds` catalogs always load. Postgres, ClickHouse, and Iceberg catalogs are created when you set the matching tfvars. Add passwords and object-storage keys on the instance after apply, then run `docker compose restart` in `/opt/trino`.

## When to use this pattern

Run a federated SQL query engine over Postgres warehouses, ClickHouse, and Iceberg lake tables on a VM you operate. Trino suits ad hoc analytics, cross-source joins, and the query layer in an open lakehouse stack.

For the warehouse itself, see [self-managed PostgreSQL](/resources/iac-templates/self-managed-postgres). For a column store, see [ClickHouse](/resources/iac-templates/clickhouse) when that template is on your branch.

## Estimated cost

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

## Template source

<TemplateSource slug="trino" />

<TemplateResourceMap template="trino" format="opentofu" />

## See also

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