From e20aa4bf5d98012c4669c3fe41e770b37eb11f89 Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Thu, 9 Mar 2023 11:00:48 +0100 Subject: [PATCH 01/14] WIP --- docs/manifest.json | 6 ++ docs/templates.md | 79 ----------------------- docs/templates/parameters.md | 120 +++++++++++++++++++++++++++++++++++ 3 files changed, 126 insertions(+), 79 deletions(-) create mode 100644 docs/templates/parameters.md diff --git a/docs/manifest.json b/docs/manifest.json index ece4030883a90..dea571b079cf6 100644 --- a/docs/manifest.json +++ b/docs/manifest.json @@ -135,6 +135,12 @@ "description": "Use docker inside containerized templates", "path": "./templates/docker-in-docker.md", "icon_path": "./images/icons/docker.svg" + }, + { + "title": "Parameters", + "description": "Use parameters to customize templates", + "path": "./templates/parameters.md", + "icon_path": "./images/icons/code.svg" } ] }, diff --git a/docs/templates.md b/docs/templates.md index f84107ae11655..b063b7839f462 100644 --- a/docs/templates.md +++ b/docs/templates.md @@ -185,85 +185,6 @@ coder dotfiles -y ${var.dotfiles_uri} } ``` -### Parameters (alpha) - -> Parameters are an [alpha feature](./contributing/feature-stages.md#alpha-features). See the [Rich Parameters Milestone](https://github.com/coder/coder/milestone/11) for more details. - -Templates can contain _parameters_, which prompt the user for additional information -in the "create workspace" screen. - -![Parameters in Create Workspace screen](./images/parameters.png) - -```hcl -data "coder_parameter" "docker_host" { - name = "Region" - description = "Which region would you like to deploy to?" - icon = "/emojis/1f30f.png" - type = "string" - default = "tcp://100.94.74.63:2375" - - option { - name = "Pittsburgh, USA" - value = "tcp://100.94.74.63:2375" - icon = "/emojis/1f1fa-1f1f8.png" - } - - option { - name = "Helsinki, Finland" - value = "tcp://100.117.102.81:2375" - icon = "/emojis/1f1eb-1f1ee.png" - } - - option { - name = "Sydney, Australia" - value = "tcp://100.127.2.1:2375" - icon = "/emojis/1f1e6-1f1f9.png" - } -} -``` - -From there, parameters can be referenced during build-time: - -```hcl -provider "docker" { - host = data.coder_parameter.docker_host.value -} -``` - -> For a complete list of supported parameter types, see the -> [coder_parameter Terraform reference](https://registry.terraform.io/providers/coder/coder/latest/docs/data-sources/parameter) - -#### Legacy parameters - -Prior to Coder v0.16.0 (Jan 2023), parameters were defined via Terraform `variable` blocks. These "legacy parameters" can still be used in templates, but will be removed in April 2023. - -```hcl -variable "use_kubeconfig" { - sensitive = true # Admin (template-level) parameter - type = bool - description = <<-EOF - Use host kubeconfig? (true/false) - EOF -} - -variable "cpu" { - sensitive = false # User (workspace-level) parameter - description = "CPU (__ cores)" - default = 2 - validation { - condition = contains([ - "2", - "4", - "6", - "8" - ], var.cpu) - error_message = "Invalid cpu!" - } -} -``` - -> ⚠️ Legacy (`variable`) parameters and rich parameters cannot be used in the same template. - ### Start/stop [Learn about resource persistence in Coder](./templates/resource-persistence.md) diff --git a/docs/templates/parameters.md b/docs/templates/parameters.md new file mode 100644 index 0000000000000..71b5e447f5bca --- /dev/null +++ b/docs/templates/parameters.md @@ -0,0 +1,120 @@ +# Parameters (alpha) + +> Parameters are an [alpha feature](../contributing/feature-stages.md#alpha-features). See the [Rich Parameters Milestone](https://github.com/coder/coder/milestone/11) for more details. + +Templates can contain _parameters_, which prompt the user for additional information +in the "create workspace" screen. + +![Parameters in Create Workspace screen](../images/parameters.png) + +```hcl +data "coder_parameter" "docker_host" { + name = "Region" + description = "Which region would you like to deploy to?" + icon = "/emojis/1f30f.png" + type = "string" + default = "tcp://100.94.74.63:2375" + + option { + name = "Pittsburgh, USA" + value = "tcp://100.94.74.63:2375" + icon = "/emojis/1f1fa-1f1f8.png" + } + + option { + name = "Helsinki, Finland" + value = "tcp://100.117.102.81:2375" + icon = "/emojis/1f1eb-1f1ee.png" + } + + option { + name = "Sydney, Australia" + value = "tcp://100.127.2.1:2375" + icon = "/emojis/1f1e6-1f1f9.png" + } +} +``` + +From there, parameters can be referenced during build-time: + +```hcl +provider "docker" { + host = data.coder_parameter.docker_host.value +} +``` + +> For a complete list of supported parameter types, see the +> [coder_parameter Terraform reference](https://registry.terraform.io/providers/coder/coder/latest/docs/data-sources/parameter) + +## Optional + +A parameter is consider to be _required_ if it doesn't have the `default` property. It means that the workspace user needs to provide the parameter value before creating a workspace. + +```hcl +data "coder_parameter" "account_name" { + name = "Account name" + description = "Cloud account name" + mutable = true +} +``` + +If a parameter contains the `default` property, coder will use it when the workspace user doesn't specify the custom value. This way admins can set the `default` property to an empty value, +so that the parameter field can remain empty. + +```hcl +data "coder_parameter" "dotfiles_url" { + name = "dotfiles URL" + description = "Git repository with dotfiles" + mutable = true + default = "" +} +``` + +## Mutable + +TODO + +## Validation + +TODO + +## Migration + +TODO + +### Terraform variables + +TODO + +TODO sensitive + +## Legacy + +Prior to Coder v0.16.0 (Jan 2023), parameters were defined via Terraform `variable` blocks. These "legacy parameters" can still be used in templates, but will be removed in April 2023. + +```hcl +variable "use_kubeconfig" { + sensitive = true # Admin (template-level) parameter + type = bool + description = <<-EOF + Use host kubeconfig? (true/false) + EOF +} + +variable "cpu" { + sensitive = false # User (workspace-level) parameter + description = "CPU (__ cores)" + default = 2 + validation { + condition = contains([ + "2", + "4", + "6", + "8" + ], var.cpu) + error_message = "Invalid cpu!" + } +} +``` + +> ⚠️ Legacy (`variable`) parameters and rich parameters cannot be used in the same template. From 1c26457f1d55ed6e81af1f9613c8efcdfb578279 Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Thu, 9 Mar 2023 12:12:19 +0100 Subject: [PATCH 02/14] WIP --- docs/templates/parameters.md | 104 ++++++++++++++++++++++++++++++++--- 1 file changed, 95 insertions(+), 9 deletions(-) diff --git a/docs/templates/parameters.md b/docs/templates/parameters.md index 71b5e447f5bca..1bea184b75b1d 100644 --- a/docs/templates/parameters.md +++ b/docs/templates/parameters.md @@ -2,8 +2,7 @@ > Parameters are an [alpha feature](../contributing/feature-stages.md#alpha-features). See the [Rich Parameters Milestone](https://github.com/coder/coder/milestone/11) for more details. -Templates can contain _parameters_, which prompt the user for additional information -in the "create workspace" screen. +Templates can contain _parameters_, which prompt the user for additional information in the "create workspace" screen. ![Parameters in Create Workspace screen](../images/parameters.png) @@ -43,10 +42,43 @@ provider "docker" { } ``` -> For a complete list of supported parameter types, see the +There are few parameter types supported - string, bool, and numbers. + +> For a complete list of supported parameter properties, see the > [coder_parameter Terraform reference](https://registry.terraform.io/providers/coder/coder/latest/docs/data-sources/parameter) -## Optional +## Options + +A _string_ parameter can provide a set of options to limit the choice: + +```hcl +data "coder_parameter" "docker_host" { + name = "Region" + description = "Which region would you like to deploy to?" + type = "string" + default = "tcp://100.94.74.63:2375" + + option { + name = "Pittsburgh, USA" + value = "tcp://100.94.74.63:2375" + icon = "/emojis/1f1fa-1f1f8.png" + } + + option { + name = "Helsinki, Finland" + value = "tcp://100.117.102.81:2375" + icon = "/emojis/1f1eb-1f1ee.png" + } + + option { + name = "Sydney, Australia" + value = "tcp://100.127.2.1:2375" + icon = "/emojis/1f1e6-1f1f9.png" + } +} +``` + +## Required and optional parameters A parameter is consider to be _required_ if it doesn't have the `default` property. It means that the workspace user needs to provide the parameter value before creating a workspace. @@ -58,8 +90,17 @@ data "coder_parameter" "account_name" { } ``` -If a parameter contains the `default` property, coder will use it when the workspace user doesn't specify the custom value. This way admins can set the `default` property to an empty value, -so that the parameter field can remain empty. +If a parameter contains the `default` property, coder will use it when the workspace user doesn't specify the custom value: + +```hcl +data "coder_parameter" "base_image" { + name = "Base image" + description = "Base machine image to download" + default = "ubuntu:latest" +} +``` + +Admins can also set the `default` property to an empty value, so that the parameter field can remain empty: ```hcl data "coder_parameter" "dotfiles_url" { @@ -70,13 +111,58 @@ data "coder_parameter" "dotfiles_url" { } ``` -## Mutable +## Mutability -TODO +Immutable parameters can be only set before workspace creation. The idea is to prevent users from modifying fragile or persistent workspace resources like volumes, regions, etc.: + +```hcl +data "coder_parameter" "region" { + name = "Region" + description = "Region where the workspace is hosted" + mutable = false + default = "us-east-1" +} +``` + +It is allowed to modify the mutability state anytime. In case of emergency, admins can temporarily allow for changing immutable parameters to fix an operational issue, but it is not +advised to overuse this opportunity. ## Validation -TODO +Rich parameters support multiple validation modes - min, max, monotonic numbers, and regular expressions. + +### Number + +A _number_ parameter can be limited to boundaries - min, max. Additionally, the monotonicity (`increasing` or `decreasing`) between current parameter value and the new one can be verified too. +Monotonicity can be enabled for resources that can't be shrinked without implications, for instance - disk volume size. + +```hcl +data "coder_parameter" "instances" { + name = "Instances" + type = "number" + description = "Number of compute instances" + validation { + min = 1 + max = 8 + monotonic = "increasing" + } +} +``` + +### String + +A _string_ parameter can have a regular expression defined to make sure that the parameter value matches the pattern. The `regex` property requires a corresponding `error` property. + +```hcl +data "coder_parameter" "project_id" { + name = "Project ID" + description = "Alpha-numeric project ID" + validation { + regex = "^[a-z0-9]+$" + error = "Unfortunately, it isn't a valid project ID" + } +} +``` ## Migration From 2a4f546155f6a0e7de29e00528778a72171902f4 Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Thu, 9 Mar 2023 13:00:52 +0100 Subject: [PATCH 03/14] docs: describe rich parameters --- docs/templates/parameters.md | 60 ++++++++++++++++++++++++++---------- 1 file changed, 44 insertions(+), 16 deletions(-) diff --git a/docs/templates/parameters.md b/docs/templates/parameters.md index 1bea184b75b1d..4eb6d5ac52606 100644 --- a/docs/templates/parameters.md +++ b/docs/templates/parameters.md @@ -42,7 +42,7 @@ provider "docker" { } ``` -There are few parameter types supported - string, bool, and numbers. +There are a few parameter types supported - string, bool, and numbers. > For a complete list of supported parameter properties, see the > [coder_parameter Terraform reference](https://registry.terraform.io/providers/coder/coder/latest/docs/data-sources/parameter) @@ -80,7 +80,7 @@ data "coder_parameter" "docker_host" { ## Required and optional parameters -A parameter is consider to be _required_ if it doesn't have the `default` property. It means that the workspace user needs to provide the parameter value before creating a workspace. +A parameter is considered to be _required_ if it doesn't have the `default` property. It means that the workspace user needs to provide the parameter value before creating a workspace. ```hcl data "coder_parameter" "account_name" { @@ -100,7 +100,7 @@ data "coder_parameter" "base_image" { } ``` -Admins can also set the `default` property to an empty value, so that the parameter field can remain empty: +Admins can also set the `default` property to an empty value so that the parameter field can remain empty: ```hcl data "coder_parameter" "dotfiles_url" { @@ -133,8 +133,8 @@ Rich parameters support multiple validation modes - min, max, monotonic numbers, ### Number -A _number_ parameter can be limited to boundaries - min, max. Additionally, the monotonicity (`increasing` or `decreasing`) between current parameter value and the new one can be verified too. -Monotonicity can be enabled for resources that can't be shrinked without implications, for instance - disk volume size. +A _number_ parameter can be limited to boundaries - min, max. Additionally, the monotonicity (`increasing` or `decreasing`) between the current parameter value and the new one can be verified too. +Monotonicity can be enabled for resources that can't be shrunk without implications, for instance - disk volume size. ```hcl data "coder_parameter" "instances" { @@ -164,16 +164,6 @@ data "coder_parameter" "project_id" { } ``` -## Migration - -TODO - -### Terraform variables - -TODO - -TODO sensitive - ## Legacy Prior to Coder v0.16.0 (Jan 2023), parameters were defined via Terraform `variable` blocks. These "legacy parameters" can still be used in templates, but will be removed in April 2023. @@ -203,4 +193,42 @@ variable "cpu" { } ``` -> ⚠️ Legacy (`variable`) parameters and rich parameters cannot be used in the same template. +> ⚠️ Legacy (`variable`) parameters and rich parameters should not be used in the same template unless it is only for migration purposes. + +## Migration + +Terraform variables shouldn't be used for parameters anymore, and it's recommended to convert variables to `coder_parameter` resources. To make the migration smoother, there was a special property introduced - +`legacy_variable`, which can link `coder_parameter` with a legacy variable. + +```hcl +variable "legacy_cpu" { + sensitive = false + description = "CPU cores" + default = 2 +} + +data "coder_parameter" "cpu" { + name = "CPU cores" + type = "number" + description = "Number of CPU cores" + + legacy_variable = var.legacy_cpu +} +``` + +Once users update their workspaces to the new template revision with rich parameters, the template admin can remove legacy variables, and strip `legacy_variable` properties. + +### Managed Terraform variables + +As parameters are intended to be used only for workspace customization purposes, Terraform variables can be freely managed by the admin to build templates. Workspace users are not able to modify +template variables. + +The admin user can enable managed Terraform variables mode by specifying the following flag: + +```hcl +provider "coder" { + feature_use_managed_variables = "true" +} +``` + +Once it's defined, coder will allow for modifying variables by using CLI and UI forms, but it will not be possible to use legacy parameters. From 3509be632080f58bbf538722586d1e2e511f625d Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Thu, 9 Mar 2023 16:57:01 +0100 Subject: [PATCH 04/14] Update docs/templates/parameters.md Co-authored-by: Cian Johnston --- docs/templates/parameters.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/templates/parameters.md b/docs/templates/parameters.md index 4eb6d5ac52606..591bd8099d41c 100644 --- a/docs/templates/parameters.md +++ b/docs/templates/parameters.md @@ -42,7 +42,7 @@ provider "docker" { } ``` -There are a few parameter types supported - string, bool, and numbers. +The following parameter types are supported: `string`, `bool`, and `number`. > For a complete list of supported parameter properties, see the > [coder_parameter Terraform reference](https://registry.terraform.io/providers/coder/coder/latest/docs/data-sources/parameter) From b7dac53eedb8e275abddfe8aa51d52bb049ac0fc Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Thu, 9 Mar 2023 16:57:10 +0100 Subject: [PATCH 05/14] Update docs/templates/parameters.md Co-authored-by: Cian Johnston --- docs/templates/parameters.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/templates/parameters.md b/docs/templates/parameters.md index 591bd8099d41c..49cd2f366fb16 100644 --- a/docs/templates/parameters.md +++ b/docs/templates/parameters.md @@ -90,7 +90,8 @@ data "coder_parameter" "account_name" { } ``` -If a parameter contains the `default` property, coder will use it when the workspace user doesn't specify the custom value: +If a parameter contains the `default` property, Coder will use this value + if the user does not specify any: ```hcl data "coder_parameter" "base_image" { From d7cfc5d01330e746001b5aa1b93630577408d9b2 Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Thu, 9 Mar 2023 16:57:17 +0100 Subject: [PATCH 06/14] Update docs/templates/parameters.md Co-authored-by: Cian Johnston --- docs/templates/parameters.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/templates/parameters.md b/docs/templates/parameters.md index 49cd2f366fb16..cd14f8e7b59d9 100644 --- a/docs/templates/parameters.md +++ b/docs/templates/parameters.md @@ -221,7 +221,7 @@ Once users update their workspaces to the new template revision with rich parame ### Managed Terraform variables -As parameters are intended to be used only for workspace customization purposes, Terraform variables can be freely managed by the admin to build templates. Workspace users are not able to modify +As parameters are intended to be used only for workspace customization purposes, Terraform variables can be freely managed by the template author to build templates. Workspace users are not able to modify template variables. The admin user can enable managed Terraform variables mode by specifying the following flag: From 0ffd0846932fbfa14651bb1cf17e7829d2662bc6 Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Thu, 9 Mar 2023 16:58:05 +0100 Subject: [PATCH 07/14] Update docs/templates/parameters.md Co-authored-by: Cian Johnston --- docs/templates/parameters.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/templates/parameters.md b/docs/templates/parameters.md index cd14f8e7b59d9..799e241c5ea6a 100644 --- a/docs/templates/parameters.md +++ b/docs/templates/parameters.md @@ -80,7 +80,7 @@ data "coder_parameter" "docker_host" { ## Required and optional parameters -A parameter is considered to be _required_ if it doesn't have the `default` property. It means that the workspace user needs to provide the parameter value before creating a workspace. +A parameter is considered to be _required_ if it doesn't have the `default` property. The user **must** provide a value to this parameter before creating a workspace. ```hcl data "coder_parameter" "account_name" { From a432b022db587b036e206b3f4b905faf1aef8cbb Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Thu, 9 Mar 2023 16:58:12 +0100 Subject: [PATCH 08/14] Update docs/templates/parameters.md Co-authored-by: Cian Johnston --- docs/templates/parameters.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/templates/parameters.md b/docs/templates/parameters.md index 799e241c5ea6a..47ce606e287e0 100644 --- a/docs/templates/parameters.md +++ b/docs/templates/parameters.md @@ -217,7 +217,7 @@ data "coder_parameter" "cpu" { } ``` -Once users update their workspaces to the new template revision with rich parameters, the template admin can remove legacy variables, and strip `legacy_variable` properties. +Once users update their workspaces to the new template revision with rich parameters, template authors can remove legacy variables, and strip `legacy_variable` properties. ### Managed Terraform variables From ec0f774cec8e4ea3c8252f53cd9439f72a825ee5 Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Thu, 9 Mar 2023 16:58:19 +0100 Subject: [PATCH 09/14] Update docs/templates/parameters.md Co-authored-by: Cian Johnston --- docs/templates/parameters.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/templates/parameters.md b/docs/templates/parameters.md index 47ce606e287e0..638536d5cf3a8 100644 --- a/docs/templates/parameters.md +++ b/docs/templates/parameters.md @@ -2,7 +2,7 @@ > Parameters are an [alpha feature](../contributing/feature-stages.md#alpha-features). See the [Rich Parameters Milestone](https://github.com/coder/coder/milestone/11) for more details. -Templates can contain _parameters_, which prompt the user for additional information in the "create workspace" screen. +Templates can contain _parameters_, which allow prompting the user for additional information when creating workspaces in both the UI and CLI. ![Parameters in Create Workspace screen](../images/parameters.png) From 49fd5b3314914c98ebee10fa1d1e13c58940f9d4 Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Thu, 9 Mar 2023 16:58:39 +0100 Subject: [PATCH 10/14] Update docs/templates/parameters.md Co-authored-by: Cian Johnston --- docs/templates/parameters.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/templates/parameters.md b/docs/templates/parameters.md index 638536d5cf3a8..61f62fb0513c4 100644 --- a/docs/templates/parameters.md +++ b/docs/templates/parameters.md @@ -224,7 +224,7 @@ Once users update their workspaces to the new template revision with rich parame As parameters are intended to be used only for workspace customization purposes, Terraform variables can be freely managed by the template author to build templates. Workspace users are not able to modify template variables. -The admin user can enable managed Terraform variables mode by specifying the following flag: +The template author can enable managed Terraform variables mode by specifying the following flag: ```hcl provider "coder" { From f2f9bee562056c0210abca917e28b82593c23113 Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Thu, 9 Mar 2023 16:58:45 +0100 Subject: [PATCH 11/14] Update docs/templates/parameters.md Co-authored-by: Cian Johnston --- docs/templates/parameters.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/templates/parameters.md b/docs/templates/parameters.md index 61f62fb0513c4..b6282df703fef 100644 --- a/docs/templates/parameters.md +++ b/docs/templates/parameters.md @@ -125,7 +125,7 @@ data "coder_parameter" "region" { } ``` -It is allowed to modify the mutability state anytime. In case of emergency, admins can temporarily allow for changing immutable parameters to fix an operational issue, but it is not +It is allowed to modify the mutability state anytime. In case of emergency, template authors can temporarily allow for changing immutable parameters to fix an operational issue, but it is not advised to overuse this opportunity. ## Validation From f2d95b58d2ab47213720f80d5caff9846861f45e Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Thu, 9 Mar 2023 16:58:52 +0100 Subject: [PATCH 12/14] Update docs/templates/parameters.md Co-authored-by: Cian Johnston --- docs/templates/parameters.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/templates/parameters.md b/docs/templates/parameters.md index b6282df703fef..cc0c311bdf8c6 100644 --- a/docs/templates/parameters.md +++ b/docs/templates/parameters.md @@ -171,7 +171,7 @@ Prior to Coder v0.16.0 (Jan 2023), parameters were defined via Terraform `variab ```hcl variable "use_kubeconfig" { - sensitive = true # Admin (template-level) parameter + sensitive = true # Template-level parameter (not editable when creating a workspace) type = bool description = <<-EOF Use host kubeconfig? (true/false) From dee3075e9bcca41cfd0955c1275385b97224cd9e Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Thu, 9 Mar 2023 17:02:54 +0100 Subject: [PATCH 13/14] Strip migration --- docs/templates/parameters.md | 29 +++-------------------------- 1 file changed, 3 insertions(+), 26 deletions(-) diff --git a/docs/templates/parameters.md b/docs/templates/parameters.md index cc0c311bdf8c6..dc96d9dc19732 100644 --- a/docs/templates/parameters.md +++ b/docs/templates/parameters.md @@ -90,7 +90,7 @@ data "coder_parameter" "account_name" { } ``` -If a parameter contains the `default` property, Coder will use this value +If a parameter contains the `default` property, Coder will use this value if the user does not specify any: ```hcl @@ -194,32 +194,9 @@ variable "cpu" { } ``` -> ⚠️ Legacy (`variable`) parameters and rich parameters should not be used in the same template unless it is only for migration purposes. +> ⚠️ Legacy (`variable`) parameters and rich parameters can't be used in the same template. -## Migration - -Terraform variables shouldn't be used for parameters anymore, and it's recommended to convert variables to `coder_parameter` resources. To make the migration smoother, there was a special property introduced - -`legacy_variable`, which can link `coder_parameter` with a legacy variable. - -```hcl -variable "legacy_cpu" { - sensitive = false - description = "CPU cores" - default = 2 -} - -data "coder_parameter" "cpu" { - name = "CPU cores" - type = "number" - description = "Number of CPU cores" - - legacy_variable = var.legacy_cpu -} -``` - -Once users update their workspaces to the new template revision with rich parameters, template authors can remove legacy variables, and strip `legacy_variable` properties. - -### Managed Terraform variables +## Managed Terraform variables As parameters are intended to be used only for workspace customization purposes, Terraform variables can be freely managed by the template author to build templates. Workspace users are not able to modify template variables. From b17167787dc6067e3129f98061f09b4bd0996284 Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Thu, 9 Mar 2023 17:06:04 +0100 Subject: [PATCH 14/14] Fix --- docs/templates/parameters.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/templates/parameters.md b/docs/templates/parameters.md index dc96d9dc19732..6ae22a47430c4 100644 --- a/docs/templates/parameters.md +++ b/docs/templates/parameters.md @@ -91,7 +91,7 @@ data "coder_parameter" "account_name" { ``` If a parameter contains the `default` property, Coder will use this value - if the user does not specify any: +if the user does not specify any: ```hcl data "coder_parameter" "base_image" {