Skip to content

Commit 97093b0

Browse files
authored
Merge pull request #976 from Azure/feature/apy/ALZSyncEnhancements
Feature/apy/alz sync enhancements
2 parents c8fd295 + cb8702d commit 97093b0

8 files changed

+123
-94
lines changed

Docs/integrating-with-alz-library.md

Lines changed: 63 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,15 @@
1-
# Integrating EPAC with the Azure Landing Zones Library
1+
# Integrating EPAC with the Azure Landing Zones Library (New)
22

3-
The [Azure Landing Zones Library](https://azure.github.io/Azure-Landing-Zones-Library/) contains the source of all policy definitions, set definition and assignments for not only the Azure Landing Zone deployment but associated projects such as the Azure Monitor Baseline Alerts and Sovereign Landing Zone accelerator. Previous integration with EPAC involved manually updating the assignments provided and was complex and difficult to maintain.
4-
5-
This new method of maintaining and deploying the policies provides the following benefits: -
6-
7-
- One process for ALZ / AMBA / SLZ instead of separate processes.
8-
- Pin to a version of the library by specifying a tag during sync - or refer to an already cloned copy.
9-
- Modify the cloned repository to add new assignments, management group archetypes, parameters.
10-
- A single file provides the default values for the policy assignments making it easier to maintain. Add new parameter values as required.
11-
12-
## Why and when should you use EPAC to manage ALZ deployed policies
13-
14-
EPAC can be used to manage Azure Policy deployed using ALZ Bicep or Terraform using the scenarios below. Some reasons you may want to switch to EPAC policy management include:
15-
16-
- You have existing unmanaged policies in a brownfield environment that you want to deploy in the new ALZ environment. [Export the existing policies](start-extracting-policy-resources.md) and manage them with EPAC alongside the ALZ policy objects.
17-
- You have ALZ deployed in a non standard way e.g. multiple management group structures for testing, non-conventional management group structure. The default assignment structure provided by other ALZ deployment methods may not fit your strategy.
18-
- A team that is not responsible for infrastructure deployment e.g. a security team may want to deploy and manage policies.
19-
- You require features from policy not available in the ALZ deployments e.g. policy exemptions, documentation, assignment customization.
20-
- Non-compliance reporting and remediation task management.
21-
22-
## Recommendation for existing deployment using EPAC
23-
24-
If you already use the `Sync-ALZPolicies` command you should move to the new process as the assignments are no longer being maintained. Follow the instructions below to create a policy structure file and then perform a sync. The main difference existing users will notice is there is that all the assignments have been split out into single files instead of the existing structure. For ease of use these are now grouped into folders based on landing zone archetypes.
25-
26-
## Scenarios
27-
28-
1. Existing Azure Landing Zones deployment and EPAC is to be used as the policy engine moving forward.
29-
2. Using EPAC to deploy and manage the Azure Landing Zone policies.
30-
31-
In both cases it is now recommended that if you have the default ALZ policies deployed you should use the new method to provide a consistent sync process.
32-
33-
## Using the new Azure Landing Zone Library sync process
34-
35-
### Pre-requisites
3+
## Pre-requisites
364

375
To use the ALZ policies in an environment successfully there are some Azure Resources that need to be created. This is normally completed by using one of the ALZ accelerators to deploy the environment however if you have written your own code or modified the default deployment ensure you have the following resources in place to support the ALZ policies.
386

397
- Log Analytics workspace
408
- DCR rules to support monitoring - [data collection rule templates](https://github.com/Azure/Enterprise-Scale/tree/main/eslzArm/resourceGroupTemplates)
419
- User Assigned Managed Identity to support Azure Monitor Agent - [sample template](https://github.com/Azure/Enterprise-Scale/blob/main/eslzArm/resourceGroupTemplates/userAssignedIdentity.json)
4210

11+
## Using the new Azure Landing Zone Library sync process
12+
4313
### Create a policy default structure file
4414

4515
This file contains information that drives the sync process. The file includes management group IDs, default enforcement mode, and parameter values. **It must be generated at least once before executing the sync process.**
@@ -48,8 +18,8 @@ This file contains information that drives the sync process. The file includes m
4818
2. Use to code to clone the library repository and create the default file. There are examples below on how to run this commnand - you will only need to run one of these depending on your requirements.
4919

5020
```ps1
51-
# Create a default file for ALZ policies using the latest version of the ALZ Library
52-
New-ALZPolicyDefaultStructure -DefinitionsRootFolder .\Definitions -Type ALZ
21+
# Create a Pac Environment default file for ALZ policies using the latest version of the ALZ Library
22+
New-ALZPolicyDefaultStructure -DefinitionsRootFolder .\Definitions -Type ALZ -PacEnvironmentSelector "epac-dev"
5323
5424
# Create a default file for ALZ policies specifiying a tagged version of the ALZ Library
5525
New-ALZPolicyDefaultStructure -DefinitionsRootFolder .\Definitions -Type ALZ -Tag "platform/alz/2025.02.0"
@@ -95,9 +65,11 @@ Modify the default enforcement mode
9565
"enforcementMode": "Default" // Can be Default or DoNotEnforce
9666
```
9767

68+
### Sync with ALZ Policy Repo
69+
9870
The next command will generate policy assignments based on the values in this file so ensure they are correct for your environment.
9971

100-
4. Use to code to sync the policy files and update scopes and parameters based on the information in the previously created file. There are examples below on how to run this command - you will only need to run one of these depending on your requirements. The files will be copied into their own folder to separate them from any definitions already in the repository.
72+
1. Use to code to sync the policy files and update scopes and parameters based on the information in the previously created file. There are examples below on how to run this command - you will only need to run one of these depending on your requirements. The files will be copied into their own folder to separate them from any definitions already in the repository.
10173

10274
```ps1
10375
# Sync the ALZ policies and assign to the "epac-dev" PAC environment.
@@ -115,11 +87,64 @@ Sync-ALZPolicyFromLibrary -DefinitionsRootFolder .\Definitions -Type AMBA -PacEn
11587

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

118-
5. When complete run `Build-DeploymentPlans` to ensure the correct changes are made. During the first sync for either a new or existing environment there will be many changes due to updating of the existing policies.
90+
2. When complete run `Build-DeploymentPlans` to ensure the correct changes are made. During the first sync for either a new or existing environment there will be many changes due to updating of the existing policies.
91+
92+
## Example
93+
94+
### ALZ
95+
96+
```ps1
97+
# Create a Pac Environment default file for ALZ policies using the latest version of the ALZ Library
98+
New-ALZPolicyDefaultStructure -DefinitionsRootFolder .\Definitions -Type ALZ -PacEnvironmentSelector "epac-dev"
99+
100+
# Sync the ALZ policies and assign to the "epac-dev" PAC environment.
101+
Sync-ALZPolicyFromLibrary -DefinitionsRootFolder .\Definitions -Type ALZ -PacEnvironmentSelector "epac-dev"
102+
```
103+
104+
### AMBA (ALZ)
105+
106+
For users interested in deploying the [Azure Monitor Baseline Alerts](https://azure.github.io/azure-monitor-baseline-alerts/welcome/) project with EPAC - these policies have been extracted and converted to the EPAC format and are available at the [amba-export](https://github.com/anwather/amba-export) repository.
107+
108+
```ps1
109+
# Create a Pac Environment default file for ALZ policies using the latest version of the ALZ Library
110+
New-ALZPolicyDefaultStructure -DefinitionsRootFolder .\Definitions -Type AMBA -PacEnvironmentSelector "epac-dev"
111+
112+
# Sync the ALZ policies and assign to the "epac-dev" PAC environment.
113+
Sync-ALZPolicyFromLibrary -DefinitionsRootFolder .\Definitions -Type AMBA -PacEnvironmentSelector "epac-dev"
114+
```
115+
116+
### SLZ
117+
118+
For users interested in deploying the [Sovereignty Policy Baseline](https://github.com/Azure/sovereign-landing-zone/blob/main/docs/scenarios/Sovereignty-Baseline-Policy-Initiatives.md) project with EPAC - these policies have been extracted and converted to the EPAC format and are available at the [spb-export](https://github.com/anwather/spb-export) repository.
119+
120+
```ps1
121+
# Create a Pac Environment default file for ALZ policies using the latest version of the ALZ Library
122+
New-ALZPolicyDefaultStructure -DefinitionsRootFolder .\Definitions -Type AMBA -PacEnvironmentSelector "epac-dev"
123+
124+
# Sync the ALZ policies and assign to the "epac-dev" PAC environment.
125+
Sync-ALZPolicyFromLibrary -DefinitionsRootFolder .\Definitions -Type AMBA -PacEnvironmentSelector "epac-dev"
126+
```
119127

120128
## Advanced Scenarios
121129

122130
Using the format of the Azure Landing Zones repository it is possible to extend the management groups defined and provide your own archetypes. You must maintain a local copy of the library for this purpose. Details will be provided at a later stage on how to customize this for different scenarios including:
123131

124132
- Modifying the management group structure (add new groups and archetypes)
125133
- Add/Remove policies from an archetype
134+
135+
### Maintaining multiple ALZ/AMBA environment with different parameter / management group values
136+
137+
If you need to have separate parameter values or different management group names for different PAC environments you can follow steps below.
138+
139+
1. Generate a policy structure file using `New-ALZPolicyDefaultStructure` and specify the `-PacEnvironmentSelector` parameter.
140+
141+
This generates a standard file structure however the file's name will now include the Pac Selector given. This default structure will now be used everytime you run the "Sync-ALZPolicyFromLibrary" command with the matching PacEnvironmentSelector.
142+
143+
For example: -
144+
145+
```
146+
alz.policy_default_structure.<PAC SELECTOR>.jsonc
147+
```
148+
149+
2. When syncing policies run the `Sync-ALZPolicyFromLibrary` once for each PAC Environment. A folder specific for that Pac Selector will now be placed within the ALZ Type.
150+

Docs/integrating-with-alz-monitor.md

Lines changed: 0 additions & 7 deletions
This file was deleted.

Docs/integrating-with-alz-overview.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Integrating EPAC with Azure Landing Zones
2+
3+
## What are Azure Landing Zones (ALZ)?
4+
5+
Azure Landing Zones (ALZ) are a set of best practices, templates, and resources provided by Microsoft to help organizations set up a secure, scalable, and compliant foundation in Azure. They are part of the broader Cloud Adoption Framework (CAF), which is Microsoft's guidance for cloud adoption across strategy, planning, readiness, governance, and management.
6+
7+
Microsoft publishes and maintains a [list of Policies, Policy Sets and Assignments](https://aka.ms/alz/policies) which are deployed as part of the Cloud Adoption Framework Azure Landing Zones deployment. The central repository that contains these policies acts as the source of truth for ALZ deployments via the portal, Bicep and Terraform.
8+
9+
To enable customers to use the Enterprise Policy as Code solution and combine Microsoft's policy recommendations there is a script which will pull the Policies, Policy Sets and Policy Assignments from the central repository and allow you to deploy them using this solution.
10+
11+
As the policies and assignments change in main repository the base files in this solution can be updated to match.
12+
13+
## Why and when should you use EPAC to manage ALZ deployed policies
14+
15+
EPAC can be used to manage Azure Policy deployed using ALZ Bicep or Terraform using the scenarios below. Some reasons you may want to switch to EPAC policy management include:
16+
17+
- You have existing unmanaged policies in a brownfield environment that you want to deploy in the new ALZ environment. [Export the existing policies](start-extracting-policy-resources.md) and manage them with EPAC alongside the ALZ policy objects.
18+
- You have ALZ deployed in a non standard way e.g. multiple management group structures for testing, non-conventional management group structure. The default assignment structure provided by other ALZ deployment methods may not fit your strategy.
19+
- A team that is not responsible for infrastructure deployment e.g. a security team may want to deploy and manage policies.
20+
- You require features from policy not available in the ALZ deployments e.g. policy exemptions, documentation, assignment customization.
21+
- Non-compliance reporting and remediation task management.
22+
23+
## Scenarios
24+
25+
1. Existing Azure Landing Zones deployment and EPAC is to be used as the policy engine moving forward.
26+
2. Using EPAC to deploy and manage the Azure Landing Zone policies.
27+
28+
In both cases it is now recommended that if you have the default ALZ policies deployed you should use the [new method](integrating-with-alz-library.md) to provide a consistent sync process.

Docs/integrating-with-alz.md

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,4 @@
1-
# Integrating EPAC with Azure Landing Zones
2-
3-
## Rationale
4-
5-
Microsoft publishes and maintains a [list of Policies, Policy Sets and Assignments](https://aka.ms/alz/policies) which are deployed as part of the Cloud Adoption Framework Azure Landing Zones deployment. The central repository that contains these policies acts as the source of truth for ALZ deployments via the portal, Bicep and Terraform. A current list of policies which are deployed using these solutions is found at this link.
6-
7-
To enable customers to use the Enterprise Policy as Code solution and combine Microsoft's policy recommendations there is a script which will pull the Policies, Policy Sets and Policy Assignments from the central repository and allow you to deploy them using this solution.
8-
9-
As the policies and assignments change in main repository the base files in this solution can be updated to match.
10-
11-
## Why and when should you use EPAC to manage ALZ deployed policies
12-
13-
EPAC can be used to manage Azure Policy deployed using ALZ Bicep or Terraform using the scenarios below. Some reasons you may want to switch to EPAC policy management include:
14-
15-
- You have existing unmanaged policies in a brownfield environment that you want to deploy in the new ALZ environment. [Export the existing policies](start-extracting-policy-resources.md) and manage them with EPAC alongside the ALZ policy objects.
16-
- You have ALZ deployed in a non standard way e.g. multiple management group structures for testing, non-conventional management group structure. The default assignment structure provided by other ALZ deployment methods may not fit your strategy.
17-
- A team that is not responsible for infrastructure deployment e.g. a security team may want to deploy and manage policies.
18-
- You require features from policy not available in the ALZ deployments e.g. policy exemptions, documentation, assignment customization.
19-
- Non-compliance reporting and remediation task management.
20-
21-
Instructions are provided below for integrating with Bicep and Terraform deployments.
22-
23-
## Scenarios
24-
25-
There are two scenarios for integrating EPAC with ALZ.
26-
27-
1. Existing Azure Landing Zone deployment and EPAC is to be used as the policy engine moving forward.
28-
2. Using EPAC to deploy and manage the Azure Landing Zone policies.
1+
# Integrating EPAC with the Azure Landing Zones Library (Legacy)
292

303
## Scenario 1 - Existing Deployment
314

Docs/integrating-with-slz.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

Scripts/CloudAdoptionFramework/New-ALZPolicyDefaultStructure.ps1

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
12
Param(
2-
33
[Parameter(Mandatory = $true)]
44
[string] $DefinitionsRootFolder,
55

@@ -8,7 +8,9 @@ Param(
88

99
[string]$LibraryPath,
1010

11-
[string]$Tag
11+
[string]$Tag,
12+
13+
[string] $PacEnvironmentSelector
1214
)
1315

1416
if ($DefinitionsRootFolder -eq "") {
@@ -35,7 +37,6 @@ if ($LibraryPath -eq "") {
3537
}
3638
}
3739

38-
3940
$jsonOutput = @{
4041
managementGroupNameMappings = @{}
4142
defaultParameterValues = @{}
@@ -44,8 +45,7 @@ $jsonOutput = @{
4445

4546
# Get Management Group Names
4647

47-
$archetypeDefinitionFile = Get-Content -Path "$LibraryPath\platform\$($Type.ToLower())\architecture_definitions\$($Type.ToLower()).alz_architecture_definition.json" | `
48-
ConvertFrom-Json
48+
$archetypeDefinitionFile = Get-Content -Path "$LibraryPath\platform\$($Type.ToLower())\architecture_definitions\$($Type.ToLower()).alz_architecture_definition.json" | ConvertFrom-Json
4949

5050
foreach ($mg in $archetypeDefinitionFile.management_groups) {
5151
$obj = @{
@@ -66,7 +66,7 @@ foreach ($parameter in $policyDefaultFile.defaults) {
6666
$assignment = $parameter.policy_assignments[0]
6767

6868
$assingmentFileName = ("$($assignment.policy_assignment_name).alz_policy_assignment.json")
69-
if ($type -eq "AMBA") {
69+
if ($Type -eq "AMBA") {
7070
$assingmentFileName = $assingmentFileName -replace ("-", "_")
7171
}
7272
$file = Get-ChildItem -Recurse -Path ".\temp" -Filter "$assingmentFileName" -File | Select-Object -First 1
@@ -85,12 +85,20 @@ foreach ($parameter in $policyDefaultFile.defaults) {
8585
$jsonOutput.defaultParameterValues.Add($parameter.default_name, $obj)
8686
}
8787

88-
Out-File "$DefinitionsRootFolder\$($Type.ToLower()).policy_default_structure.jsonc" -InputObject ($jsonOutput | ConvertTo-Json -Depth 10) -Encoding utf8 -Force
88+
# Ensure the output directory exists
89+
$outputDirectory = "$DefinitionsRootFolder\policyStructures"
90+
if (-not (Test-Path -Path $outputDirectory)) {
91+
New-Item -ItemType Directory -Path $outputDirectory
92+
}
8993

94+
if ($PacEnvironmentSelector) {
95+
Out-File "$outputDirectory\$($Type.ToLower()).policy_default_structure.$PacEnvironmentSelector.jsonc" -InputObject ($jsonOutput | ConvertTo-Json -Depth 10) -Encoding utf8 -Force
96+
}
97+
else {
98+
Out-File "$outputDirectory\$($Type.ToLower()).policy_default_structure.jsonc" -InputObject ($jsonOutput | ConvertTo-Json -Depth 10) -Encoding utf8 -Force
99+
}
90100

91101
$tempPath = Join-Path -Path (Get-Location) -ChildPath "temp"
92102
if ($LibraryPath -eq $tempPath) {
93103
Remove-Item $LibraryPath -Recurse -Force -ErrorAction SilentlyContinue
94104
}
95-
96-

0 commit comments

Comments
 (0)