-
Notifications
You must be signed in to change notification settings - Fork 518
/
upstreamPolicyUpdateProcess.tour
371 lines (371 loc) · 13 KB
/
upstreamPolicyUpdateProcess.tour
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
{
"$schema": "https://aka.ms/codetour-schema",
"title": "Upstream Policy Update Process",
"steps": [
{
"file": ".github/workflows/update-policy.yml",
"description": "This GitHub Action is responsible for syncing the policies from the upstream Enterprise-Scale repo into the ALZ-Bicep `lib` folders as explained here: https://github.com/Azure/ALZ-Bicep/wiki/PolicyDeepDive",
"line": 2
},
{
"file": ".github/workflows/update-policy.yml",
"description": "It runs every weekday at 0800 UTC",
"line": 6
},
{
"file": ".github/workflows/update-policy.yml",
"description": "It can also be triggered manually by maintainers of the repo, if reuqired",
"line": 7
},
{
"file": ".github/workflows/update-policy.yml",
"description": "This makes sure the action only runs if the repo the action is running on is `Azure/ALZ-Bicep`.\r\n\r\nIf you clone this repo and want this action to run, you'll either need to remove this line or amend it",
"line": 19,
"selection": {
"start": {
"line": 19,
"character": 31
},
"end": {
"line": 19,
"character": 46
}
}
},
{
"file": ".github/workflows/update-policy.yml",
"description": "Checkout the `ALZ-Bicep` repo to the folder `Azure/ALZ-Bicep`",
"line": 23
},
{
"file": ".github/workflows/update-policy.yml",
"description": "Checkout the `Enterprise-Scale` repo to the folder `Azure/Enterprise-Scale`",
"line": 29
},
{
"file": ".github/workflows/update-policy.yml",
"description": "Configure the GitHub Action runner Git user name and e-mail address so that it can make commits and push later",
"line": 36
},
{
"file": ".github/workflows/update-policy.yml",
"description": "Create a new local branch on the `ALZ-Bicep` repo using the environment variable called `branch_name` (see line 11) as the branch name, if it doesn't exist already.\r\n\r\nIf it does already exist then still create the branch but set the existing branch in the origin as the tracked branch.\r\n\r\n",
"line": 42
},
{
"file": ".github/workflows/update-policy.yml",
"selection": {
"start": {
"line": 61,
"character": 11
},
"end": {
"line": 62,
"character": 109
}
},
"description": "Install the required version of the `Az.Accounts` Azure PowerShell module on the runner (see line 12 where is set in enviornment variable)"
},
{
"file": ".github/workflows/update-policy.yml",
"selection": {
"start": {
"line": 63,
"character": 11
},
"end": {
"line": 68,
"character": 19
}
},
"description": "Then Run the `Invoke-LibraryUpdate.ps1` PowerShell script and pass in the required input parameters of:\r\n\r\n1. `TargetModulePath` = Path to ALZ-Bicep repo clone/check out\r\n2. `SourceModulePath` = Path to Enterprise-Scale repo clone/check out\r\n\r\nThe `Reset` input parameter flag tells the script to remove any files that already exist in the current `lib` folders (think of it as an enforced overwrite)"
},
{
"file": ".github/scripts/Invoke-LibraryUpdate.ps1",
"selection": {
"start": {
"line": 24,
"character": 1
},
"end": {
"line": 27,
"character": 45
}
},
"description": "As you can see the require input parameters have some default values, but we provide them anyway when calling the script."
},
{
"file": ".github/scripts/Invoke-LibraryUpdate.ps1",
"selection": {
"start": {
"line": 32,
"character": 1
},
"end": {
"line": 37,
"character": 48
}
},
"description": "As the comment states, this script uses a PowerShell module that is also contained in the repo, but it is unlikely you need to amend or make changes to this ever!"
},
{
"file": ".github/scripts/Invoke-LibraryUpdate.ps1",
"description": "Set the output directory for the policies once split into individual files",
"line": 53
},
{
"file": ".github/scripts/Invoke-LibraryUpdate.ps1",
"selection": {
"start": {
"line": 76,
"character": 9
},
"end": {
"line": 77,
"character": 68
}
},
"description": ""
},
{
"file": ".github/scripts/Invoke-LibraryUpdate.ps1",
"selection": {
"start": {
"line": 76,
"character": 27
},
"end": {
"line": 76,
"character": 68
}
},
"description": "For resources with the type of `Microsoft.Authorization/policyDefinitions` then add the `fileNamePrefix` to the `outputPath` set on line 53"
},
{
"file": ".github/scripts/Invoke-LibraryUpdate.ps1",
"selection": {
"start": {
"line": 84,
"character": 1
},
"end": {
"line": 85,
"character": 76
}
},
"description": "For resources with the type of `Microsoft.Authorization/policySetDefinitions` then add the `fileNamePrefix` to the `outputPath` set on line 53"
},
{
"file": ".github/scripts/Invoke-LibraryUpdate.ps1",
"selection": {
"start": {
"line": 90,
"character": 1
},
"end": {
"line": 97,
"character": 2
}
},
"description": "As `Reset` flag is set to `$true` then remove all files from the existing libraries to ensure it is clean before beginning conversion process"
},
{
"file": ".github/scripts/Invoke-LibraryUpdate.ps1",
"selection": {
"start": {
"line": 99,
"character": 1
},
"end": {
"line": 112,
"character": 2
}
},
"description": "Convert Enterprise-Scale policies in it's various files into individual files into the correct `lib` folders as specified in the variables above"
},
{
"file": ".github/workflows/update-policy.yml",
"selection": {
"start": {
"line": 71,
"character": 7
},
"end": {
"line": 76,
"character": 52
}
},
"description": "Run the `Invoke-PolicyToBicep.ps1` PowerShell script in the working directory of the clone/checkout of the `ALZ-Bicep` repo where the previous script that has just run (above) has now populated the `lib` folders with the latest changes from the `Enterprise-Scale` policy files."
},
{
"file": ".github/scripts/Invoke-PolicyToBicep.ps1",
"selection": {
"start": {
"line": 10,
"character": 1
},
"end": {
"line": 11,
"character": 18
}
},
"description": "Create and overwrite the `_policyDefinitionsBicepInput.txt` file in the specified directory with a new empty file with `utf8` encoding",
"line": 44
},
{
"file": ".github/scripts/Invoke-PolicyToBicep.ps1",
"selection": {
"start": {
"line": 21,
"character": 135
},
"end": {
"line": 21,
"character": 264
}
},
"description": "For every `.json` file in the `lib/policy_definitions` directory extract the policy definition name and the file path and then write them (append) into the `_policyDefinitionsBicepInput.txt` file in a Bicep formatted output (see end of line 54)",
"line": 47
},
{
"file": ".github/scripts/Invoke-PolicyToBicep.ps1",
"selection": {
"start": {
"line": 24,
"character": 1
},
"end": {
"line": 26,
"character": 102
}
},
"description": "Count the number of policy definitions in the `lib/policy_definitions` directory and output to the console the total number",
"line": 57
},
{
"file": ".github/scripts/Invoke-PolicyToBicep.ps1",
"selection": {
"start": {
"line": 110,
"character": 1
},
"end": {
"line": 112,
"character": 117
}
},
"description": "Count the number of policy set definitions in the `lib/policy_set_definitions` directory and output to the console the total number"
},
{
"file": ".github/scripts/Invoke-PolicyToBicep.ps1",
"selection": {
"start": {
"line": 30,
"character": 1
},
"end": {
"line": 31,
"character": 162
}
},
"description": "Create and overwrite the `_policySetDefinitionsBicepInput.txt` file in the specified directory with a new empty file with `utf8` encoding",
"line": 69
},
{
"file": ".github/scripts/Invoke-PolicyToBicep.ps1",
"description": "For every `.json` file in the `lib/policy_set_definitions` directory extract the policy set definitions (initiative) name and the file path and then write them (append) into the `_policySetDefinitionsBicepInput.txt` file in a Bicep formatted output (see end of line 145, 168 and 172).\r\n\r\nIt also creates a parameters file (not an ARM complaint one, just a JSON compliant document). And it also loops through all the child policy definitions of each policy set definition (initiative) and extracts the definition reference ID and the definition ID and adds them to the output in the `_policySetDefinitionsBicepInput.txt` file",
"line": 64
},
{
"file": ".github/scripts/Invoke-PolicyToBicep.ps1",
"selection": {
"start": {
"line": 116,
"character": 1
},
"end": {
"line": 117,
"character": 155
}
},
"description": "Create and overwrite the `_policyAssignmentsBicepInput.txt` file in the specified directory with a new empty file with `utf8` encoding",
"line": 200
},
{
"file": ".github/scripts/Invoke-PolicyToBicep.ps1",
"selection": {
"start": {
"line": 119,
"character": 1
},
"end": {
"line": 132,
"character": 2
}
},
"description": "For every `.json` file in the `lib/policy_assignments` directory extract the policy assignment's name and the file path and then write them (append) into the `_policyAssignmentsBicepInput.txt` file in a Bicep formatted output (see end of line 131).",
"line": 203
},
{
"file": ".github/scripts/Invoke-PolicyToBicep.ps1",
"selection": {
"start": {
"line": 134,
"character": 1
},
"end": {
"line": 136,
"character": 109
}
},
"description": "Count the number of policy assignments in the `lib/policy_assignments` directory and output to the console the total number",
"line": 218
},
{
"file": ".github/workflows/update-policy.yml",
"selection": {
"start": {
"line": 78,
"character": 7
},
"end": {
"line": 84,
"character": 52
}
},
"description": "Do a `git status` to check for any file changes compared to what is already in the `main` branch of the `ALZ-Bicep` repo that we cloned/checked out earlier"
},
{
"file": ".github/workflows/update-policy.yml",
"selection": {
"start": {
"line": 86,
"character": 7
},
"end": {
"line": 94,
"character": 52
}
},
"description": "If there were any chages to files then commit them and push them, and the branch (`patch-policy-library`), to the `ALZ-Bicep` repo"
},
{
"file": ".github/workflows/update-policy.yml",
"selection": {
"start": {
"line": 96,
"character": 7
},
"end": {
"line": 118,
"character": 52
}
},
"description": "Create a draft PR on the `ALZ-Bicep` repo for merging the `pathc-policy-library` branch into `main` and set the PR title and body from the environment variables (see lines 13 and 14)"
},
{
"title": "Maintainer Review",
"description": "A maintainer of the `ALZ-Bicep` repo will review the newly created PR and assess the changes and make any required changes to any of the modules if new policies have been added etc. using the `.txt` files generated by the `Invoke-PolicyToBicep.ps1` PowerShell script to copy the enitire contents of them into the respective `.bicep` module making the update process simple.\r\n\r\n> Be aware that for the policy set definitions the policy called `Deploy-Private-DNS-Zones` the `defintionParameters` use `-`'s which are not supported in Bicep so must be wrapped like this `['DINE-Private-DNS-Azure-Batch']` manually if you are replacing the whole `varCustomPolicySetDefinitionsArray` variable array from the `.txt` file."
}
]
}