Skip to content

Commit 7380a03

Browse files
anwatherAnthony Watherston
andauthored
Aw/issue1042 (#1043)
* Fix GR assignment sync * Minor fix --------- Co-authored-by: Anthony Watherston <[email protected]>
1 parent 7088ecc commit 7380a03

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

Scripts/CloudAdoptionFramework/New-ALZPolicyDefaultStructure.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ foreach ($parameter in $policyDefaults) {
202202
# Build Guardrail Deployment Object
203203

204204
if ($Type -eq "ALZ") {
205-
$guardRailPolicyFileNames = Get-ChildItem $LibraryPath\platform\$($Type.ToLower())\policy_set_definitions\*.json | Where-Object { $_.Name -match "^Enforce-Guardrails-" } | Select-Object -ExpandProperty Name
205+
$guardRailPolicyFileNames = Get-ChildItem $LibraryPath\platform\$($Type.ToLower())\policy_set_definitions\*.json | Where-Object { ($_.Name -match "^Enforce-(Guardrails|Encryption)-") } | Select-Object -ExpandProperty Name
206206
$policySetNames = $guardRailPolicyFileNames | Foreach-Object { $_.Split(".")[0] }
207207
$obj = @{
208208
policy_set_names = $policySetNames

Scripts/CloudAdoptionFramework/Sync-ALZPolicyFromLibrary.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ catch {
154154
try {
155155
foreach ($file in Get-ChildItem -Path "$LibraryPath/platform/$($Type.ToLower())/archetype_definitions" -Recurse -File -Include *.json) {
156156
$archetypeContent = Get-Content -Path $file.FullName -Raw | ConvertFrom-Json
157-
foreach ($requiredAssignment in $archetypeContent.policy_assignments) {
157+
foreach ($requiredAssignment in ($archetypeContent.policy_assignments | Where-Object { ($_ -notmatch "^Enforce-(GR|Encrypt)-\w+0") })) {
158158
switch ($Type) {
159159
"ALZ" { $fileContent = Get-ChildItem -Path "$LibraryPath/platform/$($Type.ToLower())/policy_assignments" | Where-Object { $_.BaseName.Split(".")[0] -eq $requiredAssignment } | Get-Content -Raw | ConvertFrom-Json }
160160
"AMBA" { $fileContent = Get-ChildItem -Path "$LibraryPath/platform/$($Type.ToLower())/policy_assignments" | Where-Object { $_.BaseName.Split(".")[0].Replace("_", "-") -eq $requiredAssignment } | Get-Content -Raw | ConvertFrom-Json }
@@ -277,14 +277,14 @@ try {
277277
if ($CreateGuardrailAssignments -and $Type -eq "ALZ") {
278278
foreach ($deployment in $structureFile.enforceGuardrails.deployments) {
279279
foreach ($file in Get-ChildItem "$LibraryPath/platform/$($Type.ToLower())/policy_set_definitions" -Recurse -File -Include *.json) {
280-
if (($file.Name -match "^Enforce-Guardrails") -and ($file.Name.Split(".")[0] -in $deployment.policy_set_names)) {
280+
if (($file.Name -match "^Enforce-(Guardrails|Encryption)-") -and ($file.Name.Split(".")[0] -in $deployment.policy_set_names)) {
281281
$fileContent = Get-Content -Path $file.FullName -Raw | ConvertFrom-Json -Depth 100
282282

283283
$baseTemplate = [ordered]@{
284284
"`$schema" = "https://raw.githubusercontent.com/Azure/enterprise-azure-policy-as-code/main/Schemas/policy-assignment-schema.json"
285285
nodeName = "$($fileContent.name)"
286286
assignment = [ordered]@{
287-
name = $fileContent.Name -replace "Enforce-Guardrails", "GR"
287+
name = $fileContent.Name -replace "Enforce-Guardrails", "GR" -replace "Enforce-Encryption", "EN"
288288
displayName = $fileContent.properties.displayName
289289
description = $fileContent.properties.description
290290
}

0 commit comments

Comments
 (0)