diff --git a/.github/workflows/PullRequest.yml b/.github/workflows/PullRequest.yml index 28e0ddd..0b6aa08 100644 --- a/.github/workflows/PullRequest.yml +++ b/.github/workflows/PullRequest.yml @@ -32,7 +32,7 @@ jobs: shell: pwsh run: Invoke-Build -File .\src\ALZ.build.ps1 - name: Upload pester results - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: pester-results path: .\src\Artifacts\testOutput diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 25cfddd..98755d3 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -48,18 +48,18 @@ Example folder structure: ┗ 📂acc ┣ 📂bicep ┃ ┣ 📂config - ┃ ┃ ┣ 📜inputs-azuredevops.yaml # ./docs/wiki/examples/powershell-inputs/inputs-azure-devops-bicep-complete.yaml - ┃ ┃ ┣ 📜inputs-github.yaml # ./docs/wiki/examples/powershell-inputs/inputs-github-bicep-complete.yaml - ┃ ┃ ┗ 📜inputs-local.yaml # ./docs/wiki/examples/powershell-inputs/inputs-local-bicep-complete.yaml + ┃ ┃ ┣ 📜inputs-azure-devops.yaml + ┃ ┃ ┣ 📜inputs-github.yaml + ┃ ┃ ┗ 📜inputs-local.yaml ┃ ┗ 📂output ┃ ┣ 📂azuredevops ┃ ┣ 📂github ┃ ┗ 📂local ┗ 📂terraform ┣ 📂config - ┃ ┣ 📜inputs-azuredevops.yaml # ./docs/wiki/examples/powershell-inputs/inputs-azure-devops-terraform-complete.yaml - ┃ ┣ 📜inputs-github.yaml # ./docs/wiki/examples/powershell-inputs/inputs-github-terraform-complete.yaml - ┃ ┗ 📜inputs-local.yaml # ./docs/wiki/examples/powershell-inputs/inputs-local-terraform-complete.yaml + ┃ ┣ 📜inputs-azure-devops.yaml + ┃ ┣ 📜inputs-github.yaml + ┃ ┗ 📜inputs-local.yaml ┗ 📂output ┣ 📂azuredevops ┣ 📂github @@ -92,21 +92,15 @@ git clone https://github.com/Azure/ALZ-PowerShell-Module git clone https://github.com/Azure/alz-terraform-accelerator cd / -$exampleFolder = "$targetFolder/code/ALZ-PowerShell-Module/docs/wiki/examples/powershell-inputs" +$bootstrapConfigFolderTerraform = "$targetFolder/code/alz-terraform-accelerator/templates/platform_landing_zone/examples/bootstrap" +Copy-Item -Path "$bootstrapConfigFolderTerraform/inputs-azure-devops.yaml" -Destination "$terraformConfigFolder/inputs-azure-devops.yaml" -Force +Copy-Item -Path "$bootstrapConfigFolderTerraform/inputs-github.yaml" -Destination "$terraformConfigFolder/inputs-github.yaml" -Force +Copy-Item -Path "$bootstrapConfigFolderTerraform/inputs-local.yaml" -Destination "$terraformConfigFolder/inputs-local.yaml" -Force -Copy-Item -Path "$exampleFolder/inputs-azure-devops-bicep-complete.yaml" -Destination "$bicepConfigFolder/inputs-azuredevops.yaml" -Force -Copy-Item -Path "$exampleFolder/inputs-github-bicep-complete.yaml" -Destination "$bicepConfigFolder/inputs-github.yaml" -Force -Copy-Item -Path "$exampleFolder/inputs-local-bicep-complete.yaml" -Destination "$bicepConfigFolder/inputs-local.yaml" -Force -Copy-Item -Path "$exampleFolder/inputs-azure-devops-terraform-complete-multi-region.yaml" -Destination "$terraformConfigFolder/inputs-azuredevops.yaml" -Force -Copy-Item -Path "$exampleFolder/inputs-github-terraform-complete-multi-region.yaml" -Destination "$terraformConfigFolder/inputs-github.yaml" -Force -Copy-Item -Path "$exampleFolder/inputs-local-terraform-complete-multi-region.yaml" -Destination "$terraformConfigFolder/inputs-local.yaml" -Force - -$exampleFolder = "$targetFolder/code/ALZ-PowerShell-Module/docs/wiki/examples/starter-module-config/complete-multi-region" - -Copy-Item -Path "$exampleFolder/config-hub-and-spoke-vnet-multi-region.yaml" -Destination "$terraformConfigFolder/config-hub-and-spoke-vnet-multi-region.yaml" -Force -Copy-Item -Path "$exampleFolder/config-hub-and-spoke-vnet-single-region.yaml" -Destination "$terraformConfigFolder/config-hub-and-spoke-vnet-single-region.yaml" -Force -Copy-Item -Path "$exampleFolder/config-virtual-wan-multi-region.yaml" -Destination "$terraformConfigFolder/config-virtual-wan-multi-region.yaml" -Force -Copy-Item -Path "$exampleFolder/config-virtual-wan-single-region.yaml" -Destination "$terraformConfigFolder/config-virtual-wan-single-region.yaml" -Force +$bootstrapConfigFolderBicep = "$targetFolder/code/ALZ-Bicep/accelerator/examples/bootstrap" +Copy-Item -Path "$bootstrapConfigFolderBicep/inputs-azure-devop.yaml" -Destination "$bicepConfigFolder/inputs-azure-devops.yaml" -Force +Copy-Item -Path "$bootstrapConfigFolderBicep/inputs-github.yaml" -Destination "$bicepConfigFolder/inputs-github.yaml" -Force +Copy-Item -Path "$bootstrapConfigFolderBicep/inputs-local.yaml" -Destination "$bicepConfigFolder/inputs-local.yaml" -Force ``` @@ -132,7 +126,8 @@ Deploy-Accelerator ` -bootstrapModuleOverrideFolderPath "/$targetFolder/code/accelerator-bootstrap-modules" ` -starterModuleOverrideFolderPath "/$targetFolder/code/ALZ-Bicep" ` -output "/$targetFolder/acc/bicep/output/azuredevops" ` - -inputs "/$targetFolder/acc/bicep/config/inputs-azuredevops.yaml" ` + -inputs "/$targetFolder/acc/bicep/config/inputs-azure-devops.yaml" ` + -skipAlzModuleVersionRequirementsCheck ` -verbose ` -replaceFiles # This will replace the files in the output folder with the files in the bootstrap and starter modules, so any updates are taken into account @@ -157,6 +152,7 @@ Deploy-Accelerator ` -starterModuleOverrideFolderPath "/$targetFolder/code/ALZ-Bicep" ` -output "/$targetFolder/acc/bicep/output/github" ` -inputs "/$targetFolder/acc/bicep/config/inputs-github.yaml" ` + -skipAlzModuleVersionRequirementsCheck ` -verbose ` -replaceFiles # This will replace the files in the output folder with the files in the bootstrap and starter modules, so any updates are taken into account @@ -181,6 +177,7 @@ Deploy-Accelerator ` -starterModuleOverrideFolderPath "/$targetFolder/code/ALZ-Bicep" ` -output "/$targetFolder/acc/bicep/output/local" ` -inputs "/$targetFolder/acc/bicep/config/inputs-local.yaml" ` + -skipAlzModuleVersionRequirementsCheck ` -verbose ` -replaceFiles # This will replace the files in the output folder with the files in the bootstrap and starter modules, so any updates are taken into account @@ -196,6 +193,7 @@ Run this from the VSCode terminal for the ALZ-PowerShell-Module repository: Invoke-Build -File .\src\ALZ.build.ps1 $targetFolder = "dev" +$bootstrapConfigFolderTerraform = "$targetFolder/code/alz-terraform-accelerator/templates/platform_landing_zone/examples/full-multi-region" # Uncomment to start fresh rather than relying on the -replaceFiles parameter # Remove-Item -Path "/$targetFolder/acc/terraform/output/azuredevops" -Recurse -Force @@ -204,7 +202,8 @@ Deploy-Accelerator ` -bootstrapModuleOverrideFolderPath "/$targetFolder/code/accelerator-bootstrap-modules" ` -starterModuleOverrideFolderPath "/$targetFolder/code/alz-terraform-accelerator/templates" ` -output "/$targetFolder/acc/terraform/output/azuredevops" ` - -inputs "/$targetFolder/acc/terraform/config/inputs-azuredevops.yaml", "/$targetFolder/acc/terraform/config/config-hub-and-spoke-vnet-multi-region.yaml" ` + -inputs "/$targetFolder/acc/terraform/config/inputs-azuredevops.yaml", "/$bootstrapConfigFolderTerraform/hub-and-spoke-vnet.tfvars" ` + -skipAlzModuleVersionRequirementsCheck ` -verbose ` -replaceFiles # This will replace the files in the output folder with the files in the bootstrap and starter modules, so any updates are taken into account @@ -222,6 +221,7 @@ Run this from the VSCode terminal for the ALZ-PowerShell-Module repository: Invoke-Build -File .\src\ALZ.build.ps1 $targetFolder = "dev" +$bootstrapConfigFolderTerraform = "$targetFolder/code/alz-terraform-accelerator/templates/platform_landing_zone/examples/full-multi-region" # Uncomment to start fresh rather than relying on the -replaceFiles parameter # Remove-Item -Path "/$targetFolder/acc/terraform/output/github" -Recurse -Force @@ -230,7 +230,8 @@ Deploy-Accelerator ` -bootstrapModuleOverrideFolderPath "/$targetFolder/code/accelerator-bootstrap-modules" ` -starterModuleOverrideFolderPath "/$targetFolder/code/alz-terraform-accelerator/templates" ` -output "/$targetFolder/acc/terraform/output/github" ` - -inputs "/$targetFolder/acc/terraform/config/inputs-github.yaml", "/$targetFolder/acc/terraform/config/config-hub-and-spoke-vnet-multi-region.yaml" ` + -inputs "/$targetFolder/acc/terraform/config/inputs-github.yaml", "/$bootstrapConfigFolderTerraform/hub-and-spoke-vnet.tfvars" ` + -skipAlzModuleVersionRequirementsCheck ` -verbose ` -replaceFiles # This will replace the files in the output folder with the files in the bootstrap and starter modules, so any updates are taken into account @@ -248,6 +249,7 @@ Run this from the VSCode terminal for the ALZ-PowerShell-Module repository: Invoke-Build -File .\src\ALZ.build.ps1 $targetFolder = "dev" +$bootstrapConfigFolderTerraform = "$targetFolder/code/alz-terraform-accelerator/templates/platform_landing_zone/examples/full-multi-region" # Uncomment to start fresh rather than relying on the -replaceFiles parameter # Remove-Item -Path "/$targetFolder/acc/terraform/output/azuredevops" -Recurse -Force @@ -256,7 +258,8 @@ Deploy-Accelerator ` -bootstrapModuleOverrideFolderPath "/$targetFolder/code/accelerator-bootstrap-modules" ` -starterModuleOverrideFolderPath "/$targetFolder/code/alz-terraform-accelerator/templates" ` -output "/$targetFolder/acc/terraform/output/local" ` - -inputs "/$targetFolder/acc/terraform/config/inputs-local.yaml", "/$targetFolder/acc/terraform/config/config-hub-and-spoke-vnet-multi-region.yaml" ` + -inputs "/$targetFolder/acc/terraform/config/inputs-local.yaml", "/$bootstrapConfigFolderTerraform/hub-and-spoke-vnet.tfvars" ` + -skipAlzModuleVersionRequirementsCheck ` -verbose ` -replaceFiles # This will replace the files in the output folder with the files in the bootstrap and starter modules, so any updates are taken into account diff --git a/src/ALZ/Private/Tools/Test-Tooling.ps1 b/src/ALZ/Private/Tools/Test-Tooling.ps1 index d9da6ed..e016cbe 100644 --- a/src/ALZ/Private/Tools/Test-Tooling.ps1 +++ b/src/ALZ/Private/Tools/Test-Tooling.ps1 @@ -1,4 +1,10 @@ function Test-Tooling { + [CmdletBinding(SupportsShouldProcess = $true)] + param( + [Parameter(Mandatory = $false)] + [switch]$skipAlzModuleVersionCheck + ) + $checkResults = @() $hasFailure = $false @@ -149,24 +155,38 @@ function Test-Tooling { } } - # Check if latest ALZ module is installed - Write-Verbose "Checking ALZ module version" - $alzModuleCurrentVersion = Get-InstalledModule -Name ALZ - $alzModuleLatestVersion = Find-Module -Name ALZ - if ($alzModuleCurrentVersion.Version -lt $alzModuleLatestVersion.Version) { - $checkResults += @{ - message = "ALZ module is not the latest version. Your version: $($alzModuleCurrentVersion.Version), Latest version: $($alzModuleLatestVersion.Version). Please update to the latest version using 'Update-Module ALZ'." - result = "Failure" - } - $hasFailure = $true + if($skipAlzModuleVersionCheck.IsPresent) { + Write-Verbose "Skipping ALZ module version check" } else { - $checkResults += @{ - message = "ALZ module is the latest version ($($alzModuleCurrentVersion.Version))." - result = "Success" + # Check if latest ALZ module is installed + Write-Verbose "Checking ALZ module version" + $alzModuleCurrentVersion = Get-InstalledModule -Name ALZ -ErrorAction SilentlyContinue + if($null -eq $alzModuleCurrentVersion) { + $checkResults += @{ + message = "ALZ module is not correctly installed. Please install the latest version using 'Install-Module ALZ'." + result = "Failure" + } + $hasFailure = $true + } + $alzModuleLatestVersion = Find-Module -Name ALZ + if ($null -ne $alzModuleCurrentVersion) { + if ($alzModuleCurrentVersion.Version -lt $alzModuleLatestVersion.Version) { + $checkResults += @{ + message = "ALZ module is not the latest version. Your version: $($alzModuleCurrentVersion.Version), Latest version: $($alzModuleLatestVersion.Version). Please update to the latest version using 'Update-Module ALZ'." + result = "Failure" + } + $hasFailure = $true + } else { + $checkResults += @{ + message = "ALZ module is the latest version ($($alzModuleCurrentVersion.Version))." + result = "Success" + } + } } } Write-Verbose "Showing check results" + Write-Verbose $(ConvertTo-Json $checkResults -Depth 100) $checkResults | ForEach-Object {[PSCustomObject]$_} | Format-Table -Property @{ Label = "Check Result"; Expression = { switch ($_.result) { diff --git a/src/ALZ/Public/Deploy-Accelerator.ps1 b/src/ALZ/Public/Deploy-Accelerator.ps1 index 38d4bcc..5f9afc8 100644 --- a/src/ALZ/Public/Deploy-Accelerator.ps1 +++ b/src/ALZ/Public/Deploy-Accelerator.ps1 @@ -175,9 +175,15 @@ function Deploy-Accelerator { Mandatory = $false, HelpMessage = "[OPTIONAL] Determines whether to skip the requirements check. This is not recommended." )] - [Alias("sr")] [Alias("skipRequirementsCheck")] - [switch] $skip_requirements_check + [switch] $skip_requirements_check, + + [Parameter( + Mandatory = $false, + 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 ) $ProgressPreference = "SilentlyContinue" @@ -186,7 +192,7 @@ function Deploy-Accelerator { 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 - Test-Tooling + Test-Tooling -skipAlzModuleVersionCheck:$skip_alz_module_version_requirements_check.IsPresent } Write-InformationColored "Getting ready to deploy the accelerator with you..." -ForegroundColor Green -NewLineBefore -InformationAction Continue diff --git a/src/ALZ/Public/Test-AcceleratorRequirement.ps1 b/src/ALZ/Public/Test-AcceleratorRequirement.ps1 index 24f1279..8f9397c 100644 --- a/src/ALZ/Public/Test-AcceleratorRequirement.ps1 +++ b/src/ALZ/Public/Test-AcceleratorRequirement.ps1 @@ -15,6 +15,13 @@ function Test-AcceleratorRequirement { .COMPONENT ALZ #> - - Test-Tooling + param ( + [Parameter( + Mandatory = $false, + 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 + ) + Test-Tooling -skipAlzModuleVersionCheck:$skip_alz_module_version_requirements_check.IsPresent }