Skip to content

Commit e85a17b

Browse files
authored
docs: describe list of strings (#6719)
1 parent 38d278a commit e85a17b

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

docs/templates/parameters.md

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,34 @@ provider "docker" {
4242
}
4343
```
4444

45-
The following parameter types are supported: `string`, `bool`, and `number`.
46-
4745
> For a complete list of supported parameter properties, see the
4846
> [coder_parameter Terraform reference](https://registry.terraform.io/providers/coder/coder/latest/docs/data-sources/parameter)
4947
48+
## Types
49+
50+
The following parameter types are supported: `string`, `list(string)`, `bool`, and `number`.
51+
52+
### List of strings
53+
54+
List of strings is a specific parameter type, that can't be easily mapped to the default value, which is string type.
55+
Parameters with the `list(string)` type must be converted to JSON arrays using [jsonencode](https://developer.hashicorp.com/terraform/language/functions/jsonencode)
56+
function.
57+
58+
```hcl
59+
data "coder_parameter" "security_groups" {
60+
name = "Security groups"
61+
icon = "/icon/aws.png"
62+
type = "list(string)"
63+
description = "Select appropriate security groups."
64+
mutable = true
65+
default = jsonencode([
66+
"Web Server Security Group",
67+
"Database Security Group",
68+
"Backend Security Group"
69+
])
70+
}
71+
```
72+
5073
## Options
5174

5275
A _string_ parameter can provide a set of options to limit the choice:

0 commit comments

Comments
 (0)