Apply for invite to IaCP

CLI Usage

Overview

The Terraform CLI NEWWIN is used manage the operations and state of Terraform deployments. The CLI can be configured to work with either local NEWWIN or remote NEWWIN backends.

Scalr provides a remote backend with fully compatible API.

CLI Commands

Scalr remote backend provides the following support for commands of Terraform CLI. Scalr only supports the CLI for versions >= 0.12.0:

CLI command

IaCP

apply

console

destroy

fmt

get

graph

import

init

output

plan

providers

show

state

taint

untaint

validate

version

workspace

Note

Workspaces will be created automatically in IaCP the first time terraform init is run. All other workspace management operations must currently be done in the UI

API Token

To use the CLI, you must first obtain an API token:

  1. Create API Token

    ../_images/api_token.png
  2. Add a credentials to your CLI Configuration file.

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

credentials "my.scalr.com" {
  token = "<user-token>"
}

Configure Terraform Template

To have your template come through the Scalr pipeline, you just need to add a few lines defining it as a remote backend:

  1. Get the organization id from the environment switcher on the UI

    ../_images/org_id.png
  2. Add a terraform block to your template. The hostname will be your local installation if IaCP is deployed on-prem. You can choose the workspace name at this point.

terraform {
  backend "remote" {
    hostname = "my.scalr.com"
    organization = "<organization-name of environment>"
    workspaces {
      name = "<workspace-name>"
    }
  }
}

Click on the following link for a tutorial Guide : CLI driven runs with IaCP