scalr_workspace
Resource scalr_workspace
scalr_workspace
Manage the state of workspaces in Scalr. Create, update and destroy
Example Usage
Basic usage:
VCS-driven
data "scalr_vcs_provider" test {
name = "vcs-name"
account_id = "acc-xxxx" # in case a user has access to more than one account
}
data "scalr_environment" test {
name = "env-name"
account_id = "acc-xxxx" # in case a user has access to more than one account
}
resource "scalr_workspace" "vcs-driven" {
name = "my-workspace-name"
environment_id = data.scalr_environment.test.id
vcs_provider_id = data.scalr_vcs_provider.test.id
working_directory = "example/path"
vcs_repo {
identifier = "org/repo"
branch = "dev"
trigger_prefixes = ["stage", "prod"]
}
provider_configuration {
id = "pcfg-1"
alias = "us_east1"
}
provider_configuration {
id = "pcfg-2"
alias = "us_east2"
}
}
Module-driven
data "scalr_environment" test {
name = "env-name"
# account_id = "acc-xxxx" # Optional, in case a user has access to more than one account
}
locals {
modules = {
"${data.scalr_environment.test.id}": "module-name/provider", # environment-level module will be selected
"${data.scalr_environment.test.account_id}": "module-name/provider", # account-level module will be selected
}
}
data "scalr_module_version" "module-driven" {
for_each = local.modules
source = "${each.key}/${each.value}"
# version = "1.0.0" # Optional, if omitted, the latest module version is selected
}
resource "scalr_workspace" "example" {
for_each = data.scalr_module_version.example
environment_id = data.scalr_environment.test.id
name = replace(each.value.source, "/", "-")
module_version_id = each.value.id
}
CLI-driven
data "scalr_environment" test {
name = "env-name"
# account_id = "acc-xxxx" # Optional, in case a user has access to more than one account
}
resource "scalr_workspace" "cli-driven" {
name = "my-workspace-name"
environment_id = data.scalr_environment.test.id
working_directory = "example/path"
}
Argument Reference
-
name
- (Required) Name of the workspace. -
environment_id
- (Required) ID of the environment, in the formatenv-<RANDOM STRING>
. -
auto_apply
- (Optional) Set (true/false) to configure ifterraform apply
should automatically run whenterraform plan
ends without error. Defaultfalse
. -
force_latest_run
- (Optional) Set (true/false) if the latest run will have the top priority and all pending runs will be canceled. Defaultfalse
. -
operations
- Deprecated. Useexecution-mode
instead. -
auto_queue_runs
- Indicates if runs have to be queued automatically when a new configuration version is uploaded.Supported values are
skip_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. This is the default behavior.always
- runs will be triggered automatically on every upload of the configuration version, including the first.never
- configuration versions are uploaded into the workspace, but runs will not be triggered.
-
execution_mode
- (Optional) 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). -
terraform_version
- (Optional) The version of Terraform to use for this workspace. Defaults to the latest available version. -
working_directory
- (Optional) A relative path that Terraform will be run in. Defaults to the root of the repository""
. -
var_files
- (Optional) A list of paths to the.tfvars
file(s) to be used as part of the workspace configuration. -
run_operation_timeout
- (Optional) The number of minutes run operation can be executed before termination. Defaults to0
(not set, backend default is used). -
module_version_id
- (Optional) The identifier of a module version in the formatmodver-<RANDOM STRING>
. This attribute conflicts withvcs_provider_id
andvcs_repo
attributes. -
agent_pool_id
- (Optional) The identifier of an agent pool in the formatapool-<RANDOM STRING>
. -
tag_ids
- (Optional) List of tag IDs associated with the workspace. -
deletion_protection_enabled
- (Optional) Set (true/false) to configure whether to prevent deletion when the workspace has resources. Defaulttrue
. -
vcs_provider_id
- (Optional) ID of the vcs provider - required if the vcs-repo present and vice versa, in the formatvcs-<RANDOM STRING>
-
vcs_repo
- (Optional) Settings for the workspace's VCS repository.The
vcs_repo
block supports:identifier
- (Required) A reference to your VCS repository in the format:org/:repo
, it refers to the organization and repository in your VCS provider.branch
- (Optional) The repository branch where Terraform will be run from. Defaultmaster
.path
- (Optional)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_prefixes
- (Optional) List of paths (relative topath
), whose changes will trigger a run for the workspace using this binding when the CV is created. If omitted or submitted as an empty list, any change inpath
will trigger a new run.dry_runs_enabled
- (Optional) Set (true/false) to configure the VCS driven dry runs should run when a pull request to the configuration versions branch is created. Defaulttrue
ingress_submodules
- (Optional) Set (true/false) to clone git submodules of the VCS repository. Defaultfalse
.
-
hooks
- (Optional) Settings for the workspaces custom hooks.The
hooks
block supports:pre_init
- (Optional) Action that will be called before the init phasepre_plan
- (Optional) Action that will be called before the plan phasepost_plan
- (Optional) Action that will be called after the plan phasepre_apply
- (Optional) Action that will be called before apply phasepost_apply
- (Optional) Action that will be called after apply phase
-
provider_configuration
- (Optional) Provider configurations used in workspace runs.The
provider_configuration
block supports:id
- (Required) The identifier of the provider configurationalias
- (Optional) The alias of the provider configuration
Attribute Reference
All arguments plus:
id
- The workspace ID, in the formatws-<RANDOM STRING>
.created_by
- Details of the user that created the workspace.has_resources
- The presence of active terraform resources in the current state version.
The created_by
block contains:
username
- Username of the creator.email
- Email address of creator.full_name
- Full name of the creator.
Import
To import workspaces use workspace ID as the import ID. For example:
terraform import scalr_workspace.example ws-t47s1aa6s4boubg
Updated 29 days ago