Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,32 @@ services:
MYSQL_PASSWORD: ${MYSQL_PASSWORD:-c2VjcmV0Cg==}
MYSQL_DATABASE: ${MYSQL_DATABASE:-shop}

sqlserver:
container_name: sqlserver
build:
context: ./integration/sqlserver
ports:
- 1433:1433
restart: always
environment:
ACCEPT_EULA: Y
SA_PASSWORD: ${SQLSERVER_PASSWORD:-Password123!}
MSSQL_DB: ${SQLSERVER_DATABASE:-testdb}
MSSQL_USER: ${SQLSERVER_USER:-sa}
healthcheck:
test: |
if [ -f "/opt/mssql-tools18/bin/sqlcmd" ]; then
/opt/mssql-tools18/bin/sqlcmd -S localhost -U sa -P "$${SA_PASSWORD}" -Q "SELECT 1" -C || exit 1
elif [ -f "/opt/mssql-tools/bin/sqlcmd" ]; then
/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P "$${SA_PASSWORD}" -Q "SELECT 1" -C || exit 1
else
exit 1
fi
interval: 10s
timeout: 10s
retries: 15
start_period: 60s

provider:
build:
context: .
Expand Down
205 changes: 205 additions & 0 deletions docs/resources/connection_sqlserver.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "materialize_connection_sqlserver Resource - terraform-provider-materialize"
subcategory: ""
description: |-
A SQL Server connection establishes a link to a single database of a SQL Server instance.
---

# materialize_connection_sqlserver (Resource)

A SQL Server connection establishes a link to a single database of a SQL Server instance.

## Example Usage

```terraform
resource "materialize_secret" "sqlserver_password" {
name = "sqlserver_password"
value = base64encode("c2VjcmV0Cg==")
}
# Basic SQL Server connection
resource "materialize_connection_sqlserver" "basic" {
name = "sqlserver_connection"
host = "sql-server.example.com"
port = 1433
user {
text = "sqluser"
}
password {
name = materialize_secret.sqlserver_password.name
schema_name = materialize_secret.sqlserver_password.schema_name
database_name = materialize_secret.sqlserver_password.database_name
}
database = "testdb"
validate = true
}
# SQL Server connection with SSH tunnel
resource "materialize_connection_ssh_tunnel" "example_ssh_connection" {
name = "ssh_connection"
host = "bastion-host.example.com"
port = 22
user = "ubuntu"
}
resource "materialize_connection_sqlserver" "ssh_example" {
name = "sqlserver_ssh_connection"
host = "private-sql-server.example.com"
port = 1433
user {
text = "sqluser"
}
password {
name = materialize_secret.sqlserver_password.name
schema_name = materialize_secret.sqlserver_password.schema_name
database_name = materialize_secret.sqlserver_password.database_name
}
database = "testdb"
ssh_tunnel {
name = materialize_connection_ssh_tunnel.example_ssh_connection.name
}
validate = false
}
# SQL Server connection with AWS PrivateLink
resource "materialize_connection_aws_privatelink" "sqlserver_privatelink" {
name = "sqlserver_privatelink"
service_name = "com.amazonaws.vpce.us-east-1.vpce-svc-0e123abc123198abc"
availability_zones = ["use1-az1", "use1-az4"]
}
resource "materialize_connection_sqlserver" "privatelink_example" {
name = "sqlserver_privatelink_connection"
host = "sqlserver.example.com"
port = 1433
user {
text = "sqluser"
}
password {
name = materialize_secret.sqlserver_password.name
schema_name = materialize_secret.sqlserver_password.schema_name
database_name = materialize_secret.sqlserver_password.database_name
}
database = "testdb"
aws_privatelink {
name = materialize_connection_aws_privatelink.sqlserver_privatelink.name
}
validate = false
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `database` (String) The target SQL Server database.
- `host` (String) The SQL Server database hostname.
- `name` (String) The identifier for the connection.
- `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))

### Optional

- `aws_privatelink` (Block List, Max: 1) The AWS PrivateLink configuration for the SQL Server database. (see [below for nested schema](#nestedblock--aws_privatelink))
- `comment` (String) Comment on an object in the database.
- `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.
- `ownership_role` (String) The owernship role of the object.
- `password` (Block List, Max: 1) The SQL Server database password. (see [below for nested schema](#nestedblock--password))
- `port` (Number) The SQL Server database port.
- `region` (String) The region to use for the resource connection. If not set, the default region is used.
- `schema_name` (String) The identifier for the connection schema in Materialize. Defaults to `public`.
- `ssh_tunnel` (Block List, Max: 1) The SSH tunnel configuration for the SQL Server database. (see [below for nested schema](#nestedblock--ssh_tunnel))
- `validate` (Boolean) If the connection should wait for validation.

### Read-Only

- `id` (String) The ID of this resource.
- `qualified_sql_name` (String) The fully qualified name of the connection.

<a id="nestedblock--user"></a>
### Nested Schema for `user`

Optional:

- `secret` (Block List, Max: 1) The `user` secret value. Conflicts with `text` within this block. (see [below for nested schema](#nestedblock--user--secret))
- `text` (String, Sensitive) The `user` text value. Conflicts with `secret` within this block

<a id="nestedblock--user--secret"></a>
### Nested Schema for `user.secret`

Required:

- `name` (String) The user name.

Optional:

- `database_name` (String) The user database name. Defaults to `MZ_DATABASE` environment variable if set or `materialize` if environment variable is not set.
- `schema_name` (String) The user schema name. Defaults to `public`.



<a id="nestedblock--aws_privatelink"></a>
### Nested Schema for `aws_privatelink`

Required:

- `name` (String) The aws_privatelink name.

Optional:

- `database_name` (String) The aws_privatelink database name. Defaults to `MZ_DATABASE` environment variable if set or `materialize` if environment variable is not set.
- `schema_name` (String) The aws_privatelink schema name. Defaults to `public`.


<a id="nestedblock--password"></a>
### Nested Schema for `password`

Required:

- `name` (String) The password name.

Optional:

- `database_name` (String) The password database name. Defaults to `MZ_DATABASE` environment variable if set or `materialize` if environment variable is not set.
- `schema_name` (String) The password schema name. Defaults to `public`.


<a id="nestedblock--ssh_tunnel"></a>
### Nested Schema for `ssh_tunnel`

Required:

- `name` (String) The ssh_tunnel name.

Optional:

- `database_name` (String) The ssh_tunnel database name. Defaults to `MZ_DATABASE` environment variable if set or `materialize` if environment variable is not set.
- `schema_name` (String) The ssh_tunnel schema name. Defaults to `public`.

## Import

Import is supported using the following syntax:

```shell
#!/bin/bash

# SQL Server connections can be imported using the connection name
terraform import materialize_connection_sqlserver.example <region>:<connection_name>

# Example
terraform import materialize_connection_sqlserver.example aws/us-east-1:my_sqlserver_connection
```
Loading
Loading