Skip to content

feat: Add "coder_parameter" to expose richer parameter types #57

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Sep 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Terraform Provider Coder
# terraform-provider-coder

> This works with a closed-alpha of [Coder](https://coder.com). For access, contact [support@coder.com](mailto:support@coder.com).
See [Coder](https://github.com/coder/coder).
60 changes: 60 additions & 0 deletions docs/data-sources/parameter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "coder_parameter Data Source - terraform-provider-coder"
subcategory: ""
description: |-
Use this data source to configure editable options for workspaces.
---

# coder_parameter (Data Source)

Use this data source to configure editable options for workspaces.



<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `name` (String) The name of the parameter as it will appear in the interface. If this is changed, developers will be re-prompted for a new value.

### Optional

- `default` (String) A default value for the parameter.
- `description` (String) Describe what this parameter does.
- `icon` (String) A URL to an icon that will display in the dashboard. View built-in icons here: https://github.com/coder/coder/tree/main/site/static/icon. Use a built-in icon with `data.coder_workspace.me.access_url + "/icon/<path>"`.
- `mutable` (Boolean) Whether this value can be changed after workspace creation. This can be destructive for values like region, so use with caution!
- `option` (Block List, Max: 64) Each "option" block defines a value for a user to select from. (see [below for nested schema](#nestedblock--option))
- `type` (String) The type of this parameter. Must be one of: "number", "string", or "bool".
- `validation` (Block List, Max: 1) Validate the input of a parameter. (see [below for nested schema](#nestedblock--validation))

### Read-Only

- `id` (String) The ID of this resource.
- `value` (String) The output value of the parameter.

<a id="nestedblock--option"></a>
### Nested Schema for `option`

Required:

- `name` (String) The display name of this value in the UI.
- `value` (String) The value of this option set on the parameter if selected.

Optional:

- `description` (String) Describe what selecting this value does.
- `icon` (String) A URL to an icon that will display in the dashboard. View built-in icons here: https://github.com/coder/coder/tree/main/site/static/icon. Use a built-in icon with `data.coder_workspace.me.access_url + "/icon/<path>"`.


<a id="nestedblock--validation"></a>
### Nested Schema for `validation`

Optional:

- `max` (Number) The maximum of a number parameter.
- `min` (Number) The minimum of a number parameter.
- `regex` (String) A regex for the input parameter to match against.


46 changes: 46 additions & 0 deletions examples/resources/coder_parameter/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
data "coder_parameter" "example" {
display_name = "Region"
description = "Specify a region to place your workspace."
immutable = true
type = "string"
option {
value = "us-central1-a"
label = "US Central"
icon = "/icon/usa.svg"
}
option {
value = "asia-central1-a"
label = "Asia"
icon = "/icon/asia.svg"
}
}

data "coder_parameter" "ami" {
display_name = "Machine Image"
option {
value = "ami-xxxxxxxx"
label = "Ubuntu"
icon = "/icon/ubuntu.svg"
}
}

data "coder_parameter" "image" {
display_name = "Docker Image"
icon = "/icon/docker.svg"
type = "bool"
}

data "coder_parameter" "cores" {
display_name = "CPU Cores"
icon = "/icon/"
}

data "coder_parameter" "disk_size" {
display_name = "Disk Size"
type = "number"
validation {
# This can apply to number and string types.
min = 0
max = 10
}
}
Loading