-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
44118b9
commit 2c3e973
Showing
11 changed files
with
251 additions
and
8 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
{ | ||
"experimentalFeaturesEnabled": { | ||
"userDefinedTypes": true | ||
"userDefinedTypes": true, | ||
"optionalModuleNames": true | ||
} | ||
} |
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
param keyVaultName string = 'vault1' | ||
param objectId string = newGuid() | ||
|
||
var newAccessPolicies = [ | ||
{ | ||
tenantId: tenant().tenantId | ||
objectId: objectId | ||
permissions: { | ||
keys: [ | ||
'Get' | ||
'List' | ||
] | ||
secrets: [ | ||
'Get' | ||
'List' | ||
] | ||
certificates: [] | ||
} | ||
} | ||
] | ||
|
||
resource keyvault 'Microsoft.KeyVault/vaults@2021-11-01-preview' existing = { | ||
name: keyVaultName | ||
} | ||
|
||
#disable-next-line BCP035 | ||
resource keyvault2 'Microsoft.KeyVault/vaults@2023-07-01' = { | ||
name: '${keyVaultName}-2' | ||
|
||
#disable-next-line BCP035 | ||
properties: {} | ||
} | ||
|
||
var existingAccessPolicies = keyvault.properties.accessPolicies | ||
var allPolicies = union(existingAccessPolicies, newAccessPolicies) | ||
|
||
module addPolicies './Tests.Bicep.34.child.bicep' = { | ||
params: { | ||
accessPolicies: allPolicies | ||
keyVaultName: keyVaultName | ||
} | ||
} |
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,13 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
param keyVaultName string | ||
param accessPolicies array | ||
|
||
// Policies to add. | ||
resource additionalPolicies 'Microsoft.KeyVault/vaults/accessPolicies@2023-07-01' = { | ||
name: '${keyVaultName}/add' | ||
properties: { | ||
accessPolicies: accessPolicies | ||
} | ||
} |
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,96 @@ | ||
{ | ||
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", | ||
"contentVersion": "1.0.0.0", | ||
"metadata": { | ||
"_generator": { | ||
"name": "bicep", | ||
"version": "0.24.24.22086", | ||
"templateHash": "13351406772210248604" | ||
} | ||
}, | ||
"parameters": { | ||
"keyVaultName": { | ||
"type": "string", | ||
"defaultValue": "vault1" | ||
}, | ||
"objectId": { | ||
"type": "string", | ||
"defaultValue": "[newGuid()]" | ||
} | ||
}, | ||
"variables": { | ||
"newAccessPolicies": [ | ||
{ | ||
"tenantId": "[tenant().tenantId]", | ||
"objectId": "[parameters('objectId')]", | ||
"permissions": { | ||
"keys": [ | ||
"Get", | ||
"List" | ||
], | ||
"secrets": [ | ||
"Get", | ||
"List" | ||
], | ||
"certificates": [] | ||
} | ||
} | ||
] | ||
}, | ||
"resources": [ | ||
{ | ||
"type": "Microsoft.KeyVault/vaults", | ||
"apiVersion": "2023-07-01", | ||
"name": "[format('{0}-2', parameters('keyVaultName'))]", | ||
"properties": {} | ||
}, | ||
{ | ||
"type": "Microsoft.Resources/deployments", | ||
"apiVersion": "2022-09-01", | ||
"name": "[format('addPolicies-{0}', uniqueString('addPolicies', deployment().name))]", | ||
"properties": { | ||
"expressionEvaluationOptions": { | ||
"scope": "inner" | ||
}, | ||
"mode": "Incremental", | ||
"parameters": { | ||
"accessPolicies": { | ||
"value": "[union(reference(resourceId('Microsoft.KeyVault/vaults', parameters('keyVaultName')), '2021-11-01-preview').accessPolicies, variables('newAccessPolicies'))]" | ||
}, | ||
"keyVaultName": { | ||
"value": "[parameters('keyVaultName')]" | ||
} | ||
}, | ||
"template": { | ||
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", | ||
"contentVersion": "1.0.0.0", | ||
"metadata": { | ||
"_generator": { | ||
"name": "bicep", | ||
"version": "0.24.24.22086", | ||
"templateHash": "11282630508739439881" | ||
} | ||
}, | ||
"parameters": { | ||
"keyVaultName": { | ||
"type": "string" | ||
}, | ||
"accessPolicies": { | ||
"type": "array" | ||
} | ||
}, | ||
"resources": [ | ||
{ | ||
"type": "Microsoft.KeyVault/vaults/accessPolicies", | ||
"apiVersion": "2023-07-01", | ||
"name": "[format('{0}/add', parameters('keyVaultName'))]", | ||
"properties": { | ||
"accessPolicies": "[parameters('accessPolicies')]" | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} | ||
] | ||
} |