|
| 1 | +{ |
| 2 | + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", |
| 3 | + "contentVersion": "1.0.0.0", |
| 4 | + "parameters": { |
| 5 | + "random": { |
| 6 | + "type": "bool", |
| 7 | + "defaultValue": "[greater(int(utcNow('%f')), 4)]" |
| 8 | + }, |
| 9 | + "denyLocation": { |
| 10 | + "type": "string", |
| 11 | + "defaultValue": "northeurope" |
| 12 | + } |
| 13 | + }, |
| 14 | + "variables": { |
| 15 | + "policyDefinitionName": "policy-for-what-if-test" |
| 16 | + }, |
| 17 | + "resources": [ |
| 18 | + { |
| 19 | + "name": "[variables('policyDefinitionName')]", |
| 20 | + "type": "Microsoft.Authorization/policyDefinitions", |
| 21 | + "apiVersion": "2018-05-01", |
| 22 | + "condition": "[parameters('random')]", |
| 23 | + "properties": { |
| 24 | + "policyType": "Custom", |
| 25 | + "policyRule": { |
| 26 | + "if": { |
| 27 | + "field": "location", |
| 28 | + "equals": "[parameters('denyLocation')]" |
| 29 | + }, |
| 30 | + "then": { |
| 31 | + "effect": "deny" |
| 32 | + } |
| 33 | + } |
| 34 | + } |
| 35 | + }, |
| 36 | + { |
| 37 | + "name": "[format('{0}_{1}', variables('policyDefinitionName'), if(parameters('random'), '2', '3'))]", |
| 38 | + "type": "Microsoft.Authorization/policyDefinitions", |
| 39 | + "apiVersion": "2018-05-01", |
| 40 | + "properties": { |
| 41 | + "policyType": "Custom", |
| 42 | + "policyRule": { |
| 43 | + "if": { |
| 44 | + "field": "location", |
| 45 | + "equals": "[parameters('denyLocation')]" |
| 46 | + }, |
| 47 | + "then": { |
| 48 | + "effect": "deny" |
| 49 | + } |
| 50 | + } |
| 51 | + } |
| 52 | + }, |
| 53 | + { |
| 54 | + "type": "Microsoft.Resources/deployments", |
| 55 | + "apiVersion": "2024-11-01", |
| 56 | + "name": "nestedDeployment", |
| 57 | + "location": "[deployment().location]", |
| 58 | + "properties": { |
| 59 | + "mode": "Incremental", |
| 60 | + "template": { |
| 61 | + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", |
| 62 | + "contentVersion": "1.0.0.0", |
| 63 | + "resources": [], |
| 64 | + "variables": { |
| 65 | + "undecidable": "[parameters('random')]" |
| 66 | + } |
| 67 | + } |
| 68 | + } |
| 69 | + } |
| 70 | + ] |
| 71 | +} |
0 commit comments