Skip to content

Commit 12143d1

Browse files
committed
docs
1 parent 7bfc009 commit 12143d1

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

docs/templates/parameters.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,53 @@ variable "cpu" {
196196

197197
> ⚠️ Legacy (`variable`) parameters and rich parameters can't be used in the same template.
198198
199+
### Migration
200+
201+
Terraform variables shouldn't be used for workspace scoped parameters anymore, and it's recommended to convert variables to `coder_parameter` resources. To make the migration smoother, there is a special property introduced -
202+
`legacy_variable` and `legacy_variable_name` , which can link `coder_parameter` with a legacy variable.
203+
204+
```hcl
205+
variable "legacy_cpu" {
206+
sensitive = false
207+
description = "CPU cores"
208+
default = 2
209+
}
210+
211+
data "coder_parameter" "cpu" {
212+
name = "CPU cores"
213+
type = "number"
214+
description = "Number of CPU cores"
215+
mutable = true
216+
217+
legacy_variable_name = "legacy_cpu"
218+
legacy_variable = var.legacy_cpu
219+
}
220+
```
221+
222+
#### Steps
223+
224+
1. Prepare and update a new template version:
225+
226+
- Add `coder_parameter` resource matching the legacy parameter to migrate.
227+
- Use `legacy_variable_name` and `legacy_variable` to link both.
228+
- Mark the new parameter as `mutable`, so that Coder will not block updating existing workspaces.
229+
230+
2. Update all workspaces to the uploaded template version. Coder will populate `coder_parameter`s with values from legacy parameters.
231+
3. Prepare another template version:
232+
233+
- Remove migrated variable.
234+
- Remove properties `legacy_variable` and `legacy_variable_name` from `coder_parameter`s.
235+
236+
4. Update all workspaces to the uploaded template version.
237+
5. Prepare another template version:
238+
239+
- Enable the `feature_use_managed_variables` provider flag to use managed Terraform variables for template customization. Once the flag is enabled, legacy parameters won't be used.
240+
241+
6. Update all workspaces to the uploaded template version.
242+
7. Delete legacy parameters.
243+
244+
As a template improvement, the template author can consider marking some of new `coder_parameter` resources as `mutable`.
245+
199246
## Managed Terraform variables
200247

201248
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

0 commit comments

Comments
 (0)