diff --git a/examples/tests/stacks/catalog/terraform/template-functions-test2/defaults.yaml b/examples/tests/stacks/catalog/terraform/template-functions-test2/defaults.yaml index 71c90f590..0042836e7 100644 --- a/examples/tests/stacks/catalog/terraform/template-functions-test2/defaults.yaml +++ b/examples/tests/stacks/catalog/terraform/template-functions-test2/defaults.yaml @@ -6,7 +6,7 @@ components: metadata: # Point to the Terraform component component: "test/template-functions-test2" - terraform_workspace: '{{ .vars.tenant }}-{{ .vars.environment }}-{{ .vars.stage }}' + terraform_workspace: '{{ .vars.tenant }}-{{ .vars.environment }}-{{ .vars.stage }}-test' settings: spacelift: workspace_enabled: false diff --git a/internal/exec/terraform.go b/internal/exec/terraform.go index 0c0021ff8..4747cda29 100644 --- a/internal/exec/terraform.go +++ b/internal/exec/terraform.go @@ -121,8 +121,10 @@ func ExecuteTerraform(info schema.ConfigAndStacksInfo) error { } return nil } + varFile := constructTerraformComponentVarfileName(info) planFile := constructTerraformComponentPlanfileName(info) + // Print component variables and write to file // Don't process variables when executing `terraform workspace` commands if info.SubCommand != "workspace" { diff --git a/internal/exec/utils.go b/internal/exec/utils.go index 6dea676bb..0d0b327bc 100644 --- a/internal/exec/utils.go +++ b/internal/exec/utils.go @@ -563,6 +563,10 @@ func ProcessStacks( if i, ok := configAndStacksInfo.ComponentSection[cfg.CommandSectionName].(string); ok { configAndStacksInfo.Command = i } + + if i, ok := configAndStacksInfo.ComponentSection[cfg.WorkspaceSectionName].(string); ok { + configAndStacksInfo.TerraformWorkspace = i + } } // Spacelift stack