Targets

Targets #

A sample targets.hcl looks like this:

target "D40\SQL2014" {}
target "server.domain.com" {}

The text in quotes is what it will try to connect to. The full layout of a targets file might look like this:

target_defaults {
    dial_timeout = 10
    connect_timeout = 15
}

target "my-target" {
    fqdn = "host:port"
    dial_timeout = 90
}
  • The target_defaults block sets the defaults for all targets.
  • The dial_timeout is the timeout to resolve the name and talk to the port. It is in seconds and defaults to 15 seconds.
  • The connect_timeout is the timeout to login. It defaults to 0 which is no timeout and is measured in seconds.
  • If no fqdn is specified, the name in quotes is used (“my-target”).
  • The port should be specified with colon but a comma will also work.
  • The application uses a trusted connection unless a SQL Server login is specified (see below).

Connecting with SQL Server Logins #

Targets support connecting with SQL Server logins. For each Target, you can specify a Credential (see the CredentialVault). That looks like this:

target "server-name" {
    sqldsc_credential = "cred_name"
}

A sqldsc_credential can also be specified in the target_defaults block. That will be used for all targets in the file unless overridden by a specific target.

Supporting Multiple Users #

A common scenario is to manage SQL Servers in a domain with no trust relationship using SQL Server logins. The DOMAIN.targets.hcl might look like this:

target_defaults {
    sqldsc_credential = "dba_credential"
}

In my Vault, I map dba_credential to my login like this:

sqldsc vault save dba_credential bgraziano

This creates a Credential named dba_credential with the login named bgraziano. Other DBA’s on the team would each map their own login for dba_credential. This allows a common configuration but avoids shared logins.