Module Registry Workspace

Module Registry Workspace

Scalr workspaces can also be created by selecting a module from the private module registry. We see this type of workspace used for two use cases:

  1. This is a good option if you like the idea of a service catalog, but don't want to go back to a traditional catalog feel. This method makes it easy for anyone to deploy Terraform and understand Terraform concepts at the same time.
  2. Some organizations like the idea of storing code in Git, but not the idea of deployments based on code being merged. This allows for a more controlled deployment as the version can be updated and then a run created through the UI, API, or CLI.

There are three basic steps to get started with a module registry-driven workspace:

  1. Ensure a deployable module is available
  2. Create the workspace
  3. Set the variables (if necessary)

Create Workspace

For a module-driven workspace, the user is required to select the module and module version, all other fields are optional. If variables are required, the user will be prompted to fill in the variables once the workspace is created.

1158

Once the workspace is deployed, the module will remain the source. Users can update to a new version of the module if required by updating the version in the workspace settings.

Set Terraform Variables

Terraform variables can be set in the Terraform code or within the Scalr UI. If the configuration contains variables that do not have assigned values, then these must be assigned values in the Scalr workspace via the UI. Scalr will automatically create the variables.

2190

If the local workspace contains any *.auto.tfvars files these will provide default variable values that Terraform will automatically use.

If variables in the *.auto.tfvars files have the same names as variables specified in the workspace, the predefined workspace values will be used. For map variables, the values in *.auto.tfvars are merged with values in the same named variable in the workspace.

Set Shell Variables

If the Terraform configuration utilizes shell variables (export var=value), e.g. for credentials or to set values for Terraform input variables with TF_VAR_{variable_name}={value} (-parallelism, -var-file, etc).

Shell variables can be set at all levels in Scalr and are inherited by lower levels. Use environment or account level for shell variables that are needed in multiple workspaces or environments. Use workspace level for shell variables that are specific to individual Terraform configurations.

It is also possible to use the Scalr provider to pull output from one workspace and post it as an environment or account shell variable to make it easily available to all other workspaces.

2152

See Variables for full details.

Video

More of a visual learner? Check out this feature on YouTube.