Skip to content

Commit

Permalink
Add support for HCL env vars
Browse files Browse the repository at this point in the history
  • Loading branch information
jmfontaine committed Jan 27, 2023
1 parent 3eb046e commit 264e371
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions exporters/tfc/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ locals {
stacks = [for i, v in data.tfe_workspace_ids.all.ids : {
autodeploy = data.tfe_workspace.all[i].auto_apply
env_vars = [for i, v in data.tfe_variables.all[v].variables : {
hcl = v.hcl
name = v.category == "terraform" ? "TF_VAR_${v.name}" : v.name
sensitive = v.sensitive
value = v.value
Expand Down
2 changes: 1 addition & 1 deletion generator/generator.tftpl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ resource "spacelift_stack" "${replace(lower(stack.name), "-", "_")}" {
resource "spacelift_environment_variable" "${replace(lower(env_var.name), "-", "_")}" {
stack_id = spacelift_stack.${replace(lower(stack.name), "-", "_")}.id
name = "${env_var.name}"
value = "${env_var.value}"
value = %{if env_var.hcl ~}jsonencode(${env_var.value})%{else}"${env_var.value}"%{~endif}
write_only = ${env_var.sensitive}
}
%{ endfor ~}
Expand Down
1 change: 1 addition & 0 deletions generator/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ variable "stacks" {
type = list(object({
autodeploy = bool
env_vars = list(object({
hcl = bool
name = string
sensitive = bool
value = string
Expand Down

0 comments on commit 264e371

Please sign in to comment.