File tree Expand file tree Collapse file tree 2 files changed +7
-9
lines changed
Expand file tree Collapse file tree 2 files changed +7
-9
lines changed Original file line number Diff line number Diff line change @@ -157,12 +157,12 @@ function Invoke-TerraformInit
157157 _LogMessage - Level ' INFO' - Message " Running *terraform init ${InitArgs} * in: $CodePath " - InvocationName $inv
158158 Set-Location $CodePath
159159
160- if ($CreateBackendKey -and $StackFolderName )
161- {
162- $normalized = $StackFolderName -replace ' _' , ' -'
163- $backendArg = " - backend-config= key= ${normalized} .terraform.tfstate "
164- _LogMessage - Level ' DEBUG ' - Message " Appending backend key arg: $backendArg " - InvocationName $inv
165- $InitArgs += $backendArg
160+ if ($CreateBackendKey -and $PSBoundParameters .ContainsKey ( ' StackFolderName' )) {
161+ $folderName = Split-Path - Path $StackFolderName - Leaf
162+ $backendKey = $folderName -replace ' _' , ' -' + " .terraform.tfstate "
163+ _LogMessage - Level ' DEBUG ' - Message " Computed backend key name: $backendKey " - InvocationName $MyInvocation .MyCommand.Name
164+
165+ $InitArgs += " -backend-config=key= $backendKey "
166166 }
167167
168168 & terraform init @InitArgs
Original file line number Diff line number Diff line change @@ -11,7 +11,5 @@ terraform {
1111 source = " hashicorp/random"
1212 }
1313 }
14- backend "azurerm" {
15- key = " lbd-uks-prd-1-network.terraform.tfstate"
16- }
14+ backend "azurerm" {}
1715}
You can’t perform that action at this time.
0 commit comments