Skip to content

Commit

Permalink
Copy env var for starter module
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredfholgate committed Sep 29, 2024
1 parent e7a8eb0 commit 552eca8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
13 changes: 10 additions & 3 deletions src/ALZ/Private/Config-Helpers/Set-Config.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ function Set-Config {
[Parameter(Mandatory = $false)]
[PSCustomObject] $inputConfig = $null,
[Parameter(Mandatory = $false)]
[hashtable] $computedInputs
[hashtable] $computedInputs,
[Parameter(Mandatory = $false)]
[switch] $copyEnvVarToConfig
)

if ($PSCmdlet.ShouldProcess("Set Configuration.", "Set configuration values.")) {
Expand Down Expand Up @@ -40,8 +42,13 @@ function Set-Config {
# Look for environment variables
$environmentVariable = [Environment]::GetEnvironmentVariable("TF_VAR_$inputConfigName")
if($null -ne $environmentVariable) {
$configurationValue.Value.Value = "sourced-from-env"
Write-Verbose "Using environment variable for $inputConfigName"
if($copyEnvVarToConfig) {
$configurationValue.Value.Value = $environmentVariable
Write-Verbose "Set value from environment variable for $inputConfigName"
} else {
$configurationValue.Value.Value = "sourced-from-env"
Write-Verbose "Using environment variable for $inputConfigName"
}
continue
}

Expand Down
3 changes: 2 additions & 1 deletion src/ALZ/Private/Deploy-Accelerator-Helpers/New-Bootstrap.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ function New-Bootstrap {
$starterConfiguration = Set-Config `
-configurationParameters $starterParameters `
-inputConfig $inputConfig `
-computedInputs $computedInputs
-computedInputs $computedInputs `
-copyEnvVarToConfig

# Creating the tfvars files for the bootstrap and starter module
$tfVarsFileName = "terraform.tfvars.json"
Expand Down

0 comments on commit 552eca8

Please sign in to comment.