scalr_workspace
Resource: scalr_workspace
Manage the state of workspaces in Scalr. Create, update and destroy.
Example Usage
VCS-driven
data "scalr_vcs_provider" "example" {
name = "vcs-name"
account_id = "acc-xxxxxxxxxx"
}
data "scalr_environment" "example" {
name = "env-name"
account_id = "acc-xxxxxxxxxx"
}
resource "scalr_workspace" "example" {
name = "my-workspace-name"
environment_id = data.scalr_environment.example.id
vcs_provider_id = data.scalr_vcs_provider.example.id
working_directory = "example/path"
vcs_repo {
identifier = "org/repo"
branch = "dev"
trigger_prefixes = ["stage", "prod"]
}
provider_configuration {
id = "pcfg-xxxxxxxxxx"
alias = "us_east1"
}
provider_configuration {
id = "pcfg-yyyyyyyyyy"
alias = "us_east2"
}
}
resource "scalr_workspace" "trigger_patterns" {
name = "trigger_patterns"
environment_id = data.scalr_environment.example.id
vcs_provider_id = data.scalr_vcs_provider.example.id
working_directory = "example/path"
vcs_repo {
identifier = "org/repo"
branch = "dev"
trigger_patterns = <<-EOT
!*.MD
!/**/test/
/infrastructure/environments/pre/
/infrastructure/modules/app/
/infrastructure/modules/db/
/infrastructure/modules/queue/
EOT
}
}
Module-driven
data "scalr_environment" "example" {
name = "env-name"
account_id = "acc-xxxxxxxxxx"
}
locals {
modules = {
"${data.scalr_environment.example.id}" : "module-name/provider", # environment-level module will be selected
"${data.scalr_environment.example.account_id}" : "module-name/provider", # account-level module will be selected
}
}
data "scalr_module_version" "example" {
for_each = local.modules
source = "${each.key}/${each.value}"
}
resource "scalr_workspace" "example" {
for_each = data.scalr_module_version.example
environment_id = data.scalr_environment.example.id
name = replace(each.value.source, "/", "-")
module_version_id = each.value.id
}
CLI-driven
data "scalr_environment" "example" {
name = "env-name"
account_id = "acc-xxxxxxxxxx"
}
resource "scalr_workspace" "example" {
name = "my-workspace-name"
environment_id = data.scalr_environment.example.id
working_directory = "example/path"
}
Create tagged workspaces
resource "scalr_tag" "team-a" {
name = "TeamA"
}
resource "scalr_tag" "team-b" {
name = "TeamB"
}
resource "scalr_workspace" "example-a" {
environment_id = "env-xxxxxxxxxx"
name = "example-a"
tag_ids = [scalr_tag.team-a.id]
}
resource "scalr_workspace" "example-b" {
environment_id = "env-xxxxxxxxxx"
name = "example-b"
tag_ids = [scalr_tag.team-b.id]
}
Schema
Required
environment_id
(String) ID of the environment, in the formatenv-<RANDOM STRING>
.name
(String) Name of the workspace.
Optional
agent_pool_id
(String) The identifier of an agent pool in the formatapool-<RANDOM STRING>
.auto_apply
(Boolean) Set (true/false) to configure ifterraform apply
should automatically run whenterraform plan
ends without error. Defaultfalse
.auto_queue_runs
(String) Indicates if runs have to be queued automatically when a new configuration version is uploaded. Supported values areskip_first
,always
,never
:skip_first
- after the very first configuration version is uploaded into the workspace the run will not be triggered. But the following configurations will do. This is the default behavior.always
- runs will be triggered automatically on every upload of the configuration version.never
- configuration versions are uploaded into the workspace, but runs will not be triggered.
deletion_protection_enabled
(Boolean) Indicates if the workspace has the protection from an accidental state lost. If enabled and the workspace has resource, the deletion will not be allowed. Defaulttrue
.execution_mode
(String) Which execution mode to use. Valid values areremote
andlocal
. When set tolocal
, the workspace will be used for state storage only. Defaults toremote
(not set, backend default is used).force_latest_run
(Boolean) Set (true/false) to configure if latest new run will be automatically raised in priority. Defaultfalse
.hooks
(Block List) Settings for the workspaces custom hooks. (see below for nested schema)iac_platform
(String) The IaC platform to use for this workspace. Valid values areterraform
andopentofu
. Defaults toterraform
.module_version_id
(String) The identifier of a module version in the formatmodver-<RANDOM STRING>
. This attribute conflicts withvcs_provider_id
andvcs_repo
attributes.operations
(Boolean, Deprecated) Set (true/false) to configure workspace remote execution. Whenfalse
workspace is only used to store state. Defaults totrue
.provider_configuration
(Block Set) Provider configurations used in workspace runs. (see below for nested schema)run_operation_timeout
(Number) The number of minutes run operation can be executed before termination. Defaults to0
(not set, backend default is used).ssh_key_id
(String) The identifier of the SSH key to use for the workspace.tag_ids
(Set of String) List of tag IDs associated with the workspace.terraform_version
(String) The version of Terraform to use for this workspace. Defaults to the latest available version.terragrunt_use_run_all
(Boolean) Indicates whether the workspace usesterragrunt run-all
.terragrunt_version
(String) The version of Terragrunt the workspace performs runs on.type
(String) The type of the Scalr Workspace environment, available options:production
,staging
,testing
,development
,unmapped
.var_files
(List of String) A list of paths to the.tfvars
file(s) to be used as part of the workspace configuration.vcs_provider_id
(String) ID of VCS provider - required if vcs-repo present and vice versa, in the formatvcs-<RANDOM STRING>
.vcs_repo
(Block List, Max: 1) Settings for the workspace's VCS repository. (see below for nested schema)working_directory
(String) A relative path that Terraform will be run in. Defaults to the root of the repository""
.
Read-Only
created_by
(List of Object) Details of the user that created the workspace. (see below for nested schema)has_resources
(Boolean) The presence of active terraform resources in the current state version.id
(String) The ID of this resource.
Nested Schema for hooks
hooks
Optional:
post_apply
(String) Action that will be called after apply phase.post_plan
(String) Action that will be called after plan phase.pre_apply
(String) Action that will be called before apply phase.pre_init
(String) Action that will be called before the init phase.pre_plan
(String) Action that will be called before the plan phase.
Nested Schema for provider_configuration
provider_configuration
Required:
id
(String) The identifier of provider configuration.
Optional:
alias
(String) The alias of provider configuration.
Nested Schema for vcs_repo
vcs_repo
Required:
identifier
(String) A reference to your VCS repository in the format:org/:repo
, it refers to the organization and repository in your VCS provider.
Optional:
branch
(String) The repository branch where Terraform will be run from. If omitted, the repository default branch will be used.dry_runs_enabled
(Boolean) Set (true/false) to configure the VCS driven dry runs should run when pull request to configuration versions branch created. Defaulttrue
.ingress_submodules
(Boolean) Designates whether to clone git submodules of the VCS repository.path
(String, Deprecated) The repository subdirectory that Terraform will execute from. If omitted or submitted as an empty string, this defaults to the repository's root.trigger_patterns
(String) The gitignore-style patterns for files, whose changes will trigger a run for the workspace using this binding when the CV is created. Conflicts withtrigger_prefixes
. Iftrigger_prefixes
andtrigger_patterns
are omitted, any change inpath
will trigger a new run.trigger_prefixes
(List of String) List of paths (relative topath
), whose changes will trigger a run for the workspace using this binding when the CV is created. Conflicts withtrigger_patterns
. Iftrigger_prefixes
andtrigger_patterns
are omitted, any change inpath
will trigger a new run.
Nested Schema for created_by
created_by
Read-Only:
email
(String)full_name
(String)username
(String)
Import
Import is supported using the following syntax:
terraform import scalr_workspace.example ws-xxxxxxxxxx
Updated about 23 hours ago