Skip to content

fix(provisioner/terraform/tfparse): evaluate coder_parameter defaults with variables #15800

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 3 commits into from
Dec 10, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
add test case with parameter default from another parameter
  • Loading branch information
johnstcn committed Dec 9, 2024
commit afff08fed59267c1352a0970f3396787949d99d2
33 changes: 33 additions & 0 deletions provisioner/terraform/tfparse/tfparse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,39 @@ func Test_WorkspaceTagDefaultsFromFile(t *testing.T) {
expectTags: map[string]string{"platform": "kubernetes", "cluster": "developers", "region": "us", "az": "a"},
expectError: "",
},
{
name: "main.tf with parameter that has default value from another parameter",
files: map[string]string{
"main.tf": `
provider "foo" {}
resource "foo_bar" "baz" {}
variable "region" {
type = string
default = "us"
}
data "base" "ours" {
all = true
}
data "coder_parameter" "az" {
type = string
default = "${""}${"a"}"
}
data "coder_parameter" "az2" {
name = "az"
type = "string"
default = data.coder_parameter.az.value
}
data "coder_workspace_tags" "tags" {
tags = {
"platform" = "kubernetes",
"cluster" = "${"devel"}${"opers"}"
"region" = var.region
"az" = data.coder_parameter.az2.value
}
}`,
},
expectError: "Unknown variable; There is no variable named \"data\".",
},
{
name: "main.tf with multiple valid workspace tags",
files: map[string]string{
Expand Down
Loading