Skip to content

bug: tfparse: does not correctly evaluate default of coder_parameter as variable #15795

@johnstcn

Description

@johnstcn

Given:

The following main.tf:

provider "foo" {}
resource "foo_bar" "baz" {}
variable "region" {
	type    = string
	default = "us"
}
variable "az" {
	type    = string
	default = "a"
}
data "base" "ours" {
	all = true
}
data "coder_parameter" "az" {
	name = "az"
	type = "string"
	default = var.az
}
data "coder_workspace_tags" "tags" {
	tags = {
		"platform" = "kubernetes",
		"cluster"  = "${"devel"}${"opers"}"
		"region"   = var.region
		"az"       = data.coder_parameter.az.value
	}
}

When:

provisioner/terraform/tfparse.WorkspaceTagDefaults extracts workspace tags from the above

Then:

Expected:

{"platform": "kubernetes", "cluster": "developers", "region": "us", "az": "a"}

Actual:

{"platform":"kubernetes", "cluster":"developers", "region":"us", "az":"var.az"}

Notes:

A similar issue can also be observed with an "evaluated" default value, e.g.:

provider "foo" {}
resource "foo_bar" "baz" {}
variable "region" {
	type    = string
	default = "us"
}
data "base" "ours" {
	all = true
}
data "coder_parameter" "az" {
	name = "az"
	type = "string"
	default = "${""}${"a"}"
}
data "coder_workspace_tags" "tags" {
	tags = {
		"platform" = "kubernetes",
		"cluster"  = "${"devel"}${"opers"}"
		"region"   = var.region
		"az"       = data.coder_parameter.az.value
	}
}

In this case, we get the raw value ${""}${"a"} instead of the expected value a.

Metadata

Metadata

Assignees

Labels

bug riskProne to bugscustomer-reportedBugs reported by enterprise customers. Only humans may set this.s2Broken use cases or features (with a workaround). Only humans may set this.

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    pFad - Phonifier reborn

    Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

    Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


    Alternative Proxies:

    Alternative Proxy

    pFad Proxy

    pFad v3 Proxy

    pFad v4 Proxy