Skip to content

Commit 1289026

Browse files
anwatherAnthony Watherston
and
Anthony Watherston
authored
Add mandatory parameter and Linux style folder (#958)
Co-authored-by: Anthony Watherston <Anthony.Watherston@microsoft.com>
1 parent 3875dea commit 1289026

File tree

3 files changed

+20
-19
lines changed

3 files changed

+20
-19
lines changed

Docs/integrating-with-alz-library.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,16 @@ This file contains information that drives the sync process. The file includes m
4949

5050
```ps1
5151
# Create a default file for ALZ policies using the latest version of the ALZ Library
52-
New-ALZPolicyDefaultStructure -Type ALZ
52+
New-ALZPolicyDefaultStructure -DefinitionsRootFolder .\Definitions -Type ALZ
5353
5454
# Create a default file for ALZ policies specifiying a tagged version of the ALZ Library
55-
New-ALZPolicyDefaultStructure -Type ALZ -Tag "platform/alz/2025.02.0"
55+
New-ALZPolicyDefaultStructure -DefinitionsRootFolder .\Definitions -Type ALZ -Tag "platform/alz/2025.02.0"
5656
5757
# Create a default file for ALZ policies by provising a path to a cloned/modified library
58-
New-ALZPolicyDefaultStructure -Type ALZ -LibraryPath <<path to library>>
58+
New-ALZPolicyDefaultStructure -DefinitionsRootFolder .\Definitions -Type ALZ -LibraryPath <<path to library>>
5959
6060
# Create a default file for AMBA policies using the latest version of the ALZ Library
61-
New-ALZPolicyDefaultStructure -Type AMBA
61+
New-ALZPolicyDefaultStructure -DefinitionsRootFolder .\Definitions -Type AMBA
6262
```
6363

6464
3. The file generated contains a representation of a management group structure, enforcement mode settings and required default parameter values. Update these values to match your environment.
@@ -101,16 +101,16 @@ The next command will generate policy assignments based on the values in this fi
101101

102102
```ps1
103103
# Sync the ALZ policies and assign to the "epac-dev" PAC environment.
104-
Sync-ALZPolicyFromLibrary -Type ALZ -DefinitionsRootFolder .\Definitions -PacEnvironmentSelector "epac-dev"
104+
Sync-ALZPolicyFromLibrary -DefinitionsRootFolder .\Definitions -Type ALZ -DefinitionsRootFolder .\Definitions -PacEnvironmentSelector "epac-dev"
105105
106106
# Sync the ALZ policies and assign to the "epac-dev" PAC environment. Specify a tagged version of the ALZ library
107-
Sync-ALZPolicyFromLibrary -Type ALZ -DefinitionsRootFolder .\Definitions -PacEnvironmentSelector "epac-dev" -Tag "platform/alz/2025.02.0"
107+
Sync-ALZPolicyFromLibrary -DefinitionsRootFolder .\Definitions -Type ALZ -DefinitionsRootFolder .\Definitions -PacEnvironmentSelector "epac-dev" -Tag "platform/alz/2025.02.0"
108108
109109
# Sync the ALZ policies from a cloned/modified library
110-
Sync-ALZPolicyFromLibrary -Type ALZ -DefinitionsRootFolder .\Definitions -PacEnvironmentSelector "epac-dev" -LibraryPath <<path to library>>
110+
Sync-ALZPolicyFromLibrary -DefinitionsRootFolder .\Definitions -Type ALZ -DefinitionsRootFolder .\Definitions -PacEnvironmentSelector "epac-dev" -LibraryPath <<path to library>>
111111
112112
# Sync the AMBA policies and assign to the "epac-dev" PAC environment.
113-
Sync-ALZPolicyFromLibrary -Type AMBA -DefinitionsRootFolder .\Definitions -PacEnvironmentSelector "epac-dev"
113+
Sync-ALZPolicyFromLibrary -DefinitionsRootFolder .\Definitions -Type AMBA -DefinitionsRootFolder .\Definitions -PacEnvironmentSelector "epac-dev"
114114
```
115115

116116
Carefully review the generated policy assigments and ensure all parameter and scope information is correct.

Scripts/CloudAdoptionFramework/New-ALZPolicyDefaultStructure.ps1

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Param(
22

3-
[Parameter(Mandatory = $false)]
3+
[Parameter(Mandatory = $true)]
44
[string] $DefinitionsRootFolder,
55

66
[ValidateSet('ALZ', 'FSI', 'AMBA', 'SLZ')]
@@ -28,11 +28,11 @@ if ($DefinitionsRootFolder -eq "") {
2828
if ($LibraryPath -eq "") {
2929
if ($Tag) {
3030
git clone --depth 1 --branch $Tag https://github.com/anwather/Azure-Landing-Zones-Library.git .\temp
31-
$LibraryPath = ".\temp"
31+
$LibraryPath = "./temp"
3232
}
3333
else {
3434
git clone --depth 1 https://github.com/anwather/Azure-Landing-Zones-Library.git .\temp
35-
$LibraryPath = ".\temp"
35+
$LibraryPath = "./temp"
3636
}
3737
}
3838

@@ -77,8 +77,8 @@ foreach ($parameter in $policyDefaultFile.defaults) {
7777
Out-File "$DefinitionsRootFolder\$($Type.ToLower()).policy_default_structure.json" -InputObject ($jsonOutput | ConvertTo-Json -Depth 10) -Encoding utf8 -Force
7878

7979

80-
if ($LibraryPath -eq ".\temp") {
81-
Remove-Item .\temp -Recurse -Force -ErrorAction SilentlyContinue
80+
if ($LibraryPath -eq "./temp") {
81+
Remove-Item ./temp -Recurse -Force -ErrorAction SilentlyContinue
8282
}
8383

8484

Scripts/CloudAdoptionFramework/Sync-ALZPolicyFromLibrary.ps1

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Param(
22

3-
[Parameter(Mandatory = $false)]
3+
[Parameter(Mandatory = $true)]
44
[string] $DefinitionsRootFolder,
55

66
[ValidateSet("ALZ", "AMBA")]
@@ -15,11 +15,11 @@ Param(
1515
if ($LibraryPath -eq "") {
1616
if ($Tag) {
1717
git clone --depth 1 --branch $Tag https://github.com/anwather/Azure-Landing-Zones-Library.git .\temp
18-
$LibraryPath = ".\temp"
18+
$LibraryPath = "./temp"
1919
}
2020
else {
2121
git clone --depth 1 https://github.com/anwather/Azure-Landing-Zones-Library.git .\temp
22-
$LibraryPath = ".\temp"
22+
$LibraryPath = "./temp"
2323
}
2424
}
2525

@@ -142,6 +142,7 @@ foreach ($file in Get-ChildItem -Path "$LibraryPath\platform\$($Type.ToLower())\
142142

143143

144144
$baseTemplate = @{
145+
"`$schema" = "https://raw.githubusercontent.com/Azure/enterprise-azure-policy-as-code/main/Schemas/policy-assignment-schema.json"
145146
nodeName = "$($archetypeContent.name)/$($fileContent.name)"
146147
assignment = @{
147148
name = $fileContent.Name
@@ -235,7 +236,7 @@ foreach ($file in Get-ChildItem -Path "$LibraryPath\platform\$($Type.ToLower())\
235236
if (!(Test-Path $DefinitionsRootFolder\policyAssignments\$Type\$category)) {
236237
New-Item -Path $DefinitionsRootFolder\policyAssignments\$Type\$category -ItemType Directory -Force -ErrorAction SilentlyContinue
237238
}
238-
$baseTemplate | Select-Object nodeName, assignment, definitionEntry, definitionVersion, enforcementMode, parameters, nonComplianceMessages, scope | ConvertTo-Json -Depth 50 | Out-File -FilePath $DefinitionsRootFolder\policyAssignments\$Type\$category\$($fileContent.name).json -Force
239+
$baseTemplate | Select-Object "`$schema", nodeName, assignment, definitionEntry, definitionVersion, enforcementMode, parameters, nonComplianceMessages, scope | ConvertTo-Json -Depth 50 | Out-File -FilePath $DefinitionsRootFolder\policyAssignments\$Type\$category\$($fileContent.name).json -Force
239240
(Get-Content $DefinitionsRootFolder\policyAssignments\$Type\$category\$($fileContent.name).json) -replace "\[\[", "[" | Set-Content $DefinitionsRootFolder\policyAssignments\$Type\$category\$($fileContent.name).json
240241
if ($fileContent.name -eq "Deploy-Private-DNS-Zones") {
241242
(Get-Content $DefinitionsRootFolder\policyAssignments\$Type\$category\$($fileContent.name).json) -replace "\.ne\.", ".$dnsZoneRegion." | Set-Content $DefinitionsRootFolder\policyAssignments\$Type\$category\$($fileContent.name).json
@@ -245,7 +246,7 @@ foreach ($file in Get-ChildItem -Path "$LibraryPath\platform\$($Type.ToLower())\
245246

246247
}
247248

248-
if ($LibraryPath -eq ".\temp") {
249-
Remove-Item .\temp -Recurse -Force -ErrorAction SilentlyContinue
249+
if ($LibraryPath -eq "./temp") {
250+
Remove-Item ./temp -Recurse -Force -ErrorAction SilentlyContinue
250251
}
251252

0 commit comments

Comments
 (0)