Sharing Workspace State
Sharing State 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 valuerunner-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 known as “remote state” and accessing the remote state is done using the terraform_remote_state
data source as shown in this example.
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.
Remote State Code Snippet
To obtain the remote state code snippet for a workspace, go to the workspace dashboard and click on Output Usage. A code snippet similar to the one above will be provided which can then be pasted into your Terraform code.
Sharing Within an Environment
Scalr workspaces have the option to limit which workspaces can access the state. 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 state can be shared with:
Updated 3 months ago