From facc77447ba94012640514b04866c72c252d12f2 Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Wed, 22 Mar 2023 10:24:50 +0100 Subject: [PATCH] docs: describe list of strings --- docs/templates/parameters.md | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/docs/templates/parameters.md b/docs/templates/parameters.md index a14245cad9124..ecd81751ccc1d 100644 --- a/docs/templates/parameters.md +++ b/docs/templates/parameters.md @@ -42,11 +42,34 @@ provider "docker" { } ``` -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) +## Types + +The following parameter types are supported: `string`, `list(string)`, `bool`, and `number`. + +### List of strings + +List of strings is a specific parameter type, that can't be easily mapped to the default value, which is string type. +Parameters with the `list(string)` type must be converted to JSON arrays using [jsonencode](https://developer.hashicorp.com/terraform/language/functions/jsonencode) +function. + +```hcl +data "coder_parameter" "security_groups" { + name = "Security groups" + icon = "/icon/aws.png" + type = "list(string)" + description = "Select appropriate security groups." + mutable = true + default = jsonencode([ + "Web Server Security Group", + "Database Security Group", + "Backend Security Group" + ]) +} +``` + ## Options A _string_ parameter can provide a set of options to limit the choice: