Skip to content

Fetch parameter options at workspace build time #15652

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

Open
stirby opened this issue Nov 25, 2024 · 1 comment
Open

Fetch parameter options at workspace build time #15652

stirby opened this issue Nov 25, 2024 · 1 comment
Labels
customer-requested Features requested by enterprise customers. Only humans may set this. needs-triage Issue that require triage

Comments

@stirby
Copy link
Collaborator

stirby commented Nov 25, 2024

Administrators use coder_parameters to provide developers configuration options that may vary between workspaces on the same template. These are often used to set resource values, instance types, host regions, or IDEs to inject as coder_apps.

The state of these parameters must be determined at template build time. Administrators must define all options for a parameter well before a user creates their workspace using it. This causes difficulty for administrators as the resources referenced by a coder_parameter may be dynamic. For example, adding an "instance type" parameter expects admins to manually hard-code all instance types for the template, then force users to select an option compatible with their region. This can be a functional blocker on workspace creation and a management burden on administrators.

Additionally, other CDE solutions allow the typical use-case of listing all Github repositories that belong to a user to clone when creating an environment. Pairing a parameter that can dynamically list Github repositories with our git-clone module would achieve feature parity.

Solution proposal

Note: This feature is still being designed. Implementation and UX are subject to change.

We will improve this workflow by allowing parameters to fetch data dynamically upon workspace build. This data can be retrieved from any API endpoint and be used to populate any of our parameter types. Our initial design adds a coder_parameter_source to fetch the API at build time.

data "coder_parameter_source" "org-projects" {
  get = "https://github.com/orgs/${data.coder_parameter.organization}/repos" 
  body {
    user = data.coder_workspace.me.owner # Not actually valid for this call; just an example.
  }
  headers {
    X-FOO = "bar"
  }
}
data "coder_parameter" "projects" {
  name = "Select projects to clone"
  default = element(data.coder_parameter_source.org-projects, 0)
  option = [for repo in data.coder_paramater_source.org-projects : {
	  value = repo.url
  }]
}
@stirby stirby added the customer-requested Features requested by enterprise customers. Only humans may set this. label Nov 25, 2024
@coder-labeler coder-labeler bot added the needs-triage Issue that require triage label Nov 25, 2024
@stirby stirby mentioned this issue Nov 25, 2024
8 tasks
@jore731
Copy link

jore731 commented Feb 6, 2025

It would be nice that this parameters could also be populated somehow via terraform, for example:

data "azurerm_subscriptions" "available" {}

data "coder_parameter" "subscription" {
  name = "Azure target subscription"

  dynamic "option" {
    for_each = data.azurerm_subscriptions.available
    content {
       name = option.value["display_name"]
       value = option.value["subscription_id"]
    }
  }
}

@stirby stirby changed the title Dynamic Parameters Fetch parameter options at workspace build time Feb 6, 2025
@stirby stirby unassigned Emyrk Feb 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
customer-requested Features requested by enterprise customers. Only humans may set this. needs-triage Issue that require triage
Projects
None yet
Development

No branches or pull requests

3 participants