From c19e427f361a660a051fc6bc2f5c78c9ccc3f4a5 Mon Sep 17 00:00:00 2001 From: Zach Trocinski Date: Thu, 13 Nov 2025 23:37:17 -0600 Subject: [PATCH 01/11] Initial changes to support bicep-avm --- README.md | 12 ++- .../Config-Helpers/Request-SpecialInput.ps1 | 3 +- .../New-Bootstrap.ps1 | 74 +++++++++++-------- src/ALZ/Public/Deploy-Accelerator.ps1 | 16 ++-- 4 files changed, 65 insertions(+), 40 deletions(-) diff --git a/README.md b/README.md index 6d7557f..15d502f 100644 --- a/README.md +++ b/README.md @@ -10,9 +10,17 @@ ## Introduction -This repository contains the PowerShell module and documentation for the Azure landing zones Accelerators for Bicep and Terraform. The accelerators are an opinionated implementation of the Azure Landing Zones Terraform modules, with Azure DevOps or GitHub bootstrapping. +This repository contains the PowerShell module and documentation for the Azure landing zones Accelerators for Bicep and Terraform. The accelerators are an opinionated implementation of the Azure Landing Zones modules, with Azure DevOps or GitHub bootstrapping. -It is designed to be used as a template to enable you to get started quickly deploying ALZ with Bicep or Terraform. +## Supported Infrastructure as Code (IaC) Types + +The accelerators support multiple Infrastructure as Code approaches: + +- **terraform**: Terraform-based Azure Landing Zones +- **bicep**: Bicep-based Azure Landing Zones using the traditional [ALZ-Bicep](https://github.com/Azure/ALZ-Bicep) framework +- **bicep-avm**: Bicep-based Azure Landing Zones using the new [alz-bicep-accelerator](https://github.com/Azure/alz-bicep-accelerator) framework built on Azure Verified Modules + +It is designed to be used as a template to enable you to get started quickly deploying ALZ with any of these approaches. Please refer to our [Docs](https://aka.ms/alz/acc) for detailed features and usage instructions. diff --git a/src/ALZ/Private/Config-Helpers/Request-SpecialInput.ps1 b/src/ALZ/Private/Config-Helpers/Request-SpecialInput.ps1 index b6009b4..133ce85 100644 --- a/src/ALZ/Private/Config-Helpers/Request-SpecialInput.ps1 +++ b/src/ALZ/Private/Config-Helpers/Request-SpecialInput.ps1 @@ -19,7 +19,8 @@ function Request-SpecialInput { $typeDescription = "" if($type -eq "iac") { - $options += @{ key = "bicep"; name = "Bicep"; description = "Bicep" } + $options += @{ key = "bicep-avm"; name = "Bicep AVM"; description = "Bicep (New Framework)" } + $options += @{ key = "bicep"; name = "Bicep Classic"; description = "Bicep (Classic Framework)" } $options += @{ key = "terraform"; name = "Terraform"; description = "Terraform" } $typeDescription = "Infrastructure as Code (IaC) language" } diff --git a/src/ALZ/Private/Deploy-Accelerator-Helpers/New-Bootstrap.ps1 b/src/ALZ/Private/Deploy-Accelerator-Helpers/New-Bootstrap.ps1 index 7b70bd9..e28d719 100644 --- a/src/ALZ/Private/Deploy-Accelerator-Helpers/New-Bootstrap.ps1 +++ b/src/ALZ/Private/Deploy-Accelerator-Helpers/New-Bootstrap.ps1 @@ -82,8 +82,8 @@ function New-Bootstrap { $starterRootModuleFolderPath = "" $starterFoldersToRetain = @() - if($hasStarter) { - if($inputConfig.starter_module_name.Value -eq "") { + if ($hasStarter) { + if ($inputConfig.starter_module_name.Value -eq "") { $inputConfig.starter_module_name = @{ Value = Request-SpecialInput -type "starter" -starterConfig $starterConfig Source = "user" @@ -97,12 +97,12 @@ function New-Bootstrap { $starterRootModuleFolderPath = $starterModulePath Write-Verbose "Starter Module Path: $starterModulePath" - if($chosenStarterConfig.PSObject.Properties.Name -contains "additional_retained_folders") { + if ($chosenStarterConfig.PSObject.Properties.Name -contains "additional_retained_folders") { $starterFoldersToRetain = $chosenStarterConfig.additional_retained_folders Write-Verbose "Starter Additional folders to retain: $($starterFoldersToRetain -join ",")" } - if($chosenStarterConfig.PSObject.Properties.Name -contains "root_module_folder") { + if ($chosenStarterConfig.PSObject.Properties.Name -contains "root_module_folder") { $starterRootModuleFolder = $chosenStarterConfig.root_module_folder # Retain the root module folder @@ -127,23 +127,23 @@ function New-Bootstrap { Write-Verbose "Getting the bootstrap configuration..." $terraformFiles = Get-ChildItem -Path $bootstrapModulePath -Filter "*.tf" -File - foreach($terraformFile in $terraformFiles) { + foreach ($terraformFile in $terraformFiles) { $bootstrapParameters = Convert-HCLVariablesToInputConfig -targetVariableFile $terraformFile.FullName -hclParserToolPath $hclParserToolPath -validators $validationConfig -appendToObject $bootstrapParameters } # Getting the configuration for the starter module user input - $starterParameters = [PSCustomObject]@{} + $starterParameters = [PSCustomObject]@{} - if($hasStarter) { + if ($hasStarter) { Write-Verbose "Getting the starter configuration..." - if($iac -eq "terraform") { + if ($iac -eq "terraform") { $terraformFiles = Get-ChildItem -Path $starterRootModuleFolderPath -Filter "*.tf" -File - foreach($terraformFile in $terraformFiles) { + foreach ($terraformFile in $terraformFiles) { $starterParameters = Convert-HCLVariablesToInputConfig -targetVariableFile $terraformFile.FullName -hclParserToolPath $hclParserToolPath -validators $validationConfig -appendToObject $starterParameters } } - if($iac -eq "bicep") { + if ($iac -in @("bicep", "bicep-avm")) { $starterParameters = Convert-BicepConfigToInputConfig -bicepConfig $starterConfig.starter_modules.Value.$($inputConfig.starter_module_name.Value) -validators $validationConfig } } @@ -158,7 +158,7 @@ function New-Bootstrap { Source = "calculated" } - if($inputConfig.PSObject.Properties.Name -contains "starter_location" -and $inputConfig.PSObject.Properties.Name -notcontains "starter_locations") { + if ($inputConfig.PSObject.Properties.Name -contains "starter_location" -and $inputConfig.PSObject.Properties.Name -notcontains "starter_locations") { Write-Verbose "Converting starter_location $($inputConfig.starter_location.Value) to starter_locations..." $inputConfig | Add-Member -NotePropertyName "starter_locations" -NotePropertyValue @{ Value = @($inputConfig.starter_location.Value) @@ -166,9 +166,9 @@ function New-Bootstrap { } } - if($inputConfig.PSObject.Properties.Name -contains "starter_locations") { + if ($inputConfig.PSObject.Properties.Name -contains "starter_locations") { $availabilityZonesStarter = @() - foreach($region in $inputConfig.starter_locations.Value) { + foreach ($region in $inputConfig.starter_locations.Value) { $availabilityZonesStarter += , @(Get-AvailabilityZonesSupport -region $region -zonesSupport $zonesSupport) } $inputConfig | Add-Member -NotePropertyName "availability_zones_starter" -NotePropertyValue @{ @@ -203,12 +203,12 @@ function New-Bootstrap { # Write the tfvars file for the bootstrap and starter module Write-TfvarsJsonFile -tfvarsFilePath $bootstrapTfvarsPath -configuration $bootstrapConfiguration - if($iac -eq "terraform") { - if($starterFoldersToRetain.Length -gt 0) { + if ($iac -eq "terraform") { + if ($starterFoldersToRetain.Length -gt 0) { Write-Verbose "Removing unwanted folders from the starter module..." $folders = Get-ChildItem -Path $starterModulePath -Directory - foreach($folder in $folders) { - if($starterFoldersToRetain -notcontains $folder.Name) { + foreach ($folder in $folders) { + if ($starterFoldersToRetain -notcontains $folder.Name) { Write-Verbose "Removing folder: $($folder.FullName)" Remove-Item -Path $folder.FullName -Recurse -Force } else { @@ -218,12 +218,12 @@ function New-Bootstrap { } } Remove-TerraformMetaFileSet -path $starterModulePath -writeVerboseLogs:$writeVerboseLogs.IsPresent - if($convertTfvarsToJson) { + if ($convertTfvarsToJson) { Write-TfvarsJsonFile -tfvarsFilePath $starterTfvarsPath -configuration $starterConfiguration } else { $inputsFromTfvars = $inputConfig.PSObject.Properties | Where-Object { $_.Value.Source -eq ".tfvars" } | Select-Object -ExpandProperty Name Write-TfvarsJsonFile -tfvarsFilePath $starterTfvarsPath -configuration $starterConfiguration -skipItems $inputsFromTfvars - foreach($inputConfigFilePath in $inputConfigFilePaths | Where-Object { $_ -like "*.tfvars" }) { + foreach ($inputConfigFilePath in $inputConfigFilePaths | Where-Object { $_ -like "*.tfvars" }) { $fileName = [System.IO.Path]::GetFileName($inputConfigFilePath) $fileName = $fileName.Replace(".tfvars", ".auto.tfvars") $destination = Join-Path -Path $starterRootModuleFolderPath -ChildPath $fileName @@ -233,8 +233,8 @@ function New-Bootstrap { } # Copy additional files - foreach($additionalFile in $starterAdditionalFiles) { - if(Test-Path $additionalFile -PathType Container) { + foreach ($additionalFile in $starterAdditionalFiles) { + if (Test-Path $additionalFile -PathType Container) { $folderName = ([System.IO.DirectoryInfo]::new($additionalFile)).Name $destination = Join-Path -Path $starterRootModuleFolderPath -ChildPath $folderName Write-Verbose "Copying folder $additionalFile to $destination" @@ -248,23 +248,39 @@ function New-Bootstrap { } } - if($iac -eq "bicep") { - Copy-ParametersFileCollection -starterPath $starterModulePath -configFiles $starterConfig.starter_modules.Value.$($inputConfig.starter_module_name.Value).deployment_files + if ($iac -in @("bicep", "bicep-avm")) { + $starterModuleDefinition = $starterConfig.starter_modules.Value.$($inputConfig.starter_module_name.Value) + Copy-ParametersFileCollection -starterPath $starterModulePath -configFiles $starterModuleDefinition.deployment_files Set-ComputedConfiguration -configuration $starterConfiguration Edit-ALZConfigurationFilesInPlace -alzEnvironmentDestination $starterModulePath -configuration $starterConfiguration - Write-JsonFile -jsonFilePath $starterBicepVarsPath -configuration $starterConfiguration + if ($iac -eq "bicep-avm") { + $bicepAvmEnvConfiguration = Get-BicepAvmEnvironmentConfiguration -inputConfig $inputConfig + $combinedConfiguration = [PSCustomObject]@{} + + foreach ($property in $starterConfiguration.PSObject.Properties) { + $combinedConfiguration | Add-Member -NotePropertyName $property.Name -NotePropertyValue $property.Value + } + + foreach ($property in $bicepAvmEnvConfiguration.PSObject.Properties) { + $combinedConfiguration | Add-Member -NotePropertyName $property.Name -NotePropertyValue $property.Value -Force + } + + Write-JsonFile -jsonFilePath $starterBicepVarsPath -configuration $combinedConfiguration + } else { + Write-JsonFile -jsonFilePath $starterBicepVarsPath -configuration $starterConfiguration + } # Remove unrequired files - $foldersOrFilesToRetain = $starterConfig.starter_modules.Value.$($inputConfig.starter_module_name.Value).folders_or_files_to_retain + $foldersOrFilesToRetain = $starterModuleDefinition.folders_or_files_to_retain $foldersOrFilesToRetain += "parameters.json" $foldersOrFilesToRetain += "config" $foldersOrFilesToRetain += "starter-cache.json" - foreach($deployment_file in $starterConfig.starter_modules.Value.$($inputConfig.starter_module_name.Value).deployment_files) { + foreach ($deployment_file in $starterModuleDefinition.deployment_files) { $foldersOrFilesToRetain += $deployment_file.templateParametersSourceFilePath } - $subFoldersOrFilesToRemove = $starterConfig.starter_modules.Value.$($inputConfig.starter_module_name.Value).subfolders_or_files_to_remove + $subFoldersOrFilesToRemove = $starterModuleDefinition.subfolders_or_files_to_remove Remove-UnrequiredFileSet -path $starterModulePath -foldersOrFilesToRetain $foldersOrFilesToRetain -subFoldersOrFilesToRemove $subFoldersOrFilesToRemove -writeVerboseLogs:$writeVerboseLogs.IsPresent } @@ -272,7 +288,7 @@ function New-Bootstrap { # Running terraform init and apply Write-InformationColored "Thank you for providing those inputs, we are now initializing and applying Terraform to bootstrap your environment..." -ForegroundColor Green -NewLineBefore -InformationAction Continue - if($autoApprove) { + if ($autoApprove) { Invoke-Terraform -moduleFolderPath $bootstrapModulePath -autoApprove -destroy:$destroy.IsPresent } else { Write-InformationColored "Once the plan is complete you will be prompted to confirm the apply." -ForegroundColor Green -NewLineBefore -InformationAction Continue @@ -281,4 +297,4 @@ function New-Bootstrap { Write-InformationColored "Bootstrap has completed successfully! Thanks for using our tool. Head over to Phase 3 in the documentation to continue..." -ForegroundColor Green -NewLineBefore -InformationAction Continue } -} \ No newline at end of file +} diff --git a/src/ALZ/Public/Deploy-Accelerator.ps1 b/src/ALZ/Public/Deploy-Accelerator.ps1 index 5f9afc8..58392a4 100644 --- a/src/ALZ/Public/Deploy-Accelerator.ps1 +++ b/src/ALZ/Public/Deploy-Accelerator.ps1 @@ -22,7 +22,7 @@ function Deploy-Accelerator { [Parameter( Mandatory = $false, - HelpMessage = "[REQUIRED] The infrastructure as code type to target. Supported options are 'bicep', 'terrform' or 'local'. Environment variable: ALZ_iac_type. Config file input: iac_type.")] + HelpMessage = "[REQUIRED] The infrastructure as code type to target. Supported options are 'bicep', 'bicep-avm', 'terraform' or 'local'. Environment variable: ALZ_iac_type. Config file input: iac_type.")] [Alias("i")] [Alias("iac")] [string] $iac_type = "", @@ -188,7 +188,7 @@ function Deploy-Accelerator { $ProgressPreference = "SilentlyContinue" - if($skip_requirements_check.IsPresent) { + if ($skip_requirements_check.IsPresent) { Write-InformationColored "WARNING: Skipping the software requirements check..." -ForegroundColor Yellow -InformationAction Continue } else { Write-InformationColored "Checking the software requirements for the Accelerator..." -ForegroundColor Green -InformationAction Continue @@ -201,7 +201,7 @@ function Deploy-Accelerator { # Check and install tools needed $toolsPath = Join-Path -Path $output_folder_path -ChildPath ".tools" - if($skipInternetChecks) { + if ($skipInternetChecks) { Write-InformationColored "Skipping Terraform tool check as you used the skipInternetCheck parameter. Please ensure you have the most recent version of Terraform installed" -ForegroundColor Yellow -InformationAction Continue } else { Write-InformationColored "Checking you have the latest version of Terraform installed..." -ForegroundColor Green -NewLineBefore -InformationAction Continue @@ -213,7 +213,7 @@ function Deploy-Accelerator { $inputConfig = $null if ($inputConfigFilePaths.Length -eq 0) { $envInputConfigPaths = $env:ALZ_input_config_path - if($null -ne $envInputConfigPaths -and $envInputConfigPaths -ne "") { + if ($null -ne $envInputConfigPaths -and $envInputConfigPaths -ne "") { $inputConfigFilePaths = $envInputConfigPaths -split "," } else { Write-InformationColored "No input configuration file path has been provided. Please provide the path(s) to your configuration file(s)..." -ForegroundColor Yellow -InformationAction Continue @@ -222,7 +222,7 @@ function Deploy-Accelerator { } # Get the input config from yaml and json files - foreach($inputConfigFilePath in $inputConfigFilePaths) { + foreach ($inputConfigFilePath in $inputConfigFilePaths) { $inputConfig = Get-ALZConfig -configFilePath $inputConfigFilePath -inputConfig $inputConfig -hclParserToolPath $hclParserToolPath } @@ -231,13 +231,13 @@ function Deploy-Accelerator { $parametersWithValues = @{} foreach ($parameterKey in $parameters.Keys) { $parameter = $parameters[$parameterKey] - if($parameter.IsDynamic) { + if ($parameter.IsDynamic) { continue } $parameterValue = Get-Variable -Name $parameterKey -ValueOnly -ErrorAction SilentlyContinue - if($null -ne $parameterValue) { + if ($null -ne $parameterValue) { $parametersWithValues[$parameterKey] = @{ type = $parameters[$parameterKey].ParameterType.Name value = $parameterValue @@ -255,7 +255,7 @@ function Deploy-Accelerator { } } - if ($inputConfig.iac_type.Value -eq "bicep") { + if ($inputConfig.iac_type.Value -eq "bicep" -or $inputConfig.iac_type.Value -eq "bicep-classic") { Write-InformationColored "Although you have selected Bicep, the Accelerator leverages the Terraform tool to bootstrap your Version Control System and Azure. This is will not impact your choice of Bicep post this initial bootstrap. Please refer to our documentation for further details..." -ForegroundColor Yellow -InformationAction Continue } From b28dbe0e2b83814bd76f76430d435e475029b70a Mon Sep 17 00:00:00 2001 From: Zach Trocinski Date: Fri, 14 Nov 2025 00:46:41 -0600 Subject: [PATCH 02/11] Remove logic causing script to hang --- .../New-Bootstrap.ps1 | 28 ++++--------------- 1 file changed, 6 insertions(+), 22 deletions(-) diff --git a/src/ALZ/Private/Deploy-Accelerator-Helpers/New-Bootstrap.ps1 b/src/ALZ/Private/Deploy-Accelerator-Helpers/New-Bootstrap.ps1 index 82259ae..13a47ac 100644 --- a/src/ALZ/Private/Deploy-Accelerator-Helpers/New-Bootstrap.ps1 +++ b/src/ALZ/Private/Deploy-Accelerator-Helpers/New-Bootstrap.ps1 @@ -248,39 +248,23 @@ function New-Bootstrap { } } - if ($iac -in @("bicep", "bicep-avm")) { - $starterModuleDefinition = $starterConfig.starter_modules.Value.$($inputConfig.starter_module_name.Value) - Copy-ParametersFileCollection -starterPath $starterModulePath -configFiles $starterModuleDefinition.deployment_files + if($iac -eq "bicep") { + Copy-ParametersFileCollection -starterPath $starterModulePath -configFiles $starterConfig.starter_modules.Value.$($inputConfig.starter_module_name.Value).deployment_files Set-ComputedConfiguration -configuration $starterConfiguration Edit-ALZConfigurationFilesInPlace -alzEnvironmentDestination $starterModulePath -configuration $starterConfiguration - if ($iac -eq "bicep-avm") { - $bicepAvmEnvConfiguration = Get-BicepAvmEnvironmentConfiguration -inputConfig $inputConfig - $combinedConfiguration = [PSCustomObject]@{} - - foreach ($property in $starterConfiguration.PSObject.Properties) { - $combinedConfiguration | Add-Member -NotePropertyName $property.Name -NotePropertyValue $property.Value - } - - foreach ($property in $bicepAvmEnvConfiguration.PSObject.Properties) { - $combinedConfiguration | Add-Member -NotePropertyName $property.Name -NotePropertyValue $property.Value -Force - } - - Write-JsonFile -jsonFilePath $starterBicepVarsPath -configuration $combinedConfiguration - } else { - Write-JsonFile -jsonFilePath $starterBicepVarsPath -configuration $starterConfiguration - } + Write-JsonFile -jsonFilePath $starterBicepVarsPath -configuration $starterConfiguration # Remove unrequired files - $foldersOrFilesToRetain = $starterModuleDefinition.folders_or_files_to_retain + $foldersOrFilesToRetain = $starterConfig.starter_modules.Value.$($inputConfig.starter_module_name.Value).folders_or_files_to_retain $foldersOrFilesToRetain += "parameters.json" $foldersOrFilesToRetain += "config" $foldersOrFilesToRetain += "starter-cache.json" - foreach ($deployment_file in $starterModuleDefinition.deployment_files) { + foreach($deployment_file in $starterConfig.starter_modules.Value.$($inputConfig.starter_module_name.Value).deployment_files) { $foldersOrFilesToRetain += $deployment_file.templateParametersSourceFilePath } - $subFoldersOrFilesToRemove = $starterModuleDefinition.subfolders_or_files_to_remove + $subFoldersOrFilesToRemove = $starterConfig.starter_modules.Value.$($inputConfig.starter_module_name.Value).subfolders_or_files_to_remove Remove-UnrequiredFileSet -path $starterModulePath -foldersOrFilesToRetain $foldersOrFilesToRetain -subFoldersOrFilesToRemove $subFoldersOrFilesToRemove -writeVerboseLogs:$writeVerboseLogs.IsPresent } From bffe91cba2e3cef751c4ca20557b4b39d8145412 Mon Sep 17 00:00:00 2001 From: Zach Trocinski Date: Thu, 20 Nov 2025 14:29:16 -0600 Subject: [PATCH 03/11] Add logic for bicep-avm folder replacement --- src/ALZ/Private/Deploy-Accelerator-Helpers/New-Bootstrap.ps1 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ALZ/Private/Deploy-Accelerator-Helpers/New-Bootstrap.ps1 b/src/ALZ/Private/Deploy-Accelerator-Helpers/New-Bootstrap.ps1 index 13a47ac..93bf9ca 100644 --- a/src/ALZ/Private/Deploy-Accelerator-Helpers/New-Bootstrap.ps1 +++ b/src/ALZ/Private/Deploy-Accelerator-Helpers/New-Bootstrap.ps1 @@ -248,7 +248,7 @@ function New-Bootstrap { } } - if($iac -eq "bicep") { + if ($iac -eq "bicep" -or $iac -eq "bicep-avm") { Copy-ParametersFileCollection -starterPath $starterModulePath -configFiles $starterConfig.starter_modules.Value.$($inputConfig.starter_module_name.Value).deployment_files Set-ComputedConfiguration -configuration $starterConfiguration Edit-ALZConfigurationFilesInPlace -alzEnvironmentDestination $starterModulePath -configuration $starterConfiguration @@ -258,9 +258,10 @@ function New-Bootstrap { $foldersOrFilesToRetain = $starterConfig.starter_modules.Value.$($inputConfig.starter_module_name.Value).folders_or_files_to_retain $foldersOrFilesToRetain += "parameters.json" $foldersOrFilesToRetain += "config" + $foldersOrFilesToRetain += ".config" $foldersOrFilesToRetain += "starter-cache.json" - foreach($deployment_file in $starterConfig.starter_modules.Value.$($inputConfig.starter_module_name.Value).deployment_files) { + foreach ($deployment_file in $starterConfig.starter_modules.Value.$($inputConfig.starter_module_name.Value).deployment_files) { $foldersOrFilesToRetain += $deployment_file.templateParametersSourceFilePath } From 12ac0b7898ae6df0ea690fd118f01a1952834c51 Mon Sep 17 00:00:00 2001 From: Zach Trocinski Date: Fri, 21 Nov 2025 13:58:09 -0600 Subject: [PATCH 04/11] Fix bug with being able to skip null values --- src/ALZ/Private/Config-Helpers/Remove-UnrequiredFileSet.ps1 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/ALZ/Private/Config-Helpers/Remove-UnrequiredFileSet.ps1 b/src/ALZ/Private/Config-Helpers/Remove-UnrequiredFileSet.ps1 index b6f3b46..1541db4 100644 --- a/src/ALZ/Private/Config-Helpers/Remove-UnrequiredFileSet.ps1 +++ b/src/ALZ/Private/Config-Helpers/Remove-UnrequiredFileSet.ps1 @@ -24,6 +24,10 @@ function Remove-UnrequiredFileSet { $fileRelativePath = $file.FullName.Replace($path, "").Replace("\", "/").TrimStart("/") $folderRelativePath = $file.Directory.FullName.Replace($path, "").Replace("\", "/").TrimStart("/") foreach ($folderOrFileToRetain in $foldersOrFilesToRetain) { + # Skip null or empty values + if ([string]::IsNullOrWhiteSpace($folderOrFileToRetain)) { + continue + } # If we have an exact match of the file name and path, always retain it. if ($folderOrFileToRetain.TrimStart("./") -eq $fileRelativePath) { if ($writeVerboseLogs) { From 4fe6f723d576cc3c57e8832f55e8c8a30464fa0e Mon Sep 17 00:00:00 2001 From: Jared Holgate Date: Wed, 26 Nov 2025 19:29:55 +0000 Subject: [PATCH 05/11] jared pedant changes --- .github/ISSUE_TEMPLATE/bug_report.yml | 4 +- .github/ISSUE_TEMPLATE/feature_request.yml | 4 +- README.md | 4 +- .../Convert-BicepConfigToInputConfig.ps1 | 19 --- .../Convert-HCLVariablesToInputConfig.ps1 | 28 ---- .../Config-Helpers/Request-SpecialInput.ps1 | 130 ------------------ src/ALZ/Private/Config-Helpers/Set-Config.ps1 | 2 - .../Get-BootstrapAndStarterConfig.ps1 | 7 +- .../New-Bootstrap.ps1 | 19 +-- src/ALZ/Public/Deploy-Accelerator.ps1 | 27 ++-- .../Unit/Public/Deploy-Accelerator.Tests.ps1 | 7 - 11 files changed, 22 insertions(+), 229 deletions(-) delete mode 100644 src/ALZ/Private/Config-Helpers/Request-SpecialInput.ps1 diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 954eb72..aac5567 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -46,10 +46,8 @@ body: description: Which starter module are you using? multiple: false options: - - bicep - complete + - bicep - platform_landing_zone - terraform - platform_landing_zone - - terraform - microsoft_cloud_for_sovereignty - - terraform - microsoft_cloud_for_financial_services - other - not relevant validations: diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml index 5d1c1d5..453ef60 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.yml +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -33,10 +33,8 @@ body: description: Which starter module are you using? multiple: false options: - - bicep - complete + - bicep - platform_landing_zone - terraform - platform_landing_zone - - terraform - microsoft_cloud_for_sovereignty - - terraform - microsoft_cloud_for_financial_services - other - not relevant validations: diff --git a/README.md b/README.md index 6f1ca7c..86173b0 100644 --- a/README.md +++ b/README.md @@ -15,8 +15,8 @@ This repository contains the PowerShell module and documentation for the Azure l The accelerators support multiple Infrastructure as Code approaches: - **terraform**: Terraform-based Azure Landing Zones -- **bicep**: Bicep-based Azure Landing Zones using the traditional [ALZ-Bicep](https://github.com/Azure/ALZ-Bicep) framework -- **bicep-avm**: Bicep-based Azure Landing Zones using the new [alz-bicep-accelerator](https://github.com/Azure/alz-bicep-accelerator) framework built on Azure Verified Modules +- **bicep**: Bicep-based Azure Landing Zones using the new [alz-bicep-accelerator](https://github.com/Azure/alz-bicep-accelerator) framework built on Azure Verified Modules +- **bicep-classic**: Bicep-based Azure Landing Zones using the classic [ALZ-Bicep](https://github.com/Azure/ALZ-Bicep) framework It is designed to be used as a template to enable you to get started quickly deploying ALZ with any of these approaches. diff --git a/src/ALZ/Private/Config-Helpers/Convert-BicepConfigToInputConfig.ps1 b/src/ALZ/Private/Config-Helpers/Convert-BicepConfigToInputConfig.ps1 index f589c38..b4a8222 100644 --- a/src/ALZ/Private/Config-Helpers/Convert-BicepConfigToInputConfig.ps1 +++ b/src/ALZ/Private/Config-Helpers/Convert-BicepConfigToInputConfig.ps1 @@ -4,9 +4,6 @@ function Convert-BicepConfigToInputConfig { [Parameter(Mandatory = $false)] [PSCustomObject]$bicepConfig, - [Parameter(Mandatory = $false)] - [PSCustomObject]$validators, - [Parameter(Mandatory = $false)] [PSCustomObject]$appendToObject = $null ) @@ -18,8 +15,6 @@ function Convert-BicepConfigToInputConfig { $configItems = $appendToObject } - Write-Verbose $validators - foreach ($variable in $bicepConfig.inputs.PSObject.Properties) { Write-Verbose "Parsing variable $($variable.Name)" $description = $variable.Value.description @@ -45,20 +40,6 @@ function Convert-BicepConfigToInputConfig { $configItem | Add-Member -NotePropertyName "DefaultValue" -NotePropertyValue $defaultValue } - if ($variable.Value.PSObject.Properties.Name -contains "validation") { - $validationType = $variable.Value.validation - $validator = $validators.PSObject.Properties[$validationType].Value - $description = "$description ($($validator.Description))" - Write-Verbose "Adding $($variable.Value.validation) validation for $($variable.Name). Validation type: $($validator.Type)" - if ($validator.Type -eq "AllowedValues") { - $configItem | Add-Member -NotePropertyName "AllowedValues" -NotePropertyValue $validator.AllowedValues - } - if ($validator.Type -eq "Valid") { - $configItem | Add-Member -NotePropertyName "Valid" -NotePropertyValue $validator.Valid - } - $configItem | Add-Member -NotePropertyName "Validator" -NotePropertyValue $validationType - } - if ($variable.Value.PSObject.Properties.Name -contains "targets") { $configItem | Add-Member -NotePropertyName "targets" -NotePropertyValue $variable.Value.targets } diff --git a/src/ALZ/Private/Config-Helpers/Convert-HCLVariablesToInputConfig.ps1 b/src/ALZ/Private/Config-Helpers/Convert-HCLVariablesToInputConfig.ps1 index dfde3d7..87500d9 100644 --- a/src/ALZ/Private/Config-Helpers/Convert-HCLVariablesToInputConfig.ps1 +++ b/src/ALZ/Private/Config-Helpers/Convert-HCLVariablesToInputConfig.ps1 @@ -7,9 +7,6 @@ function Convert-HCLVariablesToInputConfig { [Parameter(Mandatory = $false)] [string] $hclParserToolPath, - [Parameter(Mandatory = $false)] - [PSCustomObject]$validators, - [Parameter(Mandatory = $false)] [PSCustomObject]$appendToObject = $null ) @@ -32,19 +29,6 @@ function Convert-HCLVariablesToInputConfig { foreach ($variable in $terraformVariables.variable.PSObject.Properties) { if ($variable.Value[0].PSObject.Properties.Name -contains "description") { $description = $variable.Value[0].description - $validationTypeSplit = $description -split "\|" - - $hasValidation = $false - - if ($validationTypeSplit.Length -gt 1) { - $description = $validationTypeSplit[0].Trim() - } - - if ($validationTypeSplit.Length -eq 2) { - $splitItem = $validationTypeSplit[1].Trim() - $validationType = $splitItem - $hasValidation = $true - } } $configItem = [PSCustomObject]@{} @@ -55,18 +39,6 @@ function Convert-HCLVariablesToInputConfig { $configItem | Add-Member -NotePropertyName "DefaultValue" -NotePropertyValue $variable.Value[0].default } - if ($hasValidation) { - $validator = $validators.PSObject.Properties[$validationType].Value - $description = "$description ($($validator.Description))" - if ($validator.Type -eq "AllowedValues") { - $configItem | Add-Member -NotePropertyName "AllowedValues" -NotePropertyValue $validator.AllowedValues - } - if ($validator.Type -eq "Valid") { - $configItem | Add-Member -NotePropertyName "Valid" -NotePropertyValue $validator.Valid - } - $configItem | Add-Member -NotePropertyName "Validator" -NotePropertyValue $validationType - } - $configItem | Add-Member -NotePropertyName "Description" -NotePropertyValue $description Write-Verbose "Adding variable $($variable.Name) to the configuration..." diff --git a/src/ALZ/Private/Config-Helpers/Request-SpecialInput.ps1 b/src/ALZ/Private/Config-Helpers/Request-SpecialInput.ps1 deleted file mode 100644 index 133ce85..0000000 --- a/src/ALZ/Private/Config-Helpers/Request-SpecialInput.ps1 +++ /dev/null @@ -1,130 +0,0 @@ -function Request-SpecialInput { - [CmdletBinding(SupportsShouldProcess = $true)] - param ( - [Parameter(Mandatory = $false)] - [string] $type, - - [Parameter(Mandatory = $false)] - [PSCustomObject] $starterConfig, - - [Parameter(Mandatory = $false)] - [PSCustomObject] $bootstrapModules - ) - - if ($PSCmdlet.ShouldProcess("ALZ-Terraform module configuration", "modify")) { - - $result = "" - $options = @() - $aliasOptions = @() - $typeDescription = "" - - if($type -eq "iac") { - $options += @{ key = "bicep-avm"; name = "Bicep AVM"; description = "Bicep (New Framework)" } - $options += @{ key = "bicep"; name = "Bicep Classic"; description = "Bicep (Classic Framework)" } - $options += @{ key = "terraform"; name = "Terraform"; description = "Terraform" } - $typeDescription = "Infrastructure as Code (IaC) language" - } - - if($type -eq "bootstrap") { - if($bootstrapModules.PsObject.Properties.Name.Count -eq 0) { - $options += @{ key = "azuredevops"; name = "Azure DevOps"; description = "Azure DevOps" } - $options += @{ key = "github"; name = "GitHub"; description = "GitHub" } - $aliasOptions += @{ key = "alz_azuredevops"; name = "Azure DevOps"; description = "Azure DevOps" } - $aliasOptions += @{ key = "alz_github"; name = "GitHub"; description = "GitHub" } - } else { - foreach ($bootstrapModule in $bootstrapModules.PsObject.Properties) { - $options += @{ key = $bootstrapModule.Name; name = $bootstrapModule.Value.short_name; description = $bootstrapModule.Value.description } - foreach($alias in $bootstrapModule.Value.aliases) { - $aliasOptions += @{ key = $alias; name = $bootstrapModule.Value.short_name; description = $bootstrapModule.Value.description } - } - } - } - $typeDescription = "bootstrap module" - } - - if($type -eq "starter") { - foreach($starter in $starterConfig.starter_modules.Value.PsObject.Properties) { - if($starter.Name -eq $starterPipelineFolder) { - continue - } - - $options += @{ key = $starter.Name; name = $starter.Value.short_name; description = $starter.Value.description } - } - $typeDescription = "starter module" - } - - if($type -eq "inputConfigFilePath") { - $retryCount = 0 - $maxRetryCount = 3 - - if($IsWindows) { - while($retryCount -lt $maxRetryCount) { - Add-Type -AssemblyName System.Windows.Forms - $FileBrowser = New-Object System.Windows.Forms.OpenFileDialog -Property @{ - InitialDirectory = [Environment]::GetFolderPath("MyComputer") - Filter = "YAML or JSON (*.yml;*.yaml;*.json)|*.yml;*.yaml;*.json" - Title = "Select your input configuration file..." - MultiSelect = $true - } - - if($FileBrowser.ShowDialog() -eq "OK") { - $result = $FileBrowser.FileNames - Write-Verbose "Selected file(s): $result" - return $result - } else { - $retryCount++ - Write-InformationColored "You must select a file to continue..." -ForegroundColor Red -InformationAction Continue - } - } - } else { - $validPaths = $false - while(-not $validPath -and $retryCount -lt $maxRetryCount) { - $paths = Read-Host "Please enter the paths to your input configuration file. Separate multiple files with a comma..." - $result = $paths -split "," | ForEach-Object { $_.Trim() } - $validPaths = $true - foreach($file in $result) { - if(-not (Test-Path $file)) { - $validPaths = $false - Write-InformationColored "The path '$result' that you have entered does not exist. Please try again with a valid path..." -ForegroundColor Red -InformationAction Continue - } - } - if($validPaths) { - return $result - } else { - $retryCount++ - } - } - } - - if($retryCount -eq $maxRetryCount) { - Write-InformationColored "You have exceeded the maximum number of retries. Exiting..." -ForegroundColor Red -InformationAction Continue - throw "You have exceeded the maximum number of retries. Exiting..." - } - } - - # Add the options to the choices array - $choices = @() - $usedLetters = @() - foreach($option in $options) { - $letterIndex = 0 - - Write-Verbose "Checking for used letters in '$($option.name)'. Used letters: $usedLetters" - while($usedLetters -contains $option.name[$letterIndex].ToString().ToLower()) { - $letterIndex++ - } - - $usedLetters += $option.name[$letterIndex].ToString().ToLower() - $option.name = $option.name.Insert($letterIndex, "&") - $choices += New-Object System.Management.Automation.Host.ChoiceDescription $option.name, $option.description - } - - $message = "Please select the $typeDescription you would like to use." - $title = "Choose $typeDescription" - $resultIndex = $host.ui.PromptForChoice($title, $message, $choices, 0) - $result = $options[$resultIndex].key - - Write-InformationColored "You selected '$result'. Continuing with deployment..." -ForegroundColor Green -InformationAction Continue - - return $result - } -} diff --git a/src/ALZ/Private/Config-Helpers/Set-Config.ps1 b/src/ALZ/Private/Config-Helpers/Set-Config.ps1 index 90eb91c..d1aacad 100644 --- a/src/ALZ/Private/Config-Helpers/Set-Config.ps1 +++ b/src/ALZ/Private/Config-Helpers/Set-Config.ps1 @@ -143,8 +143,6 @@ function Set-Config { continue } - # TODO: Add validation here... - # Use the default value if no input config is supplied if($configurationValue.Value.PSObject.Properties.Name -match "DefaultValue") { Write-Verbose "Input not supplied, so using default value of $($configurationValue.Value.DefaultValue) for $($configurationValue.Name)" diff --git a/src/ALZ/Private/Deploy-Accelerator-Helpers/Get-BootstrapAndStarterConfig.ps1 b/src/ALZ/Private/Deploy-Accelerator-Helpers/Get-BootstrapAndStarterConfig.ps1 index 041a985..26c8fa6 100644 --- a/src/ALZ/Private/Deploy-Accelerator-Helpers/Get-BootstrapAndStarterConfig.ps1 +++ b/src/ALZ/Private/Deploy-Accelerator-Helpers/Get-BootstrapAndStarterConfig.ps1 @@ -22,22 +22,18 @@ function Get-BootstrapAndStarterConfig { $starterConfigFilePath = "" $bootstrapDetails = $null - $validationConfig = $null $zonesSupport = $null - # Get the bootstap configuration + # Get the bootstrap configuration $bootstrapConfigFullPath = Join-Path $bootstrapPath $bootstrapConfigPath Write-Verbose "Bootstrap config path $bootstrapConfigFullPath" $bootstrapConfig = Get-ALZConfig -configFilePath $bootstrapConfigFullPath - $validationConfig = $bootstrapConfig.validators.Value # Get the supported regions and availability zones Write-Verbose "Getting Supported Regions and Availability Zones with Terraform" $regionsAndZones = Get-AzureRegionData -toolsPath $toolsPath Write-Verbose "Supported Regions: $($regionsAndZones.supportedRegions)" $zonesSupport = $regionsAndZones.zonesSupport - $azureLocationValidator = $validationConfig.PSObject.Properties["azure_location"].Value - $azureLocationValidator.AllowedValues.Values = $regionsAndZones.supportedRegions # Get the available bootstrap modules $bootstrapModules = $bootstrapConfig.bootstrap_modules.Value @@ -76,7 +72,6 @@ function Get-BootstrapAndStarterConfig { starterModuleSourceFolder = $starterModuleSourceFolder starterReleaseArtifactName = $starterReleaseArtifactName starterConfigFilePath = $starterConfigFilePath - validationConfig = $validationConfig zonesSupport = $zonesSupport } } diff --git a/src/ALZ/Private/Deploy-Accelerator-Helpers/New-Bootstrap.ps1 b/src/ALZ/Private/Deploy-Accelerator-Helpers/New-Bootstrap.ps1 index 93bf9ca..94f4db0 100644 --- a/src/ALZ/Private/Deploy-Accelerator-Helpers/New-Bootstrap.ps1 +++ b/src/ALZ/Private/Deploy-Accelerator-Helpers/New-Bootstrap.ps1 @@ -7,9 +7,6 @@ function New-Bootstrap { [Parameter(Mandatory = $false)] [PSCustomObject] $bootstrapDetails, - [Parameter(Mandatory = $false)] - [PSCustomObject] $validationConfig, - [Parameter(Mandatory = $false)] [PSCustomObject] $inputConfig, @@ -84,10 +81,8 @@ function New-Bootstrap { if ($hasStarter) { if ($inputConfig.starter_module_name.Value -eq "") { - $inputConfig.starter_module_name = @{ - Value = Request-SpecialInput -type "starter" -starterConfig $starterConfig - Source = "user" - } + Write-InformationColored "No starter module has been specified. Please supply the starter module you wish to deploy..." -ForegroundColor Red -InformationAction Continue + throw "No starter module has been specified. Please supply the starter module you wish to deploy..." } $chosenStarterConfig = $starterConfig.starter_modules.Value.$($inputConfig.starter_module_name.Value) @@ -128,7 +123,7 @@ function New-Bootstrap { Write-Verbose "Getting the bootstrap configuration..." $terraformFiles = Get-ChildItem -Path $bootstrapModulePath -Filter "*.tf" -File foreach ($terraformFile in $terraformFiles) { - $bootstrapParameters = Convert-HCLVariablesToInputConfig -targetVariableFile $terraformFile.FullName -hclParserToolPath $hclParserToolPath -validators $validationConfig -appendToObject $bootstrapParameters + $bootstrapParameters = Convert-HCLVariablesToInputConfig -targetVariableFile $terraformFile.FullName -hclParserToolPath $hclParserToolPath -appendToObject $bootstrapParameters } # Getting the configuration for the starter module user input @@ -139,12 +134,12 @@ function New-Bootstrap { if ($iac -eq "terraform") { $terraformFiles = Get-ChildItem -Path $starterRootModuleFolderPath -Filter "*.tf" -File foreach ($terraformFile in $terraformFiles) { - $starterParameters = Convert-HCLVariablesToInputConfig -targetVariableFile $terraformFile.FullName -hclParserToolPath $hclParserToolPath -validators $validationConfig -appendToObject $starterParameters + $starterParameters = Convert-HCLVariablesToInputConfig -targetVariableFile $terraformFile.FullName -hclParserToolPath $hclParserToolPath -appendToObject $starterParameters } } - if ($iac -in @("bicep", "bicep-avm")) { - $starterParameters = Convert-BicepConfigToInputConfig -bicepConfig $starterConfig.starter_modules.Value.$($inputConfig.starter_module_name.Value) -validators $validationConfig + if ($iac -like "bicep*") { + $starterParameters = Convert-BicepConfigToInputConfig -bicepConfig $starterConfig.starter_modules.Value.$($inputConfig.starter_module_name.Value) } } @@ -248,7 +243,7 @@ function New-Bootstrap { } } - if ($iac -eq "bicep" -or $iac -eq "bicep-avm") { + if ($iac -like "bicep*") { Copy-ParametersFileCollection -starterPath $starterModulePath -configFiles $starterConfig.starter_modules.Value.$($inputConfig.starter_module_name.Value).deployment_files Set-ComputedConfiguration -configuration $starterConfiguration Edit-ALZConfigurationFilesInPlace -alzEnvironmentDestination $starterModulePath -configuration $starterConfiguration diff --git a/src/ALZ/Public/Deploy-Accelerator.ps1 b/src/ALZ/Public/Deploy-Accelerator.ps1 index 5624563..fe53e72 100644 --- a/src/ALZ/Public/Deploy-Accelerator.ps1 +++ b/src/ALZ/Public/Deploy-Accelerator.ps1 @@ -22,7 +22,7 @@ function Deploy-Accelerator { [Parameter( Mandatory = $false, - HelpMessage = "[REQUIRED] The infrastructure as code type to target. Supported options are 'bicep', 'bicep-avm', 'terraform' or 'local'. Environment variable: ALZ_iac_type. Config file input: iac_type.")] + HelpMessage = "[REQUIRED] The infrastructure as code type to target. Supported options are 'bicep', 'bicep-classic', 'terraform' or 'local'. Environment variable: ALZ_iac_type. Config file input: iac_type.")] [Alias("i")] [Alias("iac")] [string] $iac_type = "", @@ -216,8 +216,8 @@ function Deploy-Accelerator { if ($null -ne $envInputConfigPaths -and $envInputConfigPaths -ne "") { $inputConfigFilePaths = $envInputConfigPaths -split "," } else { - Write-InformationColored "No input configuration file path has been provided. Please provide the path(s) to your configuration file(s)..." -ForegroundColor Yellow -InformationAction Continue - $inputConfigFilePaths = @(Request-SpecialInput -type "inputConfigFilePath") + Write-InformationColored "No input configuration file path has been provided. Please provide the path(s) to your configuration file(s)..." -ForegroundColor Red -InformationAction Continue + throw "No input configuration file path has been provided. Please provide the path(s) to your configuration file(s)..." } } @@ -247,15 +247,13 @@ function Deploy-Accelerator { } $inputConfig = Convert-ParametersToInputConfig -inputConfig $inputConfig -parameters $parametersWithValues - # Get the IAC type if not specified + # Throw if IAC type is not specified if ($inputConfig.iac_type.Value -eq "") { - $inputConfig.iac_type = @{ - Value = Request-SpecialInput -type "iac" - Source = "user" - } + Write-InformationColored "No Infrastructure as Code type has been specified. Please supply the IAC type you wish to deploy..." -ForegroundColor Red -InformationAction Continue + throw"No Infrastructure as Code type has been specified. Please supply the IAC type you wish to deploy..." } - if ($inputConfig.iac_type.Value -eq "bicep") { + if ($inputConfig.iac_type.Value -like "bicep*") { Write-InformationColored "Although you have selected Bicep, the Accelerator leverages the Terraform tool to bootstrap your Version Control System and Azure. This will not impact your choice of Bicep post this initial bootstrap. Please refer to our documentation for further details..." -ForegroundColor Yellow -InformationAction Continue } @@ -288,21 +286,18 @@ function Deploy-Accelerator { # Setup the variables for bootstrap and starter modules $hasStarterModule = $false - $starterModuleUrl = $bicepLegacyUrl + $starterModuleUrl = "" $starterModuleSourceFolder = "." $starterReleaseArtifactName = "" $starterConfigFilePath = "" $bootstrapDetails = $null - $validationConfig = $null $zonesSupport = $null # Request the bootstrap type if not already specified if($inputConfig.bootstrap_module_name.Value -eq "") { - $inputConfig.bootstrap_module_name = @{ - Value = Request-SpecialInput -type "bootstrap" -bootstrapModules $bootstrapModules - Source = "user" - } + Write-InformationColored "No bootstrap module has been specified. Please supply the bootstrap module you wish to deploy..." -ForegroundColor Red -InformationAction Continue + throw "No bootstrap module has been specified. Please supply the bootstrap module you wish to deploy..." } $bootstrapAndStarterConfig = Get-BootstrapAndStarterConfig ` @@ -318,7 +313,6 @@ function Deploy-Accelerator { $starterModuleSourceFolder = $bootstrapAndStarterConfig.starterModuleSourceFolder $starterReleaseArtifactName = $bootstrapAndStarterConfig.starterReleaseArtifactName $starterConfigFilePath = $bootstrapAndStarterConfig.starterConfigFilePath - $validationConfig = $bootstrapAndStarterConfig.validationConfig $zonesSupport = $bootstrapAndStarterConfig.zonesSupport # Download the starter modules @@ -365,7 +359,6 @@ function Deploy-Accelerator { New-Bootstrap ` -iac $inputConfig.iac_type.Value ` -bootstrapDetails $bootstrapDetails ` - -validationConfig $validationConfig ` -inputConfig $inputConfig ` -bootstrapTargetPath $bootstrapTargetPath ` -bootstrapRelease $bootstrapReleaseTag ` diff --git a/src/Tests/Unit/Public/Deploy-Accelerator.Tests.ps1 b/src/Tests/Unit/Public/Deploy-Accelerator.Tests.ps1 index 3a8df37..75eb7ac 100644 --- a/src/Tests/Unit/Public/Deploy-Accelerator.Tests.ps1 +++ b/src/Tests/Unit/Public/Deploy-Accelerator.Tests.ps1 @@ -130,13 +130,6 @@ InModuleScope 'ALZ' { Mock -CommandName Get-BootstrapAndStarterConfig -MockWith { @{ "hasStarterModule" = $true - "validationConfig" = @{ - "azure_location" = @{ - "AllowedValues" = @{ - "Values" = @( "uksouth", "ukwest" ) - } - } - } } } From 7d30a263685add917060a5bc9d8291390eebd46f Mon Sep 17 00:00:00 2001 From: Jared Holgate Date: Wed, 26 Nov 2025 19:32:56 +0000 Subject: [PATCH 06/11] add config file path input --- src/ALZ/Public/Deploy-Accelerator.ps1 | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/ALZ/Public/Deploy-Accelerator.ps1 b/src/ALZ/Public/Deploy-Accelerator.ps1 index fe53e72..b0f79a2 100644 --- a/src/ALZ/Public/Deploy-Accelerator.ps1 +++ b/src/ALZ/Public/Deploy-Accelerator.ps1 @@ -339,17 +339,21 @@ function Deploy-Accelerator { } # Set computed interface inputs + $inputConfig | Add-Member -MemberType NoteProperty -Name "bicep_config_file_path" -Value @{ + Value = $starterConfigFilePath + Source = "calculated" + } $inputConfig | Add-Member -MemberType NoteProperty -Name "on_demand_folder_repository" -Value @{ Value = $starterModuleUrl - Source = "calaculated" + Source = "calculated" } $inputConfig | Add-Member -MemberType NoteProperty -Name "on_demand_folder_artifact_name" -Value @{ Value = $starterReleaseArtifactName - Source = "calaculated" + Source = "calculated" } $inputConfig | Add-Member -MemberType NoteProperty -Name "release_version" -Value @{ Value = ($starterReleaseTag -eq "local" ? $inputConfig.starter_module_version.Value : $starterReleaseTag) - Source = "calaculated" + Source = "calculated" } # Run the bootstrap From f14789e82448ecd64b35e572ca468f8193173af7 Mon Sep 17 00:00:00 2001 From: Jared Holgate Date: Wed, 26 Nov 2025 19:56:05 +0000 Subject: [PATCH 07/11] Add debug line --- src/ALZ/Private/Deploy-Accelerator-Helpers/Get-StarterConfig.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ALZ/Private/Deploy-Accelerator-Helpers/Get-StarterConfig.ps1 b/src/ALZ/Private/Deploy-Accelerator-Helpers/Get-StarterConfig.ps1 index 44ce03d..d8ec27c 100644 --- a/src/ALZ/Private/Deploy-Accelerator-Helpers/Get-StarterConfig.ps1 +++ b/src/ALZ/Private/Deploy-Accelerator-Helpers/Get-StarterConfig.ps1 @@ -13,6 +13,7 @@ function Get-StarterConfig { $starterConfigFullPath = Join-Path $starterPath $starterConfigPath Write-Verbose "Starter config path $starterConfigFullPath" $starterConfig = Get-ALZConfig -configFilePath $starterConfigFullPath + Write-Verbose "Starter configuration loaded." return $starterConfig } From 41884e2b83439b55cf818fd67c8ea422fe4bc15a Mon Sep 17 00:00:00 2001 From: Jared Holgate Date: Wed, 26 Nov 2025 21:45:01 +0000 Subject: [PATCH 08/11] fixy mcfixington --- .../Config-Helpers/Remove-TerraformMetaFileSet.ps1 | 4 +++- .../Copy-ParameterFileCollection.ps1 | 1 + .../Deploy-Accelerator-Helpers/New-Bootstrap.ps1 | 14 ++++++++++++-- src/ALZ/Public/Deploy-Accelerator.ps1 | 11 +++++++++-- 4 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/ALZ/Private/Config-Helpers/Remove-TerraformMetaFileSet.ps1 b/src/ALZ/Private/Config-Helpers/Remove-TerraformMetaFileSet.ps1 index 72023f5..1eed2be 100644 --- a/src/ALZ/Private/Config-Helpers/Remove-TerraformMetaFileSet.ps1 +++ b/src/ALZ/Private/Config-Helpers/Remove-TerraformMetaFileSet.ps1 @@ -19,8 +19,10 @@ function Remove-TerraformMetaFileSet { ) if ($PSCmdlet.ShouldProcess("Remove files", "modify")) { + Write-Verbose "Removing Terraform meta files and folders from $path" + if ($terraformFilesOrFoldersToRemove.Length -eq 0 ) { - Write-Verbose "No folders or files specified, so not removing aything from $path" + Write-Verbose "No folders or files specified, so not removing anything from $path" return } diff --git a/src/ALZ/Private/Deploy-Accelerator-Helpers/Copy-ParameterFileCollection.ps1 b/src/ALZ/Private/Deploy-Accelerator-Helpers/Copy-ParameterFileCollection.ps1 index 99f48a2..a5f189a 100644 --- a/src/ALZ/Private/Deploy-Accelerator-Helpers/Copy-ParameterFileCollection.ps1 +++ b/src/ALZ/Private/Deploy-Accelerator-Helpers/Copy-ParameterFileCollection.ps1 @@ -17,6 +17,7 @@ function Copy-ParametersFileCollection { if (-not (Test-Path $destinationFolder)) { New-Item -ItemType Directory -Path $destinationFolder -Force | Out-String | Write-Verbose } + Write-Verbose "Copying parameter file from $sourcePath to $destinationPath" Copy-Item -Path $sourcePath -Destination $destinationPath -Recurse -Force | Out-String | Write-Verbose } } else { diff --git a/src/ALZ/Private/Deploy-Accelerator-Helpers/New-Bootstrap.ps1 b/src/ALZ/Private/Deploy-Accelerator-Helpers/New-Bootstrap.ps1 index 94f4db0..3ecfff2 100644 --- a/src/ALZ/Private/Deploy-Accelerator-Helpers/New-Bootstrap.ps1 +++ b/src/ALZ/Private/Deploy-Accelerator-Helpers/New-Bootstrap.ps1 @@ -55,7 +55,11 @@ function New-Bootstrap { [Parameter(Mandatory = $false)] [string[]] - $starterAdditionalFiles = @() + $starterAdditionalFiles = @(), + + [Parameter(Mandatory = $false)] + [switch] + $cleanBootstrapFolder ) if ($PSCmdlet.ShouldProcess("ALZ-Terraform module configuration", "modify")) { @@ -63,6 +67,10 @@ function New-Bootstrap { $bootstrapPath = Join-Path $bootstrapTargetPath $bootstrapRelease $starterPath = Join-Path $starterTargetPath $starterRelease $bootstrapModulePath = Join-Path -Path $bootstrapPath -ChildPath $bootstrapDetails.Value.location + if($cleanBootstrapFolder.IsPresent) { + Write-Verbose "Cleaning bootstrap folder of Terraform meta files as requested..." + Remove-TerraformMetaFileSet -path $bootstrapModulePath -writeVerboseLogs:$writeVerboseLogs.IsPresent + } Write-Verbose "Bootstrap Module Path: $bootstrapModulePath" @@ -244,7 +252,9 @@ function New-Bootstrap { } if ($iac -like "bicep*") { - Copy-ParametersFileCollection -starterPath $starterModulePath -configFiles $starterConfig.starter_modules.Value.$($inputConfig.starter_module_name.Value).deployment_files + if($iac -ne "bicep") { + Copy-ParametersFileCollection -starterPath $starterModulePath -configFiles $starterConfig.starter_modules.Value.$($inputConfig.starter_module_name.Value).deployment_files + } Set-ComputedConfiguration -configuration $starterConfiguration Edit-ALZConfigurationFilesInPlace -alzEnvironmentDestination $starterModulePath -configuration $starterConfiguration Write-JsonFile -jsonFilePath $starterBicepVarsPath -configuration $starterConfiguration diff --git a/src/ALZ/Public/Deploy-Accelerator.ps1 b/src/ALZ/Public/Deploy-Accelerator.ps1 index b0f79a2..0ebe70f 100644 --- a/src/ALZ/Public/Deploy-Accelerator.ps1 +++ b/src/ALZ/Public/Deploy-Accelerator.ps1 @@ -183,7 +183,13 @@ function Deploy-Accelerator { HelpMessage = "[OPTIONAL] Determines whether to skip the requirements check for the ALZ PowerShell Module version only. This is not recommended." )] [Alias("skipAlzModuleVersionRequirementsCheck")] - [switch] $skip_alz_module_version_requirements_check + [switch] $skip_alz_module_version_requirements_check, + + [Parameter( + Mandatory = $false, + HelpMessage = "[OPTIONAL] Determines whether Clean the bootstrap folder of Terraform meta files. Only use for development purposes." + )] + [switch] $cleanBootstrapFolder ) $ProgressPreference = "SilentlyContinue" @@ -377,7 +383,8 @@ function Deploy-Accelerator { -hclParserToolPath $hclParserToolPath ` -convertTfvarsToJson:$inputConfig.convert_tfvars_to_json.Value ` -inputConfigFilePaths $inputConfigFilePaths ` - -starterAdditionalFiles $inputConfig.starter_additional_files.Value + -starterAdditionalFiles $inputConfig.starter_additional_files.Value ` + -cleanBootstrapFolder:$cleanBootstrapFolder.IsPresent } $ProgressPreference = "Continue" From 9426dce2ea45ffbdacffc1c9d1f523eeca80ac72 Mon Sep 17 00:00:00 2001 From: Jared Holgate Date: Thu, 27 Nov 2025 13:06:29 +0000 Subject: [PATCH 09/11] typo --- src/ALZ/Private/Deploy-Accelerator-Helpers/New-Bootstrap.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ALZ/Private/Deploy-Accelerator-Helpers/New-Bootstrap.ps1 b/src/ALZ/Private/Deploy-Accelerator-Helpers/New-Bootstrap.ps1 index 3ecfff2..82ef38d 100644 --- a/src/ALZ/Private/Deploy-Accelerator-Helpers/New-Bootstrap.ps1 +++ b/src/ALZ/Private/Deploy-Accelerator-Helpers/New-Bootstrap.ps1 @@ -114,7 +114,7 @@ function New-Bootstrap { # Add the root module folder to bootstrap input config $inputConfig | Add-Member -NotePropertyName "root_module_folder_relative_path" -NotePropertyValue @{ Value = $starterRootModuleFolder - Source = "caluated" + Source = "calculated" } # Set the starter root module folder full path From ac8bdaadc551211b230b34b4f3d678878a28825c Mon Sep 17 00:00:00 2001 From: Jared Holgate Date: Thu, 27 Nov 2025 13:33:01 +0000 Subject: [PATCH 10/11] tidy --- src/ALZ/Private/Deploy-Accelerator-Helpers/New-Bootstrap.ps1 | 1 - 1 file changed, 1 deletion(-) diff --git a/src/ALZ/Private/Deploy-Accelerator-Helpers/New-Bootstrap.ps1 b/src/ALZ/Private/Deploy-Accelerator-Helpers/New-Bootstrap.ps1 index 82ef38d..3e2d63f 100644 --- a/src/ALZ/Private/Deploy-Accelerator-Helpers/New-Bootstrap.ps1 +++ b/src/ALZ/Private/Deploy-Accelerator-Helpers/New-Bootstrap.ps1 @@ -264,7 +264,6 @@ function New-Bootstrap { $foldersOrFilesToRetain += "parameters.json" $foldersOrFilesToRetain += "config" $foldersOrFilesToRetain += ".config" - $foldersOrFilesToRetain += "starter-cache.json" foreach ($deployment_file in $starterConfig.starter_modules.Value.$($inputConfig.starter_module_name.Value).deployment_files) { $foldersOrFilesToRetain += $deployment_file.templateParametersSourceFilePath From f6e5bb3bac9667ff095dcb979949e73c8ed1223d Mon Sep 17 00:00:00 2001 From: Jared Holgate Date: Thu, 27 Nov 2025 20:49:23 +0000 Subject: [PATCH 11/11] don't delete state --- .../Private/Deploy-Accelerator-Helpers/New-Bootstrap.ps1 | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/ALZ/Private/Deploy-Accelerator-Helpers/New-Bootstrap.ps1 b/src/ALZ/Private/Deploy-Accelerator-Helpers/New-Bootstrap.ps1 index 3e2d63f..dd653b9 100644 --- a/src/ALZ/Private/Deploy-Accelerator-Helpers/New-Bootstrap.ps1 +++ b/src/ALZ/Private/Deploy-Accelerator-Helpers/New-Bootstrap.ps1 @@ -69,7 +69,12 @@ function New-Bootstrap { $bootstrapModulePath = Join-Path -Path $bootstrapPath -ChildPath $bootstrapDetails.Value.location if($cleanBootstrapFolder.IsPresent) { Write-Verbose "Cleaning bootstrap folder of Terraform meta files as requested..." - Remove-TerraformMetaFileSet -path $bootstrapModulePath -writeVerboseLogs:$writeVerboseLogs.IsPresent + Remove-TerraformMetaFileSet -path $bootstrapModulePath -writeVerboseLogs:$writeVerboseLogs.IsPresent -terraformFilesOrFoldersToRemove @( + "terraform.tfstate.backup", + ".terraform", + "terraform.tfvars", + ".terraform.lock.hcl" + ) } Write-Verbose "Bootstrap Module Path: $bootstrapModulePath"