Sharing Outputs

❗️

Sharing Output Between Environments

State sharing between environments is disabled by default. To share the state between environments please set a shell variable SCALR_RUNNER_ROLE with the value runner-account-access at the account scope.

It is common practice to reference outputs from other workspaces so that a Terraform configuration can make use of resources that have been deployed in another workspace. This is done using the terraform_remote_state data source as shown in this example. When using the datasource, it will only read outputs, not the entire state file.

data "terraform_remote_state" "state-1" {
  backend = "remote"

  config = {
    hostname = "<host>"
    organization = "<env_id>"
    workspaces = {
      name = "<workspace name>"
    }
  }
}

In Scalr, a workspace can reference the outputs of any other workspace in any environment if SCALR_RUNNER_ROLE=runner-account-access has been set as a shell variable at the account scope. Alternatively, if SCALR_RUNNER_ROLE is not set at the account scope, then workspaces will only have access to the remote state files within the same environment.

Sharing Within an Environment

Scalr workspaces have the option to limit which workspaces can access the outputs. Workspace owners can allow the following sharing options:

  • All workspaces in an environment
  • No workspaces (only accessed by the current workspace)
  • Some workspaces

When some workspace is selected, users will be prompted to select the workspaces that output can be shared with:

If the setting is updated to "No workspaces" or "Some workspaces", the output will not be able to be shared across environments even if the SCALR_RUNNER_ROLE variable is set.

Remote State Code Snippet

Note: This functionality is only available is the Scalr backend is used.

To obtain the remote state code snippet for the outputs, go to the workspace dashboard and click on Remote State Snippet.:

A code snippet similar to the one below will be provided which can then be pasted into your Terraform code.