Skip to content

Latest commit

 

History

History
101 lines (73 loc) · 5.87 KB

File metadata and controls

101 lines (73 loc) · 5.87 KB
page_title coder_workspace_preset Data Source - terraform-provider-coder
subcategory
description 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"
  description = "Example description of what this preset does."
  icon        = "/icon/example.svg"
  parameters = {
    (data.coder_parameter.example.name) = "us-central1-a"
    (data.coder_parameter.ami.name)     = "ami-xxxxxxxx"
  }
}

# Example of a default preset that will be pre-selected for users
data "coder_workspace_preset" "standard" {
  name        = "Standard"
  description = "A workspace preset with medium compute in the US West region."
  icon        = "/icon/standard.svg"
  default     = true
  parameters = {
    (data.coder_parameter.instance_type.name) = "t3.medium"
    (data.coder_parameter.region.name)        = "us-west-2"
  }
}

Schema

Required

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

Optional

  • default (Boolean) Whether this preset should be selected by default when creating a workspace. Only one preset per template can be marked as default.
  • description (String) Describe what this preset does.
  • icon (String) A URL to an icon that will display in the dashboard. View built-in icons here. Use a built-in icon with "${data.coder_workspace.me.access_url}/icon/<path>".
  • 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 DOM MONTH DAY-OF-WEEK" where HOUR is 0-23, DOM (day-of-month) is 1-31, MONTH is 1-12, and DAY-OF-WEEK is 0-6 (Sunday-Saturday). The minute field must be "*" to ensure the schedule covers entire hours rather than specific minute intervals.
  • instances (Number) The number of prebuild instances to maintain during this schedule period.