PRO: Variables

PRO: Variables #

All features described on this page are part of the Professional Edition.

You can purchase licenses for the Professional Edition on the Portal: https://portal.sqldsc.com.

Starting in 1.37, the PRO Edition allows variables to set attribute values.

# tags/read-only.hcl
login "placeholder" {
    login = "${read-only-account}"
    permissions = ["view server state"]
    user_databases {
        roles = ["db_datareader"]
    }
}

# tags/txn-ag.hcl
# configure the nodes the txn-ag Availability Group
variable "read-only-account" {
    value = "PROD\txn-ag-read-only"
}

# targets.hcl 
target "ag-node-01" {
    add_tags = ["txn-ag", "read-only"]
}
target "ag-node-02" {
    add_tags = ["txn-ag", "read-only"]
}

The read-only tag uses a login block to configure permissions for a login. The particular login is in the read-only-account variable. That variable is defined in the txn-ag tag. That tag is assigned to two nodes (which happen to be members of AG in this scenario)

Variables can only set attribute values and not block labels or block names. This is a quirk of the parser that may get change one of these days. Thus the placeholder in the above example.