Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 13 additions & 17 deletions src/ALZ/Public/New-AcceleratorFolderStructure.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function New-AcceleratorFolderStructure {
[string] $targetFolderPath = "~/accelerator",
[Parameter(
Mandatory = $false,
HelpMessage = "[OPTIONAL] Forece recreate of the target folder if it already exists"
HelpMessage = "[OPTIONAL] Force recreate of the target folder if it already exists"
)]
[switch] $force
)
Expand Down Expand Up @@ -96,13 +96,9 @@ function New-AcceleratorFolderStructure {
# Clone the repo and copy the bootstrap and starter configuration files
$repo = $repos[$iacType]
Write-Host "Cloning repo $($repo.repoName)"
git clone -n --depth=1 --filter=tree:0 "https://github.com/Azure/$($repo.repoName)" "$tempFolderPath" | Write-Verbose | Out-Null
git clone --depth=1 "https://github.com/Azure/$($repo.repoName)" "$tempFolderPath" | Write-Verbose | Out-Null
Set-Location $tempFolderPath

Write-Host "Checking out folder $($repo.folderToClone)"
git sparse-checkout set --no-cone $repo.folderToClone | Write-Verbose | Out-Null
git checkout | Write-Verbose | Out-Null

Set-Location $currentPath
$exampleFolderPath = "$($repo.folderToClone)/$($repo.exampleFolderPath)"
$bootstrapExampleFolderPath = "$exampleFolderPath/$($repo.bootstrapExampleFolderPath)"
Expand All @@ -124,23 +120,23 @@ function New-AcceleratorFolderStructure {
# Copy the platform landing zone configuration files based on scenario number or specific file path
if ($repo.hasScenarios) {
$scenarios = @{
1 = "full-multi-region/hub-and-spoke-vnet"
2 = "full-multi-region/virtual-wan"
3 = "full-multi-region-nva/hub-and-spoke-vnet"
4 = "full-multi-region-nva/virtual-wan"
5 = "management-only/management"
6 = "full-single-region/hub-and-spoke-vnet"
7 = "full-single-region/virtual-wan"
8 = "full-single-region-nva/hub-and-spoke-vnet"
9 = "full-single-region-nva/virtual-wan"
1 = "full-multi-region/hub-and-spoke-vnet.tfvars"
2 = "full-multi-region/virtual-wan.tfvars"
3 = "full-multi-region-nva/hub-and-spoke-vnet.tfvars"
4 = "full-multi-region-nva/virtual-wan.tfvars"
5 = "management-only/management.tfvars"
6 = "full-single-region/hub-and-spoke-vnet.tfvars"
7 = "full-single-region/virtual-wan.tfvars"
8 = "full-single-region-nva/hub-and-spoke-vnet.tfvars"
9 = "full-single-region-nva/virtual-wan.tfvars"
}

Write-Host "Copying platform landing zone configuration file for scenario $scenarioNumber to $($targetFolderPath)/config/platform-landing-zone.tfvars"
Copy-Item -Path "$tempFolderPath/templates/platform_landing_zone/examples/$($scenarios[$scenarioNumber]).tfvars" -Destination "$targetFolderPath/config/platform-landing-zone.tfvars" -Force | Write-Verbose | Out-Null
Copy-Item -Path "$tempFolderPath/$exampleFolderPath/$($scenarios[$scenarioNumber])" -Destination "$targetFolderPath/config/platform-landing-zone.tfvars" -Force | Write-Verbose | Out-Null

} elseif ($repo.platformLandingZoneFilePath -ne "") {
Write-Host "Copying platform landing zone configuration file to $($targetFolderPath)/config/platform-landing-zone.yaml"
Copy-Item -Path "$tempFolderPath/$($repo.platformLandingZoneFilePath)" -Destination "$targetFolderPath/config/platform-landing-zone.yaml" -Force | Write-Verbose | Out-Null
Copy-Item -Path "$tempFolderPath/$exampleFolderPath/$($repo.platformLandingZoneFilePath)" -Destination "$targetFolderPath/config/platform-landing-zone.yaml" -Force | Write-Verbose | Out-Null
}

Remove-Item -Path $tempFolderPath -Recurse -Force | Write-Verbose | Out-Null
Expand Down
11 changes: 10 additions & 1 deletion src/ALZ/Public/Remove-PlatformLandingZone.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ function Remove-PlatformLandingZone {
}

function Test-RequiredTooling {
Write-ToConsoleLog "Checking the software requirements for the Accelerator..."
Write-ToConsoleLog "Checking the software requirements..."

$checkResults = @()
$hasFailure = $false
Expand Down Expand Up @@ -795,6 +795,13 @@ function Remove-PlatformLandingZone {

# For each custom role definition, find and delete all assignments using Resource Graph, then delete the definition
foreach ($roleDefinition in $customRoleDefinitions) {
$graphExtension = az extension show --name resource-graph 2>$null
if (-not $graphExtension) {
Write-ToConsoleLog "Installing Azure Resource Graph extension for role assignment queries..." -NoNewLine -IsWarning
az config set extension.dynamic_install_allow_preview=true 2>$null
az extension add --name resource-graph 2>$null
}

Write-ToConsoleLog "Processing custom role definition: $($roleDefinition.roleName) (ID: $($roleDefinition.name))" -NoNewLine

# Use Resource Graph to find all role assignments for this custom role definition across all scopes
Expand Down Expand Up @@ -856,6 +863,8 @@ function Remove-PlatformLandingZone {

Test-RequiredTooling

Write-ToConsoleLog "This cmdlet uses preview features of the Azure CLI. By continuing, you agree to install preview extensions." -IsWarning

$TempLogFileForPlan = ""
if($PlanMode) {
Write-ToConsoleLog "Plan Mode enabled, no changes will be made. All actions will be logged as what would be performed." -IsWarning
Expand Down
Loading