Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs adjustments #120

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
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
17 changes: 12 additions & 5 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ The provider can be used to configure objects in Microsoft SQL Server and Azure
## Authentication methods

### SQL auth

Provider username and password, using `sql_auth` field:

```terraform
provider "mssql" {
hostname = "localhost"
Expand All @@ -25,11 +27,13 @@ provider "mssql" {
```

### Azure AD

In case of Azure SQL connections, Azure Active Directory auth tokens can be used to authenticate.

<br/>
#### Service Principal

Provide client ID (a.k.a. application ID), secret and tenant ID, using `azure_auth` field:

```terraform
provider "mssql" {
hostname = "example.database.windows.net"
Expand All @@ -43,20 +47,22 @@ provider "mssql" {
}
```

<br/>
#### Default chained credentials

When `azure_auth` value is set to empty object (`{}`), the provider uses chained credentials built from `EnvironmentCredential` -> `ManagedIdentityCredential` -> `AzureCLICredential`.

See [DefaultAzureCredential docs](https://github.com/Azure/azure-sdk-for-go/wiki/Set-up-Your-Environment-for-Authentication#configure-defaultazurecredential) for details.

<br/>
#### Environment variables

When `azure_auth` value is set to empty object (`{}`) and following environment variables are set, the env variable values will be used for authentication, taking precedence over `DefaultAzureCredential`.

- `ARM_CLIENT_ID`
- `ARM_CLIENT_SECRET`
- `ARM_TENANT_ID`

<br/>
Example:

```terraform
provider "mssql" {
hostname = "example.database.windows.net"
Expand All @@ -66,6 +72,7 @@ provider "mssql" {
```

## Computed connection provider configuration

Provider can be used, with certain limitations, with computed provider configuration. For example, provider's `hostname` can be sourced from `azurerm_mssql_server.fully_qualified_domain_name`. As shown in this [Azure SQL example](https://github.com/PGSSoft/terraform-provider-mssql/tree/main/examples/provider/azure_sql.tf)

~> **Warning** When connection details are computed and not known during plan execution (e.g. SQL Server resource returning FQDN is planned to be recreated), the state cannot contain any previously created `mssql_*` resources. In such case error will be reported, as the provider does not have enough information to generate correct plan.
Expand Down Expand Up @@ -96,4 +103,4 @@ Optional:
Required:

- `password` (String, Sensitive) Password for SQL authentication.
- `username` (String) User name for SQL authentication.
- `username` (String) User name for SQL authentication.
17 changes: 12 additions & 5 deletions templates/index.md.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -11,36 +11,43 @@ The provider can be used to configure objects in Microsoft SQL Server and Azure
## Authentication methods

### SQL auth

Provider username and password, using `sql_auth` field:

{{tffile "examples/provider/sql.tf"}}

### Azure AD

In case of Azure SQL connections, Azure Active Directory auth tokens can be used to authenticate.

<br/>
#### Service Principal

Provide client ID (a.k.a. application ID), secret and tenant ID, using `azure_auth` field:

{{tffile "examples/provider/aad_sp.tf"}}

<br/>
#### Default chained credentials

When `azure_auth` value is set to empty object (`{}`), the provider uses chained credentials built from `EnvironmentCredential` -> `ManagedIdentityCredential` -> `AzureCLICredential`.

See [DefaultAzureCredential docs](https://github.com/Azure/azure-sdk-for-go/wiki/Set-up-Your-Environment-for-Authentication#configure-defaultazurecredential) for details.

<br/>
#### Environment variables

When `azure_auth` value is set to empty object (`{}`) and following environment variables are set, the env variable values will be used for authentication, taking precedence over `DefaultAzureCredential`.

- `ARM_CLIENT_ID`
- `ARM_CLIENT_SECRET`
- `ARM_TENANT_ID`

<br/>
Example:

{{tffile "examples/provider/aad_default.tf"}}

## Computed connection provider configuration

Provider can be used, with certain limitations, with computed provider configuration. For example, provider's `hostname` can be sourced from `azurerm_mssql_server.fully_qualified_domain_name`. As shown in this [Azure SQL example](https://github.com/PGSSoft/terraform-provider-mssql/tree/main/examples/provider/azure_sql.tf)

~> **Warning** When connection details are computed and not known during plan execution (e.g. SQL Server resource returning FQDN is planned to be recreated), the state cannot contain any previously created `mssql_*` resources. In such case error will be reported, as the provider does not have enough information to generate correct plan.

{{ .SchemaMarkdown | trimspace }}
{{ .SchemaMarkdown | trimspace }}