-
Notifications
You must be signed in to change notification settings - Fork 514
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Swap individual policy assignments to
alzDefaultPolicyAssignments
m…
…odule in E2E tests (#183) * Update file to new path * Update tests/pipelines/bicep-build-to-validate.yml Co-authored-by: Jack Tracey <[email protected]> * Update tests/pipelines/bicep-build-to-validate.yml Co-authored-by: Jack Tracey <[email protected]> * Add script to loop retries * decrease wait time for script * add throw on threshold met * fix unused param * Update .github/scripts/Set-AlzDefaultPolicyAssignment.ps1 Co-authored-by: Jack Tracey <[email protected]> * Update .github/scripts/Set-AlzDefaultPolicyAssignment.ps1 Co-authored-by: Jack Tracey <[email protected]> * Update tests/pipelines/bicep-build-to-validate.yml Co-authored-by: Jack Tracey <[email protected]> * Include policyAssignmentManagementGroup.bicep * fix displayname on pwsh task * trigger pipeline * handle string * remove quotes around subscriptionId * Include quotes in array * remove E2E trigger * re-include trigger * Remove trigger again Co-authored-by: Jack Tracey <[email protected]>
- Loading branch information
Showing
2 changed files
with
50 additions
and
14 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
|
||
param ( | ||
#Added this back into parameters as error occurs if multiple tenants are found when using Get-AzTenant | ||
[Parameter(Mandatory = $true)] [string] $ManagementGroupId, | ||
[Parameter(Mandatory = $true)] [string] $parLocation, | ||
[Parameter(Mandatory = $true)] [string] $templateFile, | ||
[Parameter(Mandatory = $true)] [string] $parameterFile, | ||
[Parameter(Mandatory = $true)] [string] $parTopLevelManagementGroupPrefix, | ||
[Parameter(Mandatory = $true)] [string] $parLogAnalyticsWorkSpaceAndAutomationAccountLocation, | ||
[Parameter(Mandatory = $true)] [string] $parLogAnalyticsWorkspaceResourceID, | ||
[Parameter(Mandatory = $true)] [string] $parDdosProtectionPlanId | ||
) | ||
$state = 'fail' | ||
$i = 0 | ||
$err.clear | ||
while ($i -lt 4 -and $state -eq 'fail') { | ||
$ErrorActionPreference = "Stop" | ||
Try { | ||
New-AzManagementGroupDeployment -Managementgroupid $ManagementGroupId -Location $parLocation -TemplateFile $templateFile -TemplateParameterFile $parameterFile -parTopLevelManagementGroupPrefix $parTopLevelManagementGroupPrefix -parLogAnalyticsWorkSpaceAndAutomationAccountLocation $parLogAnalyticsWorkSpaceAndAutomationAccountLocation -parLogAnalyticsWorkspaceResourceID $parLogAnalyticsWorkspaceResourceID -parDdosProtectionPlanId $parDdosProtectionPlanId | ||
$state = 'success' | ||
} | ||
Catch { | ||
$i++ | ||
Write-Output "ALZ Default Policy Assignments module failed to deploy with $error" | ||
Write-Output "Iteration number $i" | ||
Write-Output "Will retry in 30 seconds" | ||
Start-Sleep -Seconds 30 | ||
} | ||
} | ||
If ($state -eq 'fail') { | ||
Throw "ALZ Default Policy Assignments module failed to deploy after $i attempts" | ||
} |
This file contains 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