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

ced04dc · Sep 3, 2024

History

History
165 lines (118 loc) · 6.81 KB

File metadata and controls

165 lines (118 loc) · 6.81 KB
page_title subcategory description
coderd_template Resource - terraform-provider-coderd
A Coder template. Logs from building template versions are streamed from the provisioner when the TF_LOG environment variable is INFO or higher. When importing, the ID supplied can be either a template UUID retrieved via the API or <organization-name>/<template-name>.

coderd_template (Resource)

A Coder template.

Logs from building template versions are streamed from the provisioner when the TF_LOG environment variable is INFO or higher.

When importing, the ID supplied can be either a template UUID retrieved via the API or <organization-name>/<template-name>.

Example Usage

// Provider populated from environment variables
provider "coderd" {}

// Get the commit SHA of the configuration's git repository
variable "TFC_CONFIGURATION_VERSION_GIT_COMMIT_SHA" {
  type = string
}

resource "coderd_user" "coder1" {
  username = "coder1"
  name     = "Coder One"
  email    = "coder1@coder.com"
}

resource "coderd_template" "ubuntu-main" {
  name        = "ubuntu-main"
  description = "The main template for developing on Ubuntu."
  versions = [
    {
      name        = "stable-${var.TFC_CONFIGURATION_VERSION_GIT_COMMIT_SHA}"
      description = "The stable version of the template."
      directory   = "./stable-template"
    },
    {
      name        = "staging-${var.TFC_CONFIGURATION_VERSION_GIT_COMMIT_SHA}"
      description = "The staging version of the template."
      directory   = "./staging-template"
    }
  ]
  acl = {
    users = [{
      id   = coderd_user.coder1.id
      role = "admin"
    }]
    groups = []
  }
}

Schema

Required

Optional

  • acl (Attributes) (Enterprise) Access control list for the template. If null, ACL policies will not be added, removed, or read by Terraform. (see below for nested schema)
  • activity_bump_ms (Number) The activity bump duration for all workspaces created from this template, in milliseconds. Defaults to one hour.
  • allow_user_auto_start (Boolean) (Enterprise) Whether users can auto-start workspaces created from this template. Defaults to true.
  • allow_user_auto_stop (Boolean) (Enterprise) Whether users can auto-start workspaces created from this template. Defaults to true.
  • allow_user_cancel_workspace_jobs (Boolean) Whether users can cancel in-progress workspace jobs using this template. Defaults to true.
  • auto_start_permitted_days_of_week (Set of String) (Enterprise) List of days of the week in which autostart is allowed to happen, for all workspaces created from this template. Defaults to all days. If no days are specified, autostart is not allowed.
  • auto_stop_requirement (Attributes) (Enterprise) The auto-stop requirement for all workspaces created from this template. (see below for nested schema)
  • default_ttl_ms (Number) The default time-to-live for all workspaces created from this template, in milliseconds.
  • deprecation_message (String) If set, the template will be marked as deprecated with the provided message and users will be blocked from creating new workspaces from it. Does nothing if set when the resource is created.
  • description (String) A description of the template.
  • display_name (String) The display name of the template. Defaults to the template name.
  • failure_ttl_ms (Number) (Enterprise) The max lifetime before Coder stops all resources for failed workspaces created from this template, in milliseconds.
  • icon (String) Relative path or external URL that specifes an icon to be displayed in the dashboard.
  • organization_id (String) The ID of the organization. Defaults to the provider's default organization
  • require_active_version (Boolean) (Enterprise) Whether workspaces must be created from the active version of this template. Defaults to false.
  • time_til_dormant_autodelete_ms (Number) (Enterprise) The max lifetime before Coder permanently deletes dormant workspaces created from this template.
  • time_til_dormant_ms (Number) (Enterprise) The max lifetime before Coder locks inactive workspaces created from this template, in milliseconds.

Read-Only

  • id (String) The ID of the template.

Nested Schema for versions

Required:

  • directory (String) A path to the directory to create the template version from. Changes in the directory contents will trigger the creation of a new template version.

Optional:

  • active (Boolean) Whether this version is the active version of the template. Only one version can be active at a time.
  • message (String) A message describing the changes in this version of the template. Messages longer than 72 characters will be truncated.
  • name (String) The name of the template version. Automatically generated if not provided. If provided, the name must change each time the directory contents are updated.
  • provisioner_tags (Attributes Set) Provisioner tags for the template version. (see below for nested schema)
  • tf_vars (Attributes Set) Terraform variables for the template version. (see below for nested schema)

Read-Only:

  • directory_hash (String)
  • id (String)

Nested Schema for versions.provisioner_tags

Required:

  • name (String)
  • value (String)

Nested Schema for versions.tf_vars

Required:

  • name (String)
  • value (String)

Nested Schema for acl

Required:

Nested Schema for acl.groups

Required:

  • id (String)
  • role (String)

Nested Schema for acl.users

Required:

  • id (String)
  • role (String)

Nested Schema for auto_stop_requirement

Optional:

  • days_of_week (Set of String) List of days of the week on which restarts are required. Restarts happen within the user's quiet hours (in their configured timezone). If no days are specified, restarts are not required.
  • weeks (Number) Weeks is the number of weeks between required restarts. Weeks are synced across all workspaces (and Coder deployments) using modulo math on a hardcoded epoch week of January 2nd, 2023 (the first Monday of 2023). Values of 0 or 1 indicate weekly restarts. Values of 2 indicate fortnightly restarts, etc.