123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- 1. In the [SQL Shell](https://console.materialize.com/), or your preferred SQL
- client connected to Materialize, use the [`CREATE CONNECTION`](/sql/create-connection/#aws-privatelink)
- command to create an AWS PrivateLink connection:
- ↕️ **In-region connections**
- To connect to an AWS PrivateLink endpoint service in the **same region** as your
- Materialize environment:
- ```mzsql
- CREATE CONNECTION privatelink_svc TO AWS PRIVATELINK (
- SERVICE NAME 'com.amazonaws.vpce.<region_id>.vpce-svc-<endpoint_service_id>',
- AVAILABILITY ZONES ('use1-az1', 'use1-az2', 'use1-az4')
- );
- ```
- - Replace the `SERVICE NAME` value with the service name you noted [earlier](#b-optional-configure-network-security).
- - Replace the `AVAILABILITY ZONES` list with the IDs of the availability
- zones in your AWS account. For in-region connections the availability
- zones of the NLB and the consumer VPC **must match**.
- To find your availability zone IDs, select your database in the RDS
- Console and click the subnets under **Connectivity & security**. For each
- subnet, look for **Availability Zone ID** (e.g., `use1-az6`),
- not **Availability Zone** (e.g., `us-east-1d`).
- ↔️ **Cross-region connections**
- To connect to an AWS PrivateLink endpoint service in a **different region** to
- the one where your Materialize environment is deployed:
- ```mzsql
- CREATE CONNECTION privatelink_svc TO AWS PRIVATELINK (
- SERVICE NAME 'com.amazonaws.vpce.us-west-1.vpce-svc-<endpoint_service_id>',
- -- For now, the AVAILABILITY ZONES clause **is** required, but will be
- -- made optional in a future release.
- AVAILABILITY ZONES ()
- );
- ```
- - Replace the `SERVICE NAME` value with the service name you noted [earlier](#b-optional-configure-network-security).
- - The service name region refers to where the endpoint service was created.
- You **do not need** to specify `AVAILABILITY ZONES` manually — these will
- be optimally auto-assigned when none are provided.
- 1. Retrieve the AWS principal for the AWS PrivateLink connection you just
- created:
- ```mzsql
- SELECT principal
- FROM mz_aws_privatelink_connections plc
- JOIN mz_connections c ON plc.id = c.id
- WHERE c.name = 'privatelink_svc';
- ```
- <p></p>
- ```
- principal
- ---------------------------------------------------------------------------
- arn:aws:iam::664411391173:role/mz_20273b7c-2bbe-42b8-8c36-8cc179e9bbc3_u1
- ```
- 1. Update your VPC endpoint service to [accept connections from the AWS
- principal](https://docs.aws.amazon.com/vpc/latest/privatelink/add-endpoint-service-permissions.html).
- 1. If your AWS PrivateLink service is configured to require acceptance of
- connection requests, [manually approve the connection request from
- Materialize](https://docs.aws.amazon.com/vpc/latest/privatelink/configure-endpoint-service.html#accept-reject-connection-requests).
- **Note:** It can take some time for the connection request to show up. Do
- not move on to the next step until you've approved the connection.
- 1. Validate the AWS PrivateLink connection you created using the
- [`VALIDATE CONNECTION`](/sql/validate-connection) command:
- ```mzsql
- VALIDATE CONNECTION privatelink_svc;
- ```
- If no validation error is returned, move to the next step.
- 1. Use the [`CREATE SECRET`](/sql/create-secret/) command to securely store the password for the `materialize` SQL Server user [you created](#1-create-a-materialize-user-in-sql-server):
- ```mzsql
- CREATE SECRET sql_server_pass AS '<PASSWORD>';
- ```
- 1. Use the [`CREATE CONNECTION`](/sql/create-connection/) command to create
- another connection object, this time with database access and authentication
- details for Materialize to use:
- ```mzsql
- CREATE CONNECTION sql_server_connection TO SQL SERVER (
- HOST <host>,
- PORT 1433,
- USER 'materialize',
- PASSWORD SECRET sql_server_pass,
- SSL MODE REQUIRED,
- AWS PRIVATELINK privatelink_svc
- );
- ```
- - Replace `<host>` with your RDS endpoint. To find your RDS endpoint, select
- your database in the RDS Console, and look under **Connectivity &
- security**.
- - Replace `<database>` with the name of the database containing the tables
- you want to replicate to Materialize.
- 1. Use the [`CREATE SOURCE`](/sql/create-source/) command to connect Materialize
- to your RDS instance via AWS PrivateLink and start ingesting data:
- ```mzsql
- CREATE SOURCE mz_source
- FROM SQL SERVER CONNECTION sql_server_connection
- FOR ALL TABLES;
- ```
- By default, the source will be created in the active cluster; to use a
- different cluster, use the `IN CLUSTER` clause. To ingest data from
- specific schemas or tables, use `FOR SCHEMAS(<schema1>,<schema2>)` or `FOR
- TABLES (<table1>, <table2>)` instead of `FOR ALL TABLES`.
- AWS IAM authentication is also available, see the [`CREATE CONNECTION`](/sql/create-connection/#mysql) command for details.
|