Skip to content

Files

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Latest commit

68bcb2f · Jun 18, 2025

History

History
84 lines (57 loc) · 4.82 KB

workspace_preset.md

File metadata and controls

84 lines (57 loc) · 4.82 KB
page_title subcategory description
coder_workspace_preset Data Source - terraform-provider-coder
Use this data source to predefine common configurations for coder workspaces. Users will have the option to select a defined preset, which will automatically apply the selected configuration. Any parameters defined in the preset will be applied to the workspace. Parameters that are defined by the template but not defined by the preset will still be configurable when creating a workspace.

coder_workspace_preset (Data Source)

Use this data source to predefine common configurations for coder workspaces. Users will have the option to select a defined preset, which will automatically apply the selected configuration. Any parameters defined in the preset will be applied to the workspace. Parameters that are defined by the template but not defined by the preset will still be configurable when creating a workspace.

Example Usage

provider "coder" {}

# presets can be used to predefine common configurations for workspaces
# Parameters are referenced by their name. Each parameter must be defined in the preset.
# Values defined by the preset must pass validation for the parameter.
# See the coder_parameter data source's documentation for examples of how to define
# parameters like the ones used below.
data "coder_workspace_preset" "example" {
  name = "example"
  parameters = {
    (data.coder_parameter.example.name) = "us-central1-a"
    (data.coder_parameter.ami.name)     = "ami-xxxxxxxx"
  }
}

Schema

Required

  • name (String) The name of the workspace preset.

Optional

  • parameters (Map of String) Workspace parameters that will be set by the workspace preset. For simple templates that only need prebuilds, you may define a preset with zero parameters. Because workspace parameters may change between Coder template versions, preset parameters are allowed to define values for parameters that do not exist in the current template version.
  • prebuilds (Block Set, Max: 1) Configuration for prebuilt workspaces associated with this preset. Coder will maintain a pool of standby workspaces based on this configuration. When a user creates a workspace using this preset, they are assigned a prebuilt workspace instead of waiting for a new one to build. See prebuilt workspace documentation here (see below for nested schema)

Read-Only

  • id (String) The preset ID is automatically generated and may change between runs. It is recommended to use the name attribute to identify the preset.

Nested Schema for prebuilds

Required:

  • instances (Number) The number of workspaces to keep in reserve for this preset.

Optional:

  • expiration_policy (Block Set, Max: 1) Configuration block that defines TTL (time-to-live) behavior for prebuilds. Use this to automatically invalidate and delete prebuilds after a certain period, ensuring they stay up-to-date. (see below for nested schema)
  • scheduling (Block List, Max: 1) Configuration block that defines scheduling behavior for prebuilds. Use this to automatically adjust the number of prebuild instances based on a schedule. (see below for nested schema)

Nested Schema for prebuilds.expiration_policy

Required:

  • ttl (Number) Time in seconds after which an unclaimed prebuild is considered expired and eligible for cleanup.

Nested Schema for prebuilds.scheduling

Required:

Nested Schema for prebuilds.scheduling.schedule

Required:

  • cron (String) A cron expression that defines when this schedule should be active. The cron expression must be in the format "* HOUR * * DAY-OF-WEEK" where HOUR is 0-23 and DAY-OF-WEEK is 0-6 (Sunday-Saturday). The minute, day-of-month, and month fields must be "*".
  • instances (Number) The number of prebuild instances to maintain during this schedule period.