Repository navigation
feat(deploy-accelerator): support renamed architecture definition files - #541
Open
Git-PrinceNagar wants to merge 6 commits into
Open
Git-PrinceNagar wants to merge 6 commits into
Git-PrinceNagar wants to merge 6 commits into
Conversation
added 6 commits
November 25, 2026 12:06
Deploy-Accelerator copies config/lib on top of the starter lib, so a renamed
architecture file sat next to the starter's alz_custom file while the bootstrap
kept reading the default terraform_architecture_file_path. The bootstrap then
built the intermediate root management group from the wrong file, or the library
held two architectures with the same name.
When terraform_architecture_file_path is not supplied, New-Bootstrap now looks
for *.alz_architecture_definition.{json,yaml,yml} files in the starter
additional files whose name matches management_group_settings.architecture_name
(or the starter default file's name). A single match outside the default path
is passed to the bootstrap, and the starter default file is removed when it
declares the same architecture. More than one match stops with an error.
actions_bootstrap.ps1 installs powershell-yaml so the new tests can parse YAML
architecture files on the CI runner.
Refs Azure/Azure-Landing-Zones#4068
…g architecture files Review follow-up for the renamed architecture file support. - Take the target architecture name from the starter code (a hardcoded architecture_name, the input, or the optional() default) so a rerun after the default file was removed resolves the same file. - Only count files in the lib folder, matched with the lower-case extensions the bootstrap reads, and leave everything unchanged when a user file lands on the default path, so the dedupe can never remove the user's own file. - Skip files that do not parse or have no text name, and warn instead of failing when powershell-yaml is not loaded. - Keep the default path when the bootstrap state already manages a different intermediate root management group; switching would replace it. - Warn when the default file is missing from a reused starter folder. Refs Azure/Azure-Landing-Zones#4068
…cond review - Compare the default path case-insensitively on every OS (macOS file systems are case-insensitive) and require the lib folder name to match exactly. - Stop with an error when the bootstrap state manages a root management group that neither the selected file nor the default uses; read only managed, non-deposed state instances and skip resolution when the state is unreadable or names more than one root. - Ignore architecture_name in block comments and expressions in starter code. - Count a file once when two lib folders copy it to the same destination. - Skip resolution when TF_VAR_management_group_settings overrides the input. Refs Azure/Azure-Landing-Zones#4068
…iles apart - Strip heredoc strings as well as block comments before reading the architecture name from the starter code. - Deduplicate copied architecture files by their exact destination, so files whose paths differ only in letter case are both counted. Refs Azure/Azure-Landing-Zones#4068
… and give working recovery advice - Read terraform.tfstate inside Resolve-TerraformArchitectureFile after a renamed file is selected. Users without a renamed architecture file no longer get a state warning, and an empty or unreadable state keeps the default path with a warning. - Parse the state with -AsHashtable so keys that differ only in case do not fail the read. - When the default architecture file is missing, tell users to add their file to their lib folder at the default path or set terraform_architecture_file_path. -replaceFiles only applies to the override folders, so it did not restore the file for release downloads. - Use -LiteralPath when removing the starter default file. - Add New-Bootstrap tests for unreadable and empty state and for a default layout with unreadable state; rename a test whose name did not match its setup. Refs Azure/Azure-Landing-Zones#4068
…nd say move, not add - Tell users to move their architecture file to the default path inside their lib folder. Copying it there would leave two files declaring the same architecture, which alzlib rejects. - Treat a state path that exists but is not a readable JSON object, including a folder, as unknown, so the default path is kept with a warning. - Add tests for state that is a JSON array and for a folder at the state path; fix a test title. Refs Azure/Azure-Landing-Zones#4068
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request
Issue
Refs Azure/Azure-Landing-Zones#4068
Description
Deploy-Acceleratornow passes a renamed architecture definition file to the bootstrap and removes the starter's default copy when both declare the same architecture. Users who keep the default file name, or who setterraform_architecture_file_path, get the same output as before.Root cause
New-Bootstrapcopiesconfig/libover the starter'slibwithCopy-Item -Recurse -Force. That merges the folders, so the starter'slib/architecture_definitions/alz_custom.alz_architecture_definition.yamlstays next to the user's renamed file. The bootstrap reads onlyterraform_architecture_file_path, and its default points at the starter file.name: alz_custom, the library holds two architectures with one name and the starter plan fails.The documented workaround is to set
terraform_architecture_file_pathand delete the duplicate by hand.Change
New private function
Resolve-TerraformArchitectureFile, called fromNew-Bootstrap:terraform_architecture_file_pathand the user has not set it through the inputs,TF_VAR_terraform_architecture_file_pathorTF_VAR_management_group_settings.*.alz_architecture_definition.json,.yamland.ymlfiles inside an additional folder namedlib. A user file on the default path keeps today's behaviour.architecture_namein the starter's root.tffiles, thenmanagement_group_settings.architecture_namefrom the inputs, then the starter'soptional(string, ...)default, then thenamein the starter's default file.powershell-yamlmodule when a YAML file must be read, keeps the default path and logs a warning.terraform.tfstatein the bootstrap folder. If the state manages an intermediate root management group that differs from the selected file's root, the module does not switch. It keeps the default path with a warning when the default file uses the recorded root, and stops with an error otherwise. Switching would replace the management group, so users opt in by settingterraform_architecture_file_path. State that is empty, cannot be parsed, is not a JSON object, is a folder or names more than one root also keeps the default path with a warning.New-Bootstrapdeletes the starter's default file only when it declares the same architecture name as the selected file. User files are never deleted.libfolder, so only one file declares the architecture, or to setterraform_architecture_file_path.actions_bootstrap.ps1installspowershell-yaml0.4.12 because the new tests import it and theubuntu-latestimage does not ship it. #538 adds the same entry, so whichever PR merges second should keep one copy.523 of the 760 added lines are tests.
Evidence
Same inputs for both runs. The user's
libholdscontoso.alz_architecture_definition.yamlwithname: alz_custom. Each run wasDeploy-Acceleratorwith the bootstrap Terraform step stubbed, thenterraform planon the starter folder it prepared.v7.1.5 writes
terraform_architecture_file_path = lib/architecture_definitions/alz_custom.alz_architecture_definition.yaml, and the starter plan fails:This branch writes
terraform_architecture_file_path = lib/architecture_definitions/contoso.alz_architecture_definition.yaml, leaves only the contoso file in the starter library, and the starter plan succeeds:Backward compatibility
terraform_architecture_file_pathtakes the same early exit.No changes.local_filecreate and onelocal_filedelete. The management group kept its name, display name and parent, and the plan after apply showedNo changes.Deliberately not changed
architecture_namedefault and thealz_customfile name in the starter.Testing
Invoke-Build -File ./src/ALZ.build.ps1on PowerShell 7.7, Windows, Pester 5.4.0: 90 tests pass, analyzer and formatting clean, coverage gate passes. Not run locally on Linux; the PR workflow builds onubuntu-latest.TF_VARskips, each made at least one of the tests aimed at that rule fail. Most ran on earlier commits of this branch.Deploy-Acceleratorwith the bootstrap Terraform step stubbed, for v7.1.5 and this branch, with the default and renamed configs.alz_localbootstrap in a test tenant under a unique root management group, on an earlier commit of this branch: deployed v7.1.5, 112 resources, re-planNo changes. This branch with the same inputs plannedNo changes. This branch with the renamed file applied the twolocal_filechanges, re-planNo changes. All 112 resources were then destroyed, and a separate inventory found nothing left.terraform planfor both versions as shown above, not applied.New-Bootstrapruns the same code for all three, and they share thefile_manipulationmodule that reads the path. A live run where the state root differs from the selected file; unit tests cover that guard.License
By submitting this pull request, I confirm that my contribution is made under the terms of the projects associated license.