Skip to content

Commit caa9ceb

Browse files
fix: bicep folder structure (#504)
# Pull Request ## Description Fix the cmdlet to setup the Bicep folder structure ## License By submitting this pull request, I confirm that my contribution is made under the terms of the projects associated license.
1 parent a45cf36 commit caa9ceb

File tree

2 files changed

+23
-18
lines changed

2 files changed

+23
-18
lines changed

src/ALZ/Public/New-AcceleratorFolderStructure.ps1

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function New-AcceleratorFolderStructure {
2323
[string] $targetFolderPath = "~/accelerator",
2424
[Parameter(
2525
Mandatory = $false,
26-
HelpMessage = "[OPTIONAL] Forece recreate of the target folder if it already exists"
26+
HelpMessage = "[OPTIONAL] Force recreate of the target folder if it already exists"
2727
)]
2828
[switch] $force
2929
)
@@ -96,13 +96,9 @@ function New-AcceleratorFolderStructure {
9696
# Clone the repo and copy the bootstrap and starter configuration files
9797
$repo = $repos[$iacType]
9898
Write-Host "Cloning repo $($repo.repoName)"
99-
git clone -n --depth=1 --filter=tree:0 "https://github.com/Azure/$($repo.repoName)" "$tempFolderPath" | Write-Verbose | Out-Null
99+
git clone --depth=1 "https://github.com/Azure/$($repo.repoName)" "$tempFolderPath" | Write-Verbose | Out-Null
100100
Set-Location $tempFolderPath
101101

102-
Write-Host "Checking out folder $($repo.folderToClone)"
103-
git sparse-checkout set --no-cone $repo.folderToClone | Write-Verbose | Out-Null
104-
git checkout | Write-Verbose | Out-Null
105-
106102
Set-Location $currentPath
107103
$exampleFolderPath = "$($repo.folderToClone)/$($repo.exampleFolderPath)"
108104
$bootstrapExampleFolderPath = "$exampleFolderPath/$($repo.bootstrapExampleFolderPath)"
@@ -124,23 +120,23 @@ function New-AcceleratorFolderStructure {
124120
# Copy the platform landing zone configuration files based on scenario number or specific file path
125121
if ($repo.hasScenarios) {
126122
$scenarios = @{
127-
1 = "full-multi-region/hub-and-spoke-vnet"
128-
2 = "full-multi-region/virtual-wan"
129-
3 = "full-multi-region-nva/hub-and-spoke-vnet"
130-
4 = "full-multi-region-nva/virtual-wan"
131-
5 = "management-only/management"
132-
6 = "full-single-region/hub-and-spoke-vnet"
133-
7 = "full-single-region/virtual-wan"
134-
8 = "full-single-region-nva/hub-and-spoke-vnet"
135-
9 = "full-single-region-nva/virtual-wan"
123+
1 = "full-multi-region/hub-and-spoke-vnet.tfvars"
124+
2 = "full-multi-region/virtual-wan.tfvars"
125+
3 = "full-multi-region-nva/hub-and-spoke-vnet.tfvars"
126+
4 = "full-multi-region-nva/virtual-wan.tfvars"
127+
5 = "management-only/management.tfvars"
128+
6 = "full-single-region/hub-and-spoke-vnet.tfvars"
129+
7 = "full-single-region/virtual-wan.tfvars"
130+
8 = "full-single-region-nva/hub-and-spoke-vnet.tfvars"
131+
9 = "full-single-region-nva/virtual-wan.tfvars"
136132
}
137133

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

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

146142
Remove-Item -Path $tempFolderPath -Recurse -Force | Write-Verbose | Out-Null

src/ALZ/Public/Remove-PlatformLandingZone.ps1

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ function Remove-PlatformLandingZone {
369369
}
370370

371371
function Test-RequiredTooling {
372-
Write-ToConsoleLog "Checking the software requirements for the Accelerator..."
372+
Write-ToConsoleLog "Checking the software requirements..."
373373

374374
$checkResults = @()
375375
$hasFailure = $false
@@ -795,6 +795,13 @@ function Remove-PlatformLandingZone {
795795

796796
# For each custom role definition, find and delete all assignments using Resource Graph, then delete the definition
797797
foreach ($roleDefinition in $customRoleDefinitions) {
798+
$graphExtension = az extension show --name resource-graph 2>$null
799+
if (-not $graphExtension) {
800+
Write-ToConsoleLog "Installing Azure Resource Graph extension for role assignment queries..." -NoNewLine -IsWarning
801+
az config set extension.dynamic_install_allow_preview=true 2>$null
802+
az extension add --name resource-graph 2>$null
803+
}
804+
798805
Write-ToConsoleLog "Processing custom role definition: $($roleDefinition.roleName) (ID: $($roleDefinition.name))" -NoNewLine
799806

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

857864
Test-RequiredTooling
858865

866+
Write-ToConsoleLog "This cmdlet uses preview features of the Azure CLI. By continuing, you agree to install preview extensions." -IsWarning
867+
859868
$TempLogFileForPlan = ""
860869
if($PlanMode) {
861870
Write-ToConsoleLog "Plan Mode enabled, no changes will be made. All actions will be logged as what would be performed." -IsWarning

0 commit comments

Comments
 (0)