Scalr Terraform Provider


The Scalr Terraform provider can be used to manage the components within Scalr. This will allow you to automate the creation of workspaces, variables, VCS providers and much more.


To start, an API token must be generated by clicking on your user on the top right of the screen and clicking on “TF API Access”:


This will provide you with an ID and token. The token will disappear after you click close. A user can have as many tokens as they want, it is up to that user to manage the tokens.

The token should then be used within the provider itself:

provider scalr {
  hostname = var.hostname
  token    = var.api_token

You can also add the token to your Terraform configuration file and the Scalr provider will use it automatically based on the hostname.


File name and location


The file must be named named terraform.rc and placed in the relevant user’s %APPDATA% directory. The physical location of this directory depends on your Windows version and system configuration; use $env:APPDATA in PowerShell to find its location on your system.

All other


provider scalr {
  hostname = var.hostname

Authentication with Shell Variables

The Scalr provider accepts the hostname and token values through shell variables SCALR_HOSTNAME and SCALR_TOKEN.

These variables can be set in your local shell, e.g.

export SCALR_TOKEN="xxxxxxxxxxxxxxxxxx"

They can also be set in the variables tab of a Scalr workspace.


The provider block will not require any parameters if these are set.

provider scalr {}

Authentication when Managing Scalr Objects

A best practice is to use the Scalr Terraform provider to manage other objects within Scalr. It is important to note that each Scalr run has it’s own unique authentication token that has minimal permissions to allow for the run execution. If the run is executing Terraform code that will create, update, or delete other Scalr objects, you must override the default token in the Scalr runner. This can be done by setting a new token as a Shell Variables within the workspace. It is recommended to use Service Accounts for the token.

To override the variable, please set it as a hidden variable in the workspace that is executing the run:




Terraform >= 13 or higher is required. Please see Terraform 0.12.x Scalr Provider Installation for Terraform 0.12.x instructions.

To use the Scalr provider, simply add the following code block to your code:

terraform {
    required_providers {
        scalr = {
            source = ""
            version= "1.0.0-rc27"

Example usage and the version list can be found here NEWWIN. The GPG key for the provider registry can be found here NEWWIN. The fingerprint is 1EF68C8041FC80714FF7A4017F685A20F41004C4.

If needed, the provider executables can be found here NEWWIN.


Here is a basic example of creating a workspace with the provider:

provider scalr {
  hostname = var.hostname
  token    = var.api_token

data "scalr_vcs_provider" test {
  name = "vcs-name"
  account_id = "acc-xxxx" # if the user has access to more than one account

data "scalr_environment" test {
  name = "env-name"
  account_id = "acc-xxxx" # if the user has access to more than one account

resource "scalr_workspace" "vcs-driven" {
  name            = "my-workspace-name"
  environment_id  =
  vcs_provider_id =

  working_directory = "example/path"

  vcs_repo {
      identifier          = "org/repo"
      branch              = "dev"
      trigger_prefixes    = ["stage", "prod"]

Please see the full details for all of the resources in the list below.