Skip to content

Terraform variables show different behavior between Classic and Dynamic template formats #18671

Open
@blink-so

Description

@blink-so

Problem

Terraform variables defined in terraform.vars files behave differently between Classic and Dynamic template formats:

  • Classic format: Shows updated/overridden values from terraform.vars
  • Dynamic format: Stuck on default values, ignoring overrides set in Template Settings

Example

Template defines:

variable "availability_zone_names" {
  description = "List of AWS availability zones"
  type        = list(string)
  default     = ["us-west-1b", "us-west-1d", "uk-west-2a"]
}

data "coder_parameter" "availability_zone" {
  name         = "availability_zone"
  display_name = "Availability Zone"
  description  = "Select which availability zone to deploy in"
  type         = "string"
  mutable      = true

  dynamic "option" {
    for_each = toset(var.availability_zone_names)
    content {
      name  = option.value
      value = option.value
    }
  }
}

When overriding via:

export TF_VAR_availability_zone_names='["us-west-1b","us-west-1d", "uk-west-2a", "uk-west-2a"]'
# or terraform.vars file
coder templates push -y --org=coder --var teams=""

Expected: Both Classic and Dynamic should show the same overridden values
Actual: Classic shows overridden values, Dynamic shows defaults

Additional Context

Dynamic parameters does not take in the TemplateVariables set in the settings page. It should.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions