page_title | subcategory | description |
---|---|---|
coderd_template Resource - terraform-provider-coderd |
A Coder template.
Logs from building template versions can be optionally streamed from the provisioner by setting the TF_LOG environment variable to INFO or higher. |
A Coder template.
Logs from building template versions can be optionally streamed from the provisioner by setting the TF_LOG
environment variable to INFO
or higher.
// Provider populated from environment variables
provider "coderd" {}
// Can be populated using an environment variable, or an external datasource script
variable "COMMIT_SHA" {
type = string
}
resource "coderd_user" "coder1" {
username = "coder1"
name = "Coder One"
email = "[email protected]"
}
resource "coderd_template" "ubuntu-main" {
name = "ubuntu-main"
description = "The main template for developing on Ubuntu."
versions = [
{
name = "stable-${var.COMMIT_SHA}"
description = "The stable version of the template."
directory = "./stable-template"
},
{
name = "staging-${var.COMMIT_SHA}"
description = "The staging version of the template."
directory = "./staging-template"
}
]
acl = {
users = [{
id = coderd_user.coder1.id
role = "admin"
}]
groups = []
}
}
name
(String) The name of the template.versions
(Attributes List) (see below for nested schema)
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-stop 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.max_port_share_level
(String) (Enterprise) The maximum port share level for workspaces created from this template. Defaults toowner
on an Enterprise deployment, orpublic
otherwise.organization_id
(String) The ID of the organization. Defaults to the provider's default organizationrequire_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.
id
(String) The ID of the template.
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, or thetf_vars
attribute are updated.provisioner_tags
(Map of String) Provisioner tags for the template version.tf_vars
(Map of String) Terraform variables for the template version.
Read-Only:
directory_hash
(String)id
(String)
Required:
groups
(Attributes Set) (see below for nested schema)users
(Attributes Set) (see below for nested schema)
Required:
id
(String)role
(String)
Required:
id
(String)role
(String)
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.
Import is supported using the following syntax:
# The ID supplied can be either a template UUID retrieved via the API
# or a fully qualified name: `<organization-name>/<template-name>`.
$ terraform import coderd_template.example coder/dogfood
Once imported, you'll need to manually declare in your config:
- The
versions
list, in order to specify the source directories for new versions of the template. - (Enterprise) The
acl
attribute, in order to specify the users and groups that have access to the template.
Alternatively, in Terraform v1.5.0 and later, an import
block can be used:
import {
to = coderd_template.example
id = "coder/dogfood"
}