-
Notifications
You must be signed in to change notification settings - Fork 771
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support target scopes for modules (#771)
* Add scope type * Very basic emitter, no validation * Attach function arguments to scope * Add ability to set target scope * Add example create-rg-lock-role-assignment * Fix up some tests * Pull in latest types, fix up tests * Check for multiple instances of targetScope declaration * Create INamedDeclarationSyntax * Tidy up * Add some tests * Update docs for scopes * Avoid outputting unrepresentible function types to JSON * Tidy up, add some comments * Combine AzResourceScope & ResoureScopeType enums * Fix vscode e2e test
- Loading branch information
1 parent
83b846d
commit 895cac2
Showing
126 changed files
with
10,453 additions
and
4,033 deletions.
There are no files selected for viewing
Submodule bicep-types-az
updated
130 files
28 changes: 0 additions & 28 deletions
28
docs/examples/201/log-analytics-with-solutions-and-diagnostics/main.bicep
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
docs/examples/modules/create-rg-lock-role-assignment/applylock.bicep
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
targetScope = 'resourceGroup' | ||
|
||
param principalId string | ||
param roleDefinitionId string | ||
param roleAssignmentName string | ||
|
||
resource lockResource 'Microsoft.Authorization/locks@2016-09-01' = { | ||
name: 'DontDelete' | ||
properties: { | ||
level: 'CanNotDelete' | ||
notes: 'Prevent deletion of the resourceGroup' | ||
} | ||
} | ||
|
||
resource assignmentResource 'Microsoft.Authorization/roleAssignments@2020-04-01-preview' = { | ||
name: guid(roleAssignmentName) | ||
properties: { | ||
roleDefinitionId: subscriptionResourceId('Microsoft.Authorization/roleDefinitions', roleDefinitionId) | ||
principalId: principalId | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
docs/examples/modules/create-rg-lock-role-assignment/applylock.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", | ||
"contentVersion": "1.0.0.0", | ||
"parameters": { | ||
"principalId": { | ||
"type": "string" | ||
}, | ||
"roleDefinitionId": { | ||
"type": "string" | ||
}, | ||
"roleAssignmentName": { | ||
"type": "string" | ||
} | ||
}, | ||
"functions": [], | ||
"resources": [ | ||
{ | ||
"type": "Microsoft.Authorization/locks", | ||
"apiVersion": "2016-09-01", | ||
"name": "DontDelete", | ||
"properties": { | ||
"level": "CanNotDelete", | ||
"notes": "Prevent deletion of the resourceGroup" | ||
} | ||
}, | ||
{ | ||
"type": "Microsoft.Authorization/roleAssignments", | ||
"apiVersion": "2020-04-01-preview", | ||
"name": "[guid(parameters('roleAssignmentName'))]", | ||
"properties": { | ||
"roleDefinitionId": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', parameters('roleDefinitionId'))]", | ||
"principalId": "[parameters('principalId')]" | ||
} | ||
} | ||
] | ||
} |
23 changes: 23 additions & 0 deletions
23
docs/examples/modules/create-rg-lock-role-assignment/main.bicep
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
targetScope = 'subscription' | ||
|
||
param rgName string | ||
param rgLocation string | ||
param principalId string | ||
param roleDefinitionId string = 'b24988ac-6180-42a0-ab88-20f7382dd24c' // default is contributor | ||
param roleAssignmentName string = guid(principalId, roleDefinitionId, rgName) | ||
|
||
resource newRg 'Microsoft.Resources/resourceGroups@2019-10-01' = { | ||
name: rgName | ||
location: rgLocation | ||
properties: {} | ||
} | ||
|
||
module applyLock './applylock.bicep' = { | ||
name: 'applyLock' | ||
scope: resourceGroup(newRg.name) | ||
params: { | ||
principalId: principalId | ||
roleDefinitionId: roleDefinitionId | ||
roleAssignmentName: roleAssignmentName | ||
} | ||
} |
95 changes: 95 additions & 0 deletions
95
docs/examples/modules/create-rg-lock-role-assignment/main.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
{ | ||
"$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#", | ||
"contentVersion": "1.0.0.0", | ||
"parameters": { | ||
"rgName": { | ||
"type": "string" | ||
}, | ||
"rgLocation": { | ||
"type": "string" | ||
}, | ||
"principalId": { | ||
"type": "string" | ||
}, | ||
"roleDefinitionId": { | ||
"type": "string", | ||
"defaultValue": "b24988ac-6180-42a0-ab88-20f7382dd24c" | ||
}, | ||
"roleAssignmentName": { | ||
"type": "string", | ||
"defaultValue": "[guid(parameters('principalId'), parameters('roleDefinitionId'), parameters('rgName'))]" | ||
} | ||
}, | ||
"functions": [], | ||
"resources": [ | ||
{ | ||
"type": "Microsoft.Resources/resourceGroups", | ||
"apiVersion": "2019-10-01", | ||
"name": "[parameters('rgName')]", | ||
"location": "[parameters('rgLocation')]", | ||
"properties": {} | ||
}, | ||
{ | ||
"type": "Microsoft.Resources/deployments", | ||
"apiVersion": "2019-10-01", | ||
"name": "applyLock", | ||
"resourceGroup": "[parameters('rgName')]", | ||
"properties": { | ||
"expressionEvaluationOptions": { | ||
"scope": "inner" | ||
}, | ||
"mode": "Incremental", | ||
"parameters": { | ||
"principalId": { | ||
"value": "[parameters('principalId')]" | ||
}, | ||
"roleDefinitionId": { | ||
"value": "[parameters('roleDefinitionId')]" | ||
}, | ||
"roleAssignmentName": { | ||
"value": "[parameters('roleAssignmentName')]" | ||
} | ||
}, | ||
"template": { | ||
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", | ||
"contentVersion": "1.0.0.0", | ||
"parameters": { | ||
"principalId": { | ||
"type": "string" | ||
}, | ||
"roleDefinitionId": { | ||
"type": "string" | ||
}, | ||
"roleAssignmentName": { | ||
"type": "string" | ||
} | ||
}, | ||
"functions": [], | ||
"resources": [ | ||
{ | ||
"type": "Microsoft.Authorization/locks", | ||
"apiVersion": "2016-09-01", | ||
"name": "DontDelete", | ||
"properties": { | ||
"level": "CanNotDelete", | ||
"notes": "Prevent deletion of the resourceGroup" | ||
} | ||
}, | ||
{ | ||
"type": "Microsoft.Authorization/roleAssignments", | ||
"apiVersion": "2020-04-01-preview", | ||
"name": "[guid(parameters('roleAssignmentName'))]", | ||
"properties": { | ||
"roleDefinitionId": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', parameters('roleDefinitionId'))]", | ||
"principalId": "[parameters('principalId')]" | ||
} | ||
} | ||
] | ||
} | ||
}, | ||
"dependsOn": [ | ||
"[resourceId('Microsoft.Resources/resourceGroups', parameters('rgName'))]" | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.