You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -284,12 +284,14 @@ data "coder_parameter" "cpu_cores" {
284
284
}
285
285
```
286
286
287
-
<!--### Secrets
287
+
### Secrets
288
288
289
289
Sliders can be used for configuration on a linear scale, like resource allocation. The `validation` block is used to clamp the minimum and maximum values for the parameter.
290
290
291
291
[Try secret parameters on the Parameters Playground](https://playground.coder.app/parameters/wmiP7FM3Za).
292
292
293
+
Note: this text may not be properly hidden in the Playground. The `mask_input` styling attribute is supported in v2.24.0 and onward.
294
+
293
295
```terraform
294
296
data "coder_parameter" "private_api_key" {
295
297
name = "private_api_key"
@@ -302,10 +304,10 @@ data "coder_parameter" "private_api_key" {
302
304
default = "privatekey"
303
305
304
306
styling = jsonencode({
305
-
maskInput = true
307
+
mask_input = true
306
308
})
307
309
}
308
-
```-->
310
+
```
309
311
310
312
311
313
</div>
@@ -549,35 +551,159 @@ data "coder_parameter" "region" {
549
551
550
552
</div>
551
553
554
+
## Identity-aware parameters (Premium)
555
+
556
+
Premium users can leverage our roles and groups to conditionally expose or change parameters based on user identity. This is helpful for establishing governance policy directly in the workspace creation form, rather than creating multiple templates to manage RBAC.
557
+
558
+
User identity is referenced in Terraform by reading the [`coder_workspace_owner`](https://registry.terraform.io/providers/coder/coder/latest/docs/data-sources/workspace_owner) data source.
559
+
552
560
<divclass="tabs">
553
561
554
562
## Admin Options
555
563
564
+
Template administrators often want to expose certain experimental or unstable options only to those with elevated roles. You can now do this by setting `count` based on a user's group or role, referencing the [`coder_workspace_owner`](https://registry.terraform.io/providers/coder/coder/latest/docs/data-sources/workspace_owner) data source.
565
+
566
+
[Try out admin-only options in the Playground](https://playground.coder.app/parameters/5Gn9W3hYs7).
567
+
568
+
```terraform
569
+
570
+
locals {
571
+
roles = [for r in data.coder_workspace_owner.me.rbac_roles: r.name]
# This parameter is only visible when the user is an administrator
580
+
count = local.is_admin ? 1 : 0
581
+
582
+
name = "advanced_settings"
583
+
display_name = "Add an arbitrary script"
584
+
description = "An advanced configuration option only available to admins."
585
+
type = "string"
586
+
form_type = "textarea"
587
+
mutable = true
588
+
order = 5
589
+
590
+
styling = jsonencode({
591
+
placeholder = <<-EOT
592
+
#!/usr/bin/env bash
593
+
while true; do
594
+
echo "hello world"
595
+
sleep 1
596
+
done
597
+
EOT
598
+
})
599
+
}
600
+
556
601
```
557
-
data "coder_parameter" "advanced_setting" {
602
+
603
+
## Role-specific options
604
+
605
+
Similarly to the above example, you can show certain options to specific roles on the platform. This allows you to restrict resources for those who may not need them.
606
+
607
+
```terraform
608
+
locals {
609
+
roles = [for r in data.coder_workspace_owner.me.rbac_roles: r.name]
description = "An advanced configuration option only available to admins."
563
627
type = "string"
564
-
default = "default_value"
628
+
form_type = "textarea"
629
+
630
+
styling = jsonencode({
631
+
placeholder = <<-EOT
632
+
#!/usr/bin/env bash
633
+
while true; do
634
+
echo "hello world"
635
+
sleep 1
636
+
done
637
+
EOT
638
+
})
639
+
565
640
mutable = true
566
-
order = 1
641
+
order = 5
642
+
}
643
+
```
644
+
645
+
### User-aware Regions
646
+
647
+
You can expose regions depending on which group a user belongs to. This way developers can't incidentally induce low-latency with world-spanning connections.
648
+
649
+
[Try user-aware regions in the parameter playground](https://playground.coder.app/parameters/tBD-mbZRGm)
A slightly unorthodox way to leverage this is filling the selections of a parameter from the user's groups. Some users associate groups with namespaces (E.G. Kubernetes), then allow users to target that namespace with a parameter like so.
575
699
576
-
## Advanced use cases
577
700
578
-
## Dynamic Parameter Use Case Examples
701
+
```terraform
702
+
579
703
580
-
<details><summary>Conditional Parameters: Region and Instance Types</summary>
704
+
```
705
+
706
+
</div>
581
707
582
708
This example shows instance types based on the selected region:
583
709
@@ -626,39 +752,6 @@ data "coder_parameter" "instance_type" {
0 commit comments