Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

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

Closed
johnstcn opened this issue Dec 9, 2024 · 1 comment
Assignees
Labels
bug risk Prone to bugs customer-reported Bugs reported by enterprise customers. Only humans may set this. s2 Broken use cases or features (with a workaround). Only humans may set this.

Comments

@johnstcn
Copy link
Member

johnstcn commented Dec 9, 2024

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.

@johnstcn johnstcn added the customer-reported Bugs reported by enterprise customers. Only humans may set this. label Dec 9, 2024
@coder-labeler coder-labeler bot added the bug risk Prone to bugs label Dec 9, 2024
@johnstcn johnstcn self-assigned this Dec 9, 2024
@johnstcn johnstcn added the s2 Broken use cases or features (with a workaround). Only humans may set this. label Dec 9, 2024
@johnstcn
Copy link
Member Author

Fixed by #15800

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug risk Prone to bugs customer-reported Bugs reported by enterprise customers. Only humans may set this. s2 Broken use cases or features (with a workaround). Only humans may set this.
Projects
None yet
Development

No branches or pull requests

1 participant