Back to Materialize

SSH tunnel connections

doc/user/content/ingest-data/network-security/ssh-tunnel.md

1231.7 KB
Original Source

{{< tabs >}} {{< tab "Cloud" >}} {{% network-security/ssh-tunnel %}} {{< /tab >}} {{< tab "Self-Managed" >}} {{% network-security/ssh-tunnel-sm %}} {{< /tab >}} {{< /tabs >}}

Create a source connection

In Materialize, create a source connection that uses the SSH tunnel connection you configured in the previous section:

{{< tabs tabID="1" >}} {{< tab "Kafka">}}

mzsql
CREATE CONNECTION kafka_connection TO KAFKA (
    BROKER 'broker1:9092',
    SSH TUNNEL ssh_connection
);

You can reuse this Kafka connection across multiple CREATE SOURCE statements.

{{< /tab >}} {{< tab "PostgreSQL">}}

mzsql
CREATE SECRET pgpass AS '<POSTGRES_PASSWORD>';

CREATE CONNECTION pg_connection TO POSTGRES (
  HOST 'instance.foo000.us-west-1.rds.amazonaws.com',
  PORT 5432,
  USER 'postgres',
  PASSWORD SECRET pgpass,
  SSL MODE 'require',
  DATABASE 'postgres'
  SSH TUNNEL ssh_connection
);

You can reuse this PostgreSQL connection across multiple CREATE SOURCE statements:

mzsql
CREATE SOURCE mz_source
  FROM POSTGRES CONNECTION pg_connection (PUBLICATION 'mz_source')
  FOR ALL TABLES;

{{< /tab >}}

{{< tab "MySQL">}}

mzsql
CREATE SECRET mysqlpass AS '<POSTGRES_PASSWORD>';

CREATE CONNECTION mysql_connection TO MYSQL (
  HOST '<host>',
  SSH TUNNEL ssh_connection,
);

You can reuse this MySQL connection across multiple CREATE SOURCE statements.

{{< /tab >}}

{{< /tabs >}}