forked from Azure/bicep-registry-modules
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.test.bicep
76 lines (64 loc) · 2.72 KB
/
main.test.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
targetScope = 'subscription'
metadata name = 'Using Customer-Managed-Keys with System-Assigned identity'
metadata description = 'This instance deploys the module using Customer-Managed-Keys using a System-Assigned Identity. This required the service to be deployed twice, once as a pre-requisite to create the System-Assigned Identity, and once to use it for accessing the Customer-Managed-Key secret.'
// ========== //
// Parameters //
// ========== //
@description('Optional. The name of the resource group to deploy for testing purposes.')
@maxLength(90)
param resourceGroupName string = 'dep-${namePrefix}-cognitiveservices.accounts-${serviceShort}-rg'
@description('Optional. The location to deploy resources to.')
param resourceLocation string = deployment().location
@description('Optional. A short identifier for the kind of deployment. Should be kept short to not run into resource-name length-constraints.')
param serviceShort string = 'csaecrs'
@description('Generated. Used as a basis for unique resource names.')
param baseTime string = utcNow('u')
@description('Optional. A token to inject into the name of each resource. This value can be automatically injected by the CI.')
param namePrefix string = '#_namePrefix_#'
// ============ //
// Dependencies //
// ============ //
// General resources
// =================
resource resourceGroup 'Microsoft.Resources/resourceGroups@2022-09-01' = {
name: resourceGroupName
location: resourceLocation
}
module nestedDependencies 'dependencies.bicep' = {
scope: resourceGroup
name: '${uniqueString(deployment().name, resourceLocation)}-nestedDependencies'
params: {
cognitiveServiceName: '${namePrefix}${serviceShort}001'
// Adding base time to make the name unique as purge protection must be enabled (but may not be longer than 24 characters total)
keyVaultName: 'dep-${namePrefix}-kv-${serviceShort}-${substring(uniqueString(baseTime), 0, 3)}'
location: resourceLocation
}
}
// ============== //
// Test Execution //
// ============== //
@batchSize(1)
module testDeployment '../../../main.bicep' = [
for iteration in ['init', 'idem']: {
scope: resourceGroup
name: '${uniqueString(deployment().name, resourceLocation)}-test-${serviceShort}-${iteration}'
params: {
name: nestedDependencies.outputs.cognitiveServiceName
kind: 'SpeechServices'
location: resourceLocation
customerManagedKey: {
keyName: nestedDependencies.outputs.keyVaultKeyName
keyVaultResourceId: nestedDependencies.outputs.keyVaultResourceId
}
publicNetworkAccess: 'Enabled'
sku: 'S0'
managedIdentities: {
systemAssigned: true
}
restrictOutboundNetworkAccess: false
}
dependsOn: [
nestedDependencies
]
}
]