Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup Old Role Assignments in CI resource group #561

Merged
merged 12 commits into from
Mar 30, 2023
2 changes: 1 addition & 1 deletion .github/workflows/ByoVnetPrivateCI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ on:
required: false
region:
description: 'Resource Deployment Region'
default: 'UKWest'
default: 'EastUs'
options:
- "WestEurope"
- "NorthEurope"
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/cleanupRg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,15 @@ jobs:
try {
#Remove all but public ip addresses
Get-AzResource -ResourceGroupName $rgToPurge.ResourceGroupName | ? {$_.ResourceType -ne "Microsoft.Network/publicIPAddresses"} | Remove-AzResource -Force

#Remove public ip addresses
Get-AzResource -ResourceGroupName $rgToPurge.ResourceGroupName | ? {$_.ResourceType -eq "Microsoft.Network/publicIPAddresses"} | Remove-AzResource -Force

#Final run to clean other dependant resources in parent-child graph
Get-AzResource -ResourceGroupName $rgToPurge.ResourceGroupName | Remove-AzResource -Force

#Remove unknown/invalid role assignments from rg
Get-AzRoleAssignment -Scope $rgToPurge.ResourceId | where ObjectType -eq 'Unknown' | Remove-AzRoleAssignment
}
Catch #we're wanting to suppress failures in this step. If it fails to clean, the nightly automation will catch it.
{
Expand Down