title: "Ingest data from AlloyDB" description: "How to stream data from AlloyDB to Materialize" aliases:
This page shows you how to stream data from AlloyDB for PostgreSQL to Materialize using the PostgreSQL source.
{{< tip >}} {{< guided-tour-blurb-for-ingest-data >}} {{< /tip >}}
{{% postgres-direct/before-you-begin %}}
If you don't already have an AlloyDB instance, creating one involves several steps, including configuring your cluster and setting up network connections. For detailed instructions, refer to the AlloyDB documentation.
Materialize uses PostgreSQL's logical replication protocol to track changes in your database and propagate them to Materialize.
To enable logical replication in AlloyDB, see the AlloyDB documentation.
{{% postgres-direct/create-a-publication-other %}}
{{< note >}} If you are prototyping and your AlloyDB instance is publicly accessible, you can skip this step. For production scenarios, we recommend configuring one of the network security options below. {{</ note >}}
To establish authorized and secure connections to an AlloyDB instance, an authentication proxy is necessary. Google Cloud Platform provides a guide to assist you in setting up this proxy and generating a connection string that can be utilized with Materialize. Further down, we will provide you with a tailored approach specific to integrating Materialize.
Next, choose the best network configuration for your setup to connect Materialize with AlloyDB:
{{< tabs >}}
{{< tab "Allow Materialize IPs">}}
In the Materialize console's SQL Shell, or your preferred SQL client connected to Materialize, find the static egress IP addresses for the Materialize region you are running in:
SELECT * FROM mz_egress_ips;
Update your Google Cloud firewall rules to allow traffic to your AlloyDB auth proxy instance from each IP address from the previous step.
{{< /tab >}}
{{< tab "Use an SSH tunnel">}}
To create an SSH tunnel from Materialize to your database, you launch an instance to serve as an SSH bastion host, configure the bastion host to allow traffic only from Materialize, and then configure your database's private network to allow traffic from the bastion host.
Launch a GCE instance to serve as your SSH bastion host.
Configure the SSH bastion host to allow traffic only from Materialize.
In the Materialize console's SQL Shell, or your preferred SQL client connected to Materialize, get the static egress IP addresses for the Materialize region you are running in:
SELECT * FROM mz_egress_ips;
Update your SSH bastion host's firewall rules to allow traffic from each IP address from the previous step.
Update your Google Cloud firewall rules to allow traffic to your AlloyDB auth proxy instance from the SSH bastion host.
{{< /tab >}}
{{< /tabs >}}
{{< note >}}
If you are prototyping and already have a cluster to host your PostgreSQL
source (e.g. quickstart
), you can skip this step. For production
scenarios, we recommend separating your workloads into multiple clusters for
resource isolation.
{{< /note >}}
{{% postgres-direct/create-a-cluster %}}
With the network configured and an ingestion pipeline in place, connect Materialize to your AlloyDB instance and begin the data ingestion process.
{{< tabs >}}
{{< tab "Allow Materialize IPs">}} {{% postgres-direct/ingesting-data/allow-materialize-ips %}} {{< /tab >}}
{{< tab "Use an SSH tunnel">}} {{% postgres-direct/ingesting-data/use-ssh-tunnel %}} {{< /tab >}}
{{< /tabs >}}
{{% postgres-direct/check-the-ingestion-status %}}
{{% postgres-direct/right-size-the-cluster %}}
{{% postgres-direct/next-steps %}}
{{< include-md file="shared-content/postgres-considerations.md" >}}