-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.bicep
98 lines (85 loc) · 3.54 KB
/
main.bicep
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
// Also:
// * KeyVaults secrets CANNOT BE EXPORTED into ARM/Bicep format via the Template Export capability.
// * documentation on key vault secret resource types:
// https://docs.microsoft.com/en-us/azure/templates/microsoft.keyvault/vaults/secrets?tabs=json
// * 201/key-vault-secret=create in pre-decompiled ARM format
// https://github.com/Azure/azure-quickstart-templates/tree/master/quickstarts/microsoft.keyvault/key-vault-secret-create
@description('Specifies the name of the key vault.')
param keyVaultName string
@description('Specifies the Azure location where the key vault should be created.')
param location string = resourceGroup().location
@description('Specifies whether Azure Virtual Machines are permitted to retrieve certificates stored as secrets from the key vault.')
param enabledForDeployment bool = false
@description('Specifies whether Azure Disk Encryption is permitted to retrieve secrets from the vault and unwrap keys.')
param enabledForDiskEncryption bool = false
@description('Specifies whether Azure Resource Manager is permitted to retrieve secrets from the key vault.')
param enabledForTemplateDeployment bool = false
@description('Specifies the Azure Active Directory tenant ID that should be used for authenticating requests to the key vault. Get it by using Get-AzSubscription cmdlet.')
param tenantId string = subscription().tenantId
@description('Specifies the object ID of a user, service principal or security group in the Azure Active Directory tenant for the vault. The object ID must be unique for the list of access policies. Get it by using Get-AzADUser or Get-AzADServicePrincipal cmdlets.')
param objectId string
@description('Specifies the permissions to keys in the vault. Valid values are: all, encrypt, decrypt, wrapKey, unwrapKey, sign, verify, get, list, create, update, import, delete, backup, restore, recover, and purge.')
param keysPermissions array = [
'list'
]
@description('Specifies the permissions to secrets in the vault. Valid values are: all, get, list, set, delete, backup, restore, recover, and purge.')
param secretsPermissions array = [
'list'
]
@description('Specifies whether the key vault is a standard vault or a premium vault.')
@allowed([
'standard'
'premium'
])
param skuName string = 'standard'
@description('Specifies all secrets {"secretName":"","secretValue":""} wrapped in "secrets" member array in a secure object.')
@secure()
param secretsObject object
// secretsObject should be passed in dynamically as a parameter (not checked in to
// source code control). It should be an object in this format:
// {
// secrets: [
// {
// secretName: 'yourSecret'
// secretValue: 'yourValue'
// }
// ]
// }
resource vault 'Microsoft.KeyVault/vaults@2019-09-01' = {
name: keyVaultName
location: location
tags: {
displayName: 'KeyVault'
}
properties: {
enabledForDeployment: enabledForDeployment
enabledForTemplateDeployment: enabledForTemplateDeployment
enabledForDiskEncryption: enabledForDiskEncryption
tenantId: tenantId
accessPolicies: [
{
objectId: objectId
tenantId: tenantId
permissions: {
keys: keysPermissions
secrets: secretsPermissions
}
}
]
sku: {
name: skuName
family: 'A'
}
networkAcls: {
defaultAction: 'Allow'
bypass: 'AzureServices'
}
}
}
resource secrets 'Microsoft.KeyVault/vaults/secrets@2019-09-01' = [for secret in secretsObject.secrets: {
parent: vault
name: secret.secretName
properties: {
value: secret.secretValue
}
}]