From 1b723349ef3bf6799fb38d011b3ced85ee1c90e8 Mon Sep 17 00:00:00 2001 From: Zach Trocinski <30884663+oZakari@users.noreply.github.com> Date: Thu, 6 Apr 2023 00:47:45 -0500 Subject: [PATCH] 26294: Accelerator - Add ability to import env file and minor fixes (#488) --- accelerator/.github/workflows/alz-bicep-1.yml | 18 +++++++++++++----- accelerator/.github/workflows/alz-bicep-2.yml | 16 ++++++++++++---- accelerator/.github/workflows/alz-bicep-3.yml | 17 +++++++++++++---- accelerator/.github/workflows/alz-bicep-4a.yml | 17 ++++++++++++----- accelerator/.github/workflows/alz-bicep-4b.yml | 17 ++++++++++++----- .../Deploy-ALZHub-HubAndSpoke.ps1 | 4 ++-- .../pipeline-scripts/Deploy-ALZHub-VWAN.ps1 | 4 ++-- .../Deploy-ALZLoggingAndSentinel.ps1 | 4 ++-- 8 files changed, 68 insertions(+), 29 deletions(-) diff --git a/accelerator/.github/workflows/alz-bicep-1.yml b/accelerator/.github/workflows/alz-bicep-1.yml index e4da7bbe5..6399bbcd9 100644 --- a/accelerator/.github/workflows/alz-bicep-1.yml +++ b/accelerator/.github/workflows/alz-bicep-1.yml @@ -6,6 +6,7 @@ on: - "main" paths: - "config/custom-parameters/managementGroups.parameters.all.json" + - "config/custom-parameters/resourceGroupLoggingAndSentinel.parameters.all.json" - "config/custom-parameters/logging.parameters.all.json" - "config/custom-parameters/customPolicyDefinitions.parameters.all.json" - "config/custom-parameters/customRoleDefinitions.parameters.all.json" @@ -17,11 +18,7 @@ permissions: contents: read env: - LOCATION: "" - UPSTREAM_RELEASE_VERSION: "" - MANAGEMENT_SUBSCRIPTION_ID: "" - TOP_LEVEL_MG_PREFIX: "" - LOGGING_RESOURCE_GROUP: "" + ENV_FILE: ".env" jobs: ALZ_Bicep_1_Workflow_Job: @@ -32,6 +29,17 @@ jobs: with: fetch-depth: 0 + - name: "Remove Quotation Marks from Environment File" + uses: azure/powershell@v1 + with: + inlineScript: | + Write-Host $ENV_FILE + (Get-Content -Path $env:ENV_FILE -Encoding UTF8) | ForEach-Object {$_ -replace '"',''} | Out-File -FilePath $env:ENV_FILE -Encoding UTF8 + azPSVersion: "latest" + + - name: Import Environment Variables from File + run: cat ${{ env.ENV_FILE }} >> $GITHUB_ENV + - name: OIDC Login to Tenant uses: azure/login@v1 with: diff --git a/accelerator/.github/workflows/alz-bicep-2.yml b/accelerator/.github/workflows/alz-bicep-2.yml index 45f268ac1..f1bde2a05 100644 --- a/accelerator/.github/workflows/alz-bicep-2.yml +++ b/accelerator/.github/workflows/alz-bicep-2.yml @@ -13,10 +13,7 @@ permissions: contents: read env: - LOCATION: "" - UPSTREAM_RELEASE_VERSION: "" - MANAGEMENT_SUBSCRIPTION_ID: "" - TOP_LEVEL_MG_PREFIX: "" + ENV_FILE: ".env" jobs: ALZ_Bicep_2_Workflow_Job: @@ -27,6 +24,17 @@ jobs: with: fetch-depth: 0 + - name: "Remove Quotation Marks from Environment File" + uses: azure/powershell@v1 + with: + inlineScript: | + Write-Host $ENV_FILE + (Get-Content -Path $env:ENV_FILE -Encoding UTF8) | ForEach-Object {$_ -replace '"',''} | Out-File -FilePath $env:ENV_FILE -Encoding UTF8 + azPSVersion: "latest" + + - name: Import Environment Variables from File + run: cat ${{ env.ENV_FILE }} >> $GITHUB_ENV + - name: OIDC Login to Tenant uses: azure/login@v1 with: diff --git a/accelerator/.github/workflows/alz-bicep-3.yml b/accelerator/.github/workflows/alz-bicep-3.yml index ea33a3709..f4d6f8bde 100644 --- a/accelerator/.github/workflows/alz-bicep-3.yml +++ b/accelerator/.github/workflows/alz-bicep-3.yml @@ -5,7 +5,7 @@ on: branches: - "main" paths: - - "config/custom-parameters/subscriptionPlacement.parameters.all.json" + - "config/custom-parameters/subPlacementAll.parameters.all.json" workflow_dispatch: permissions: @@ -13,9 +13,7 @@ permissions: contents: read env: - LOCATION: "" - UPSTREAM_RELEASE_VERSION: "" - TOP_LEVEL_MG_PREFIX: "" + ENV_FILE: ".env" jobs: ALZ_Bicep_3_Workflow_Job: @@ -26,6 +24,17 @@ jobs: with: fetch-depth: 0 + - name: "Remove Quotation Marks from Environment File" + uses: azure/powershell@v1 + with: + inlineScript: | + Write-Host $ENV_FILE + (Get-Content -Path $env:ENV_FILE -Encoding UTF8) | ForEach-Object {$_ -replace '"',''} | Out-File -FilePath $env:ENV_FILE -Encoding UTF8 + azPSVersion: "latest" + + - name: Import Environment Variables from File + run: cat ${{ env.ENV_FILE }} >> $GITHUB_ENV + - name: OIDC Login to Tenant uses: azure/login@v1 with: diff --git a/accelerator/.github/workflows/alz-bicep-4a.yml b/accelerator/.github/workflows/alz-bicep-4a.yml index 46620f2db..2bd136a7f 100644 --- a/accelerator/.github/workflows/alz-bicep-4a.yml +++ b/accelerator/.github/workflows/alz-bicep-4a.yml @@ -14,11 +14,7 @@ permissions: contents: read env: - LOCATION: "" - UPSTREAM_RELEASE_VERSION: "" - CONNECTIVITY_SUBSCRIPTION_ID: "" - TOP_LEVEL_MG_PREFIX: "" - CONNECTIVITY_RESOURCE_GROUP: "" + ENV_FILE: ".env" jobs: ALZ_Bicep_4a_Workflow_Job: @@ -29,6 +25,17 @@ jobs: with: fetch-depth: 0 + - name: "Remove Quotation Marks from Environment File" + uses: azure/powershell@v1 + with: + inlineScript: | + Write-Host $ENV_FILE + (Get-Content -Path $env:ENV_FILE -Encoding UTF8) | ForEach-Object {$_ -replace '"',''} | Out-File -FilePath $env:ENV_FILE -Encoding UTF8 + azPSVersion: "latest" + + - name: Import Environment Variables from File + run: cat ${{ env.ENV_FILE }} >> $GITHUB_ENV + - name: OIDC Login to Tenant uses: azure/login@v1 with: diff --git a/accelerator/.github/workflows/alz-bicep-4b.yml b/accelerator/.github/workflows/alz-bicep-4b.yml index dbcbc5894..5540b5334 100644 --- a/accelerator/.github/workflows/alz-bicep-4b.yml +++ b/accelerator/.github/workflows/alz-bicep-4b.yml @@ -14,11 +14,7 @@ permissions: contents: read env: - LOCATION: "" - UPSTREAM_RELEASE_VERSION: "" - CONNECTIVITY_SUBSCRIPTION_ID: "" - TOP_LEVEL_MG_PREFIX: "" - CONNECTIVITY_RESOURCE_GROUP: "" + ENV_FILE: ".env" jobs: ALZ_Bicep_4b_Workflow_Job: @@ -29,6 +25,17 @@ jobs: with: fetch-depth: 0 + - name: "Remove Quotation Marks from Environment File" + uses: azure/powershell@v1 + with: + inlineScript: | + Write-Host $ENV_FILE + (Get-Content -Path $env:ENV_FILE -Encoding UTF8) | ForEach-Object {$_ -replace '"',''} | Out-File -FilePath $env:ENV_FILE -Encoding UTF8 + azPSVersion: "latest" + + - name: Import Environment Variables from File + run: cat ${{ env.ENV_FILE }} >> $GITHUB_ENV + - name: OIDC Login to Tenant uses: azure/login@v1 with: diff --git a/accelerator/pipeline-scripts/Deploy-ALZHub-HubAndSpoke.ps1 b/accelerator/pipeline-scripts/Deploy-ALZHub-HubAndSpoke.ps1 index 8c7c50133..088bcd894 100644 --- a/accelerator/pipeline-scripts/Deploy-ALZHub-HubAndSpoke.ps1 +++ b/accelerator/pipeline-scripts/Deploy-ALZHub-HubAndSpoke.ps1 @@ -3,7 +3,7 @@ param ( [String]$ConnectivitySubscriptionId = "$($env:CONNECTIVITY_SUBSCRIPTION_ID)", [Parameter()] - [String]$ConnectivityResourceGroup = "$($env:CONNECTIVITY_RESOURCE_GROUP)", + [String]$TopLevelMGPrefix = "$($env:TOP_LEVEL_MG_PREFIX)", [Parameter()] [String]$TemplateFile = "upstream-releases\$($env:UPSTREAM_RELEASE_VERSION)\infra-as-code\bicep\modules\hubNetworking\hubNetworking.bicep", @@ -15,7 +15,7 @@ param ( # Parameters necessary for deployment $inputObject = @{ DeploymentName = 'alz-Hub-and-SpokeDeploy-{0}' -f ( -join (Get-Date -Format 'yyyyMMddTHHMMssffffZ')[0..63]) - ResourceGroupName = $ConnectivityResourceGroup + ResourceGroupName = "rg-$TopLevelMGPrefix-connectivity" TemplateFile = $TemplateFile TemplateParameterFile = $TemplateParameterFile Verbose = $true diff --git a/accelerator/pipeline-scripts/Deploy-ALZHub-VWAN.ps1 b/accelerator/pipeline-scripts/Deploy-ALZHub-VWAN.ps1 index 4a73fd971..572f8777a 100644 --- a/accelerator/pipeline-scripts/Deploy-ALZHub-VWAN.ps1 +++ b/accelerator/pipeline-scripts/Deploy-ALZHub-VWAN.ps1 @@ -3,7 +3,7 @@ param ( [String]$ConnectivitySubscriptionId = "$($env:CONNECTIVITY_SUBSCRIPTION_ID)", [Parameter()] - [String]$ConnectivityResourceGroup = "$($env:CONNECTIVITY_RESOURCE_GROUP)", + [String]$TopLevelMGPrefix = "$($env:TOP_LEVEL_MG_PREFIX)", [Parameter()] [String]$TemplateFile = "upstream-releases\$($env:UPSTREAM_RELEASE_VERSION)\infra-as-code\bicep\modules\vwanConnectivity\vwanConnectivity.bicep", @@ -15,7 +15,7 @@ param ( # Parameters necessary for deployment $inputObject = @{ DeploymentName = 'alz-VWANDeploy-{0}' -f ( -join (Get-Date -Format 'yyyyMMddTHHMMssffffZ')[0..63]) - ResourceGroupName = $ConnectivityResourceGroup + ResourceGroupName = "rg-$TopLevelMGPrefix-connectivity" TemplateFile = $TemplateFile TemplateParameterFile = $TemplateParameterFile Verbose = $true diff --git a/accelerator/pipeline-scripts/Deploy-ALZLoggingAndSentinel.ps1 b/accelerator/pipeline-scripts/Deploy-ALZLoggingAndSentinel.ps1 index ef3d578e5..342b65dee 100644 --- a/accelerator/pipeline-scripts/Deploy-ALZLoggingAndSentinel.ps1 +++ b/accelerator/pipeline-scripts/Deploy-ALZLoggingAndSentinel.ps1 @@ -3,7 +3,7 @@ param ( [String]$ManagementSubscriptionId = "$($env:MANAGEMENT_SUBSCRIPTION_ID)", [Parameter()] - [String]$LoggingResourceGroup = "$($env:LOGGING_RESOURCE_GROUP)", + [String]$TopLevelMGPrefix = "$($env:TOP_LEVEL_MG_PREFIX)", [Parameter()] [String]$TemplateFile = "upstream-releases\$($env:UPSTREAM_RELEASE_VERSION)\infra-as-code\bicep\modules\logging\logging.bicep", @@ -15,7 +15,7 @@ param ( # Parameters necessary for deployment $inputObject = @{ DeploymentName = 'alz-LoggingDeploy-{0}' -f ( -join (Get-Date -Format 'yyyyMMddTHHMMssffffZ')[0..63]) - ResourceGroupName = $LoggingResourceGroup + ResourceGroupName = "rg-$TopLevelMGPrefix-logging" TemplateFile = $TemplateFile TemplateParameterFile = $TemplateParameterFile Verbose = $true