From c36e68802cc4d4486dec0151872f47959a6adfde Mon Sep 17 00:00:00 2001 From: Zach Trocinski Date: Fri, 10 Nov 2023 00:11:42 -0600 Subject: [PATCH 1/5] Add installation of ALZ Powershell module for policy scripts --- .github/scripts/Invoke-PolicyToBicep-China.ps1 | 6 ++---- .github/scripts/Invoke-PolicyToBicep.ps1 | 4 ++++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/scripts/Invoke-PolicyToBicep-China.ps1 b/.github/scripts/Invoke-PolicyToBicep-China.ps1 index e629ee585..870344f34 100644 --- a/.github/scripts/Invoke-PolicyToBicep-China.ps1 +++ b/.github/scripts/Invoke-PolicyToBicep-China.ps1 @@ -13,8 +13,6 @@ param ( [string] $rootPath = "./infra-as-code/bicep/modules/policy", [string] - $alzToolsPath = "$PWD/../Enterprise-Scale/src/Alz.Tools", - [string] $definitionsRoot = "definitions", [string] $lineEnding = "unix", @@ -43,8 +41,8 @@ param ( ) # This script relies on a custom set of classes and functions -# defined within the Alz.Tools PowerShell module. -Import-Module $alzToolsPath -ErrorAction Stop +# defined within the [ALZ-PowerShell-Module](https://github.com/Azure/Alz-powershell-module). +Install-Module -Name ALZ -Scope CurrentUser -ErrorAction Stop # Line Endings function to be used in three functions below function Update-FileLineEndingType { diff --git a/.github/scripts/Invoke-PolicyToBicep.ps1 b/.github/scripts/Invoke-PolicyToBicep.ps1 index 8c76c3650..e3c2d1f5b 100644 --- a/.github/scripts/Invoke-PolicyToBicep.ps1 +++ b/.github/scripts/Invoke-PolicyToBicep.ps1 @@ -38,6 +38,10 @@ param ( $assignmentsTxtFileName = "_policyAssignmentsBicepInput.txt" ) +# This script relies on a custom set of classes and functions +# defined within the [ALZ-PowerShell-Module](https://github.com/Azure/Alz-powershell-module). +Install-Module -Name ALZ -Scope CurrentUser -ErrorAction Stop + # Line Endings function to be used in three functions below function Update-FileLineEndingType { [CmdletBinding(SupportsShouldProcess)] From 867fb70991f593ef00115abf79ba210ae61aacb5 Mon Sep 17 00:00:00 2001 From: Zach Trocinski Date: Mon, 13 Nov 2023 15:51:56 -0600 Subject: [PATCH 2/5] Update query to add logging and adjust workflow for MC --- .github/scripts/Invoke-PolicyToBicep-China.ps1 | 7 ++++++- .github/scripts/Invoke-PolicyToBicep.ps1 | 7 ++++++- .github/workflows/update-policy-china.yml | 8 ++++++-- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/.github/scripts/Invoke-PolicyToBicep-China.ps1 b/.github/scripts/Invoke-PolicyToBicep-China.ps1 index 870344f34..e338ebc38 100644 --- a/.github/scripts/Invoke-PolicyToBicep-China.ps1 +++ b/.github/scripts/Invoke-PolicyToBicep-China.ps1 @@ -42,7 +42,12 @@ param ( # This script relies on a custom set of classes and functions # defined within the [ALZ-PowerShell-Module](https://github.com/Azure/Alz-powershell-module). -Install-Module -Name ALZ -Scope CurrentUser -ErrorAction Stop +if (-not (Get-Module -ListAvailable -Name ALZ)) { + # Module doesn't exist, so install it + Install-Module -Name ALZ -Scope CurrentUser -ErrorAction Stop +} else { + Write-Information "====> ALZ module is already installed." -InformationAction Continue +} # Line Endings function to be used in three functions below function Update-FileLineEndingType { diff --git a/.github/scripts/Invoke-PolicyToBicep.ps1 b/.github/scripts/Invoke-PolicyToBicep.ps1 index e3c2d1f5b..ef535b7bd 100644 --- a/.github/scripts/Invoke-PolicyToBicep.ps1 +++ b/.github/scripts/Invoke-PolicyToBicep.ps1 @@ -40,7 +40,12 @@ param ( # This script relies on a custom set of classes and functions # defined within the [ALZ-PowerShell-Module](https://github.com/Azure/Alz-powershell-module). -Install-Module -Name ALZ -Scope CurrentUser -ErrorAction Stop +if (-not (Get-Module -ListAvailable -Name ALZ)) { + # Module doesn't exist, so install it + Install-Module -Name ALZ -Scope CurrentUser -ErrorAction Stop +} else { + Write-Information "====> ALZ module is already installed." -InformationAction Continue +} # Line Endings function to be used in three functions below function Update-FileLineEndingType { diff --git a/.github/workflows/update-policy-china.yml b/.github/workflows/update-policy-china.yml index 0e1703912..43a9b96d3 100644 --- a/.github/workflows/update-policy-china.yml +++ b/.github/workflows/update-policy-china.yml @@ -68,14 +68,18 @@ jobs: -Reset azPSVersion: "latest" + - name: Install ALZ PowerShell Module + shell: pwsh + run: | + Install-Module -Name 'ALZ' -Force + - name: Update Policy Definition Bicep Input Files uses: azure/powershell@v1 with: inlineScript: | cd ${{ github.workspace }}/${{ github.repository }} Write-Information "==> Running script..." -InformationAction Continue - .github/scripts/Invoke-PolicyToBicep-China.ps1 ` - -alzToolsPath "${{ github.workspace }}/${{ env.remote_repository }}/src/Alz.Tools/" + .github/scripts/Invoke-PolicyToBicep-China.ps1 azPSVersion: "latest" - name: Check for changes From c861d18d88e09e795517719f53df8d37a641add0 Mon Sep 17 00:00:00 2001 From: Zach Trocinski Date: Wed, 15 Nov 2023 13:18:13 -0600 Subject: [PATCH 3/5] Update accelerator doc for version --- docs/wiki/Accelerator.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/wiki/Accelerator.md b/docs/wiki/Accelerator.md index afa340b52..8592ebc9f 100644 --- a/docs/wiki/Accelerator.md +++ b/docs/wiki/Accelerator.md @@ -219,7 +219,7 @@ With the ALZ Accelerator framework, we have designed the pipelines and directory 1. Using the ALZ PowerShell Module, there is a cmdlet called `Get-ALZBicepRelease`. This will download a specified release version from the remote ALZ-Bicep repository and pull down to the local directory where your Accelerator framework was initially deployed. - Here is an example of using the cmdlet to pull down version v0.16.5: + Here is an example of using the cmdlet to pull down version v0.16.6: ```powershell Get-ALZGithubRelease -githubRepoUrl "https://github.com/Azure/ALZ-Bicep" -release "v0.16.6" -directoryForReleases "C:\Repos\ALZ\accelerator\upstream-releases\" @@ -228,7 +228,7 @@ With the ALZ Accelerator framework, we have designed the pipelines and directory 1. Once the ALZ Bicep release has been downloaded, you will need to update `upstream-releases-version` within the environment variables file (.env) with the version number of the release that you just downloaded. For example, if you downloaded v0.16.5, you would update the file with the following: ```text - UPSTREAM_RELEASE_VERSION="v0.16.5" + UPSTREAM_RELEASE_VERSION="v0.16.6" ``` 1. You can now deploy the updated modules. From 07f28720fe881d58c54730bacf6528a0db05b7d6 Mon Sep 17 00:00:00 2001 From: Zach Trocinski <30884663+oZakari@users.noreply.github.com> Date: Mon, 20 Nov 2023 11:24:46 -0600 Subject: [PATCH 4/5] Update .github/scripts/Invoke-PolicyToBicep-China.ps1 Co-authored-by: Jack Tracey <41163455+jtracey93@users.noreply.github.com> --- .github/scripts/Invoke-PolicyToBicep-China.ps1 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/scripts/Invoke-PolicyToBicep-China.ps1 b/.github/scripts/Invoke-PolicyToBicep-China.ps1 index e338ebc38..e1e659cba 100644 --- a/.github/scripts/Invoke-PolicyToBicep-China.ps1 +++ b/.github/scripts/Invoke-PolicyToBicep-China.ps1 @@ -44,7 +44,9 @@ param ( # defined within the [ALZ-PowerShell-Module](https://github.com/Azure/Alz-powershell-module). if (-not (Get-Module -ListAvailable -Name ALZ)) { # Module doesn't exist, so install it - Install-Module -Name ALZ -Scope CurrentUser -ErrorAction Stop + Write-Information "====> ALZ module isn't already installed. Installing..." -InformationAction Continue + Install-Module -Name ALZ -Force -Scope CurrentUser -ErrorAction Stop + Write-Information "====> ALZ module now installed." -InformationAction Continue } else { Write-Information "====> ALZ module is already installed." -InformationAction Continue } From 8a0f805150ebffc1528f7a3473754d38f41f58c3 Mon Sep 17 00:00:00 2001 From: Zach Trocinski <30884663+oZakari@users.noreply.github.com> Date: Mon, 20 Nov 2023 11:24:51 -0600 Subject: [PATCH 5/5] Update .github/scripts/Invoke-PolicyToBicep.ps1 Co-authored-by: Jack Tracey <41163455+jtracey93@users.noreply.github.com> --- .github/scripts/Invoke-PolicyToBicep.ps1 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/scripts/Invoke-PolicyToBicep.ps1 b/.github/scripts/Invoke-PolicyToBicep.ps1 index ef535b7bd..42c068006 100644 --- a/.github/scripts/Invoke-PolicyToBicep.ps1 +++ b/.github/scripts/Invoke-PolicyToBicep.ps1 @@ -42,7 +42,9 @@ param ( # defined within the [ALZ-PowerShell-Module](https://github.com/Azure/Alz-powershell-module). if (-not (Get-Module -ListAvailable -Name ALZ)) { # Module doesn't exist, so install it - Install-Module -Name ALZ -Scope CurrentUser -ErrorAction Stop + Write-Information "====> ALZ module isn't already installed. Installing..." -InformationAction Continue + Install-Module -Name ALZ -Force -Scope CurrentUser -ErrorAction Stop + Write-Information "====> ALZ module now installed." -InformationAction Continue } else { Write-Information "====> ALZ module is already installed." -InformationAction Continue }