../_images/login_button.png ../_images/signup_button.png



Scalr Terraform Provider

(Version rc9)

Overview

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

Authentication

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

../_images/api_access.png

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.

OS

File name and location

Windows

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

~/.terraformrc

provider scalr {
  hostname = var.hostname
}

Authentication with Environment Variables

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

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

export SCALR_HOSTNAME="my-account.scalr.io"
export SCALR_TOKEN="xxxxxxxxxxxxxxxxxx"

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

../_images/provider_vars.png

The provider block will not require any parameters.

provider scalr {}

Scalr Provider Installation

Note

This a 3rd party provider which cannot be automatically downloaded by Terraform. This provider must be installed manually.

The locations for installing the provider plugins depend on the version of Terraform in use. This tables specifies the installation locations for the specific versions of Terraform.

Version

User Level Plugins

Workspace Plugins

0.12.x

~/.terraform.d/plugins/

{workspace}/terraform.d/plugins

0.13.x

~/.terraform.d/plugins/scalr.com/scalr/scalr/{version}/{os}_{arch}

{workspace}/terraform.d/plugins/scalr.com/scalr/scalr/{version}/{os}_{arch}

The provider executables can be found here: https://github.com/Scalr/terraform-provider-scalr/releases

If you required detailed instructions for installing the provider please follow the link that is applicable to your version of Terraform.

Example

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

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

resource scalr_workspace test {
  name         = "my-workspace-name"
  organization = "your_org_id"
  auto_apply = "true"
  terraform_version = "0.12.19"
  vcs_provider_id = "my_vcs_provider"
  vcs_repo {
      identifier = "repo_org/repo_name"
      }
  }

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