|
| 1 | +--- |
| 2 | +# generated by https://github.com/hashicorp/terraform-plugin-docs |
| 3 | +page_title: "materialize_connection_sqlserver Resource - terraform-provider-materialize" |
| 4 | +subcategory: "" |
| 5 | +description: |- |
| 6 | + A SQL Server connection establishes a link to a single database of a SQL Server instance. |
| 7 | +--- |
| 8 | + |
| 9 | +# materialize_connection_sqlserver (Resource) |
| 10 | + |
| 11 | +A SQL Server connection establishes a link to a single database of a SQL Server instance. |
| 12 | + |
| 13 | +## Example Usage |
| 14 | + |
| 15 | +```terraform |
| 16 | +resource "materialize_secret" "sqlserver_password" { |
| 17 | + name = "sqlserver_password" |
| 18 | + value = base64encode("c2VjcmV0Cg==") |
| 19 | +} |
| 20 | +
|
| 21 | +# Basic SQL Server connection |
| 22 | +resource "materialize_connection_sqlserver" "basic" { |
| 23 | + name = "sqlserver_connection" |
| 24 | + host = "sql-server.example.com" |
| 25 | + port = 1433 |
| 26 | +
|
| 27 | + user { |
| 28 | + text = "sqluser" |
| 29 | + } |
| 30 | +
|
| 31 | + password { |
| 32 | + name = materialize_secret.sqlserver_password.name |
| 33 | + schema_name = materialize_secret.sqlserver_password.schema_name |
| 34 | + database_name = materialize_secret.sqlserver_password.database_name |
| 35 | + } |
| 36 | +
|
| 37 | + database = "testdb" |
| 38 | + validate = true |
| 39 | +} |
| 40 | +
|
| 41 | +# SQL Server connection with SSH tunnel |
| 42 | +resource "materialize_connection_ssh_tunnel" "example_ssh_connection" { |
| 43 | + name = "ssh_connection" |
| 44 | + host = "bastion-host.example.com" |
| 45 | + port = 22 |
| 46 | + user = "ubuntu" |
| 47 | +} |
| 48 | +
|
| 49 | +resource "materialize_connection_sqlserver" "ssh_example" { |
| 50 | + name = "sqlserver_ssh_connection" |
| 51 | + host = "private-sql-server.example.com" |
| 52 | + port = 1433 |
| 53 | +
|
| 54 | + user { |
| 55 | + text = "sqluser" |
| 56 | + } |
| 57 | +
|
| 58 | + password { |
| 59 | + name = materialize_secret.sqlserver_password.name |
| 60 | + schema_name = materialize_secret.sqlserver_password.schema_name |
| 61 | + database_name = materialize_secret.sqlserver_password.database_name |
| 62 | + } |
| 63 | +
|
| 64 | + database = "testdb" |
| 65 | +
|
| 66 | + ssh_tunnel { |
| 67 | + name = materialize_connection_ssh_tunnel.example_ssh_connection.name |
| 68 | + } |
| 69 | +
|
| 70 | + validate = false |
| 71 | +} |
| 72 | +
|
| 73 | +# SQL Server connection with AWS PrivateLink |
| 74 | +resource "materialize_connection_aws_privatelink" "sqlserver_privatelink" { |
| 75 | + name = "sqlserver_privatelink" |
| 76 | + service_name = "com.amazonaws.vpce.us-east-1.vpce-svc-0e123abc123198abc" |
| 77 | + availability_zones = ["use1-az1", "use1-az4"] |
| 78 | +} |
| 79 | +
|
| 80 | +resource "materialize_connection_sqlserver" "privatelink_example" { |
| 81 | + name = "sqlserver_privatelink_connection" |
| 82 | + host = "sqlserver.example.com" |
| 83 | + port = 1433 |
| 84 | +
|
| 85 | + user { |
| 86 | + text = "sqluser" |
| 87 | + } |
| 88 | +
|
| 89 | + password { |
| 90 | + name = materialize_secret.sqlserver_password.name |
| 91 | + schema_name = materialize_secret.sqlserver_password.schema_name |
| 92 | + database_name = materialize_secret.sqlserver_password.database_name |
| 93 | + } |
| 94 | +
|
| 95 | + database = "testdb" |
| 96 | +
|
| 97 | + aws_privatelink { |
| 98 | + name = materialize_connection_aws_privatelink.sqlserver_privatelink.name |
| 99 | + } |
| 100 | +
|
| 101 | + validate = false |
| 102 | +} |
| 103 | +``` |
| 104 | + |
| 105 | +<!-- schema generated by tfplugindocs --> |
| 106 | +## Schema |
| 107 | + |
| 108 | +### Required |
| 109 | + |
| 110 | +- `database` (String) The target SQL Server database. |
| 111 | +- `host` (String) The SQL Server database hostname. |
| 112 | +- `name` (String) The identifier for the connection. |
| 113 | +- `user` (Block List, Min: 1, Max: 1) The SQL Server database username.. Can be supplied as either free text using `text` or reference to a secret object using `secret`. (see [below for nested schema](#nestedblock--user)) |
| 114 | + |
| 115 | +### Optional |
| 116 | + |
| 117 | +- `aws_privatelink` (Block List, Max: 1) The AWS PrivateLink configuration for the SQL Server database. (see [below for nested schema](#nestedblock--aws_privatelink)) |
| 118 | +- `comment` (String) Comment on an object in the database. |
| 119 | +- `database_name` (String) The identifier for the connection database in Materialize. Defaults to `MZ_DATABASE` environment variable if set or `materialize` if environment variable is not set. |
| 120 | +- `ownership_role` (String) The owernship role of the object. |
| 121 | +- `password` (Block List, Max: 1) The SQL Server database password. (see [below for nested schema](#nestedblock--password)) |
| 122 | +- `port` (Number) The SQL Server database port. |
| 123 | +- `region` (String) The region to use for the resource connection. If not set, the default region is used. |
| 124 | +- `schema_name` (String) The identifier for the connection schema in Materialize. Defaults to `public`. |
| 125 | +- `ssh_tunnel` (Block List, Max: 1) The SSH tunnel configuration for the SQL Server database. (see [below for nested schema](#nestedblock--ssh_tunnel)) |
| 126 | +- `validate` (Boolean) If the connection should wait for validation. |
| 127 | + |
| 128 | +### Read-Only |
| 129 | + |
| 130 | +- `id` (String) The ID of this resource. |
| 131 | +- `qualified_sql_name` (String) The fully qualified name of the connection. |
| 132 | + |
| 133 | +<a id="nestedblock--user"></a> |
| 134 | +### Nested Schema for `user` |
| 135 | + |
| 136 | +Optional: |
| 137 | + |
| 138 | +- `secret` (Block List, Max: 1) The `user` secret value. Conflicts with `text` within this block. (see [below for nested schema](#nestedblock--user--secret)) |
| 139 | +- `text` (String, Sensitive) The `user` text value. Conflicts with `secret` within this block |
| 140 | + |
| 141 | +<a id="nestedblock--user--secret"></a> |
| 142 | +### Nested Schema for `user.secret` |
| 143 | + |
| 144 | +Required: |
| 145 | + |
| 146 | +- `name` (String) The user name. |
| 147 | + |
| 148 | +Optional: |
| 149 | + |
| 150 | +- `database_name` (String) The user database name. Defaults to `MZ_DATABASE` environment variable if set or `materialize` if environment variable is not set. |
| 151 | +- `schema_name` (String) The user schema name. Defaults to `public`. |
| 152 | + |
| 153 | + |
| 154 | + |
| 155 | +<a id="nestedblock--aws_privatelink"></a> |
| 156 | +### Nested Schema for `aws_privatelink` |
| 157 | + |
| 158 | +Required: |
| 159 | + |
| 160 | +- `name` (String) The aws_privatelink name. |
| 161 | + |
| 162 | +Optional: |
| 163 | + |
| 164 | +- `database_name` (String) The aws_privatelink database name. Defaults to `MZ_DATABASE` environment variable if set or `materialize` if environment variable is not set. |
| 165 | +- `schema_name` (String) The aws_privatelink schema name. Defaults to `public`. |
| 166 | + |
| 167 | + |
| 168 | +<a id="nestedblock--password"></a> |
| 169 | +### Nested Schema for `password` |
| 170 | + |
| 171 | +Required: |
| 172 | + |
| 173 | +- `name` (String) The password name. |
| 174 | + |
| 175 | +Optional: |
| 176 | + |
| 177 | +- `database_name` (String) The password database name. Defaults to `MZ_DATABASE` environment variable if set or `materialize` if environment variable is not set. |
| 178 | +- `schema_name` (String) The password schema name. Defaults to `public`. |
| 179 | + |
| 180 | + |
| 181 | +<a id="nestedblock--ssh_tunnel"></a> |
| 182 | +### Nested Schema for `ssh_tunnel` |
| 183 | + |
| 184 | +Required: |
| 185 | + |
| 186 | +- `name` (String) The ssh_tunnel name. |
| 187 | + |
| 188 | +Optional: |
| 189 | + |
| 190 | +- `database_name` (String) The ssh_tunnel database name. Defaults to `MZ_DATABASE` environment variable if set or `materialize` if environment variable is not set. |
| 191 | +- `schema_name` (String) The ssh_tunnel schema name. Defaults to `public`. |
| 192 | + |
| 193 | +## Import |
| 194 | + |
| 195 | +Import is supported using the following syntax: |
| 196 | + |
| 197 | +```shell |
| 198 | +#!/bin/bash |
| 199 | + |
| 200 | +# SQL Server connections can be imported using the connection name |
| 201 | +terraform import materialize_connection_sqlserver.example <region>:<connection_name> |
| 202 | + |
| 203 | +# Example |
| 204 | +terraform import materialize_connection_sqlserver.example aws/us-east-1:my_sqlserver_connection |
| 205 | +``` |
0 commit comments