Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Modules] Align CMK implementation for Cognitive Services & cleaned up several allowed values #2402

Merged
merged 13 commits into from
Dec 9, 2022
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ resource keyVault 'Microsoft.KeyVault/vaults@2022-07-01' = {
}

resource keyPermissions 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
name: guid('msi-${keyVault::key.id}-${location}-${managedIdentity.id}-Key-Reader-RoleAssignment')
name: guid('msi-${keyVault::key.id}-${location}-${managedIdentity.id}-Key-Key-Vault-Crypto-User-RoleAssignment')
scope: keyVault::key
properties: {
principalId: managedIdentity.properties.principalId
Expand All @@ -77,15 +77,9 @@ output subnetResourceId string = virtualNetwork.properties.subnets[0].id
@description('The resource ID of the created Key Vault.')
output keyVaultResourceId string = keyVault.id

@description('The vault URI of the created Key Vault.')
output keyVaultUri string = keyVault.properties.vaultUri

@description('The name of the created Key Vault encryption key.')
output keyVaultKeyName string = keyVault::key.name

@description('The version of the created Key Vault encryption key.')
output keyVaultKeyVersion string = last(split(keyVault::key.properties.keyUriWithVersion, '/'))

@description('The resource ID of the created Managed Identity.')
output managedIdentityResourceId string = managedIdentity.id

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,9 @@ module testDeployment '../../deploy.bicep' = {
enableDefaultTelemetry: enableDefaultTelemetry
name: '<<namePrefix>>${serviceShort}001'
kind: 'SpeechServices'
encryption: {
keySource: 'Microsoft.KeyVault'
keyVaultProperties: {
identityClientId: resourceGroupResources.outputs.managedIdentityClientId
keyName: resourceGroupResources.outputs.keyVaultKeyName
keyVaultUri: resourceGroupResources.outputs.keyVaultUri
keyversion: resourceGroupResources.outputs.keyVaultKeyVersion
}
}
cMKKeyVaultResourceId: resourceGroupResources.outputs.keyVaultResourceId
cMKKeyName: resourceGroupResources.outputs.keyVaultKeyName
cMKUserAssignedIdentityResourceId: resourceGroupResources.outputs.managedIdentityResourceId
publicNetworkAccess: 'Enabled'
sku: 'S0'
userAssignedIdentities: {
Expand Down
44 changes: 40 additions & 4 deletions modules/Microsoft.CognitiveServices/accounts/deploy.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,20 @@ param apiProperties object = {}
@description('Optional. Allow only Azure AD authentication. Should be enabled for security reasons.')
param disableLocalAuth bool = true

@description('Optional. Properties to configure encryption.')
param encryption object = {}
@description('Optional. The resource ID of a key vault to reference a customer managed key for encryption from.')
param cMKKeyVaultResourceId string = ''

@description('Optional. The name of the customer managed key to use for encryption. Cannot be deployed together with the parameter \'systemAssignedIdentity\' enabled.')
param cMKKeyName string = ''

@description('Conditional. User assigned identity to use when fetching the customer managed key. Required if \'cMKKeyName\' is not empty.')
param cMKUserAssignedIdentityResourceId string = ''

@description('Optional. The version of the customer managed key to reference for encryption. If not provided, latest is used.')
param cMKKeyVersion string = ''

@description('Optional. The flag to enable dynamic throttling.')
param dynamicThrottlingEnabled bool = false

@description('Optional. Resource migration token.')
param migrationToken string = ''
Expand Down Expand Up @@ -195,7 +207,22 @@ resource defaultTelemetry 'Microsoft.Resources/deployments@2021-04-01' = if (ena
}
}

resource cognitiveServices 'Microsoft.CognitiveServices/accounts@2021-10-01' = {
resource cmkKeyVault 'Microsoft.KeyVault/vaults@2021-06-01-preview' existing = if (!empty(cMKKeyVaultResourceId)) {
AlexanderSehr marked this conversation as resolved.
Show resolved Hide resolved
name: last(split(cMKKeyVaultResourceId, '/'))
scope: resourceGroup(split(cMKKeyVaultResourceId, '/')[2], split(cMKKeyVaultResourceId, '/')[4])
}

resource cMKKeyVaultKey 'Microsoft.KeyVault/vaults/keys@2021-10-01' existing = if (!empty(cMKKeyVaultResourceId) && !empty(cMKKeyName)) {
name: '${last(split(cMKKeyVaultResourceId, '/'))}/${cMKKeyName}'
scope: resourceGroup(split(cMKKeyVaultResourceId, '/')[2], split(cMKKeyVaultResourceId, '/')[4])
}

resource cMkUserAssignedIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2018-11-30' existing = if (!empty(cMKUserAssignedIdentityResourceId)) {
AlexanderSehr marked this conversation as resolved.
Show resolved Hide resolved
name: last(split(cMKUserAssignedIdentityResourceId, '/'))
scope: resourceGroup(split(cMKUserAssignedIdentityResourceId, '/')[2], split(cMKUserAssignedIdentityResourceId, '/')[4])
}

resource cognitiveServices 'Microsoft.CognitiveServices/accounts@2022-10-01' = {
name: name
kind: kind
identity: identity
Expand All @@ -215,11 +242,20 @@ resource cognitiveServices 'Microsoft.CognitiveServices/accounts@2021-10-01' = {
allowedFqdnList: allowedFqdnList
apiProperties: apiProperties
disableLocalAuth: disableLocalAuth
encryption: !empty(encryption) ? encryption : null
encryption: !empty(cMKKeyName) ? {
eriqua marked this conversation as resolved.
Show resolved Hide resolved
keySource: 'Microsoft.KeyVault'
keyVaultProperties: {
identityClientId: cMkUserAssignedIdentity.properties.clientId
keyVaultUri: cmkKeyVault.properties.vaultUri
keyName: cMKKeyName
keyVersion: !empty(cMKKeyVersion) ? cMKKeyVersion : last(split(cMKKeyVaultKey.properties.keyUriWithVersion, '/'))
}
} : null
migrationToken: !empty(migrationToken) ? migrationToken : null
restore: restore
restrictOutboundNetworkAccess: restrictOutboundNetworkAccess
userOwnedStorage: !empty(userOwnedStorage) ? userOwnedStorage : null
dynamicThrottlingEnabled: dynamicThrottlingEnabled
}
}

Expand Down
40 changes: 18 additions & 22 deletions modules/Microsoft.CognitiveServices/accounts/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ This module deploys different kinds of cognitive services resources
| :-- | :-- |
| `Microsoft.Authorization/locks` | [2020-05-01](https://docs.microsoft.com/en-us/azure/templates/Microsoft.Authorization/2020-05-01/locks) |
| `Microsoft.Authorization/roleAssignments` | [2022-04-01](https://docs.microsoft.com/en-us/azure/templates/Microsoft.Authorization/2022-04-01/roleAssignments) |
| `Microsoft.CognitiveServices/accounts` | [2021-10-01](https://docs.microsoft.com/en-us/azure/templates/Microsoft.CognitiveServices/2021-10-01/accounts) |
| `Microsoft.CognitiveServices/accounts` | [2022-10-01](https://docs.microsoft.com/en-us/azure/templates/Microsoft.CognitiveServices/2022-10-01/accounts) |
| `Microsoft.Insights/diagnosticSettings` | [2021-05-01-preview](https://docs.microsoft.com/en-us/azure/templates/Microsoft.Insights/2021-05-01-preview/diagnosticSettings) |
| `Microsoft.Network/privateEndpoints` | [2022-05-01](https://docs.microsoft.com/en-us/azure/templates/Microsoft.Network/2022-05-01/privateEndpoints) |
| `Microsoft.Network/privateEndpoints/privateDnsZoneGroups` | [2022-05-01](https://docs.microsoft.com/en-us/azure/templates/Microsoft.Network/2022-05-01/privateEndpoints/privateDnsZoneGroups) |
Expand All @@ -35,6 +35,7 @@ This module deploys different kinds of cognitive services resources

| Parameter Name | Type | Default Value | Description |
| :-- | :-- | :-- | :-- |
| `cMKUserAssignedIdentityResourceId` | string | `''` | User assigned identity to use when fetching the customer managed key. Required if 'cMKKeyName' is not empty. |
| `customSubDomainName` | string | `''` | Subdomain name used for token-based authentication. Required if 'networkAcls' or 'privateEndpoints' are set. |
| `userAssignedIdentities` | object | `{object}` | The ID(s) to assign to the resource. Required if a user assigned identity is used for encryption. |

Expand All @@ -44,6 +45,9 @@ This module deploys different kinds of cognitive services resources
| :-- | :-- | :-- | :-- | :-- |
| `allowedFqdnList` | array | `[]` | | List of allowed FQDN. |
| `apiProperties` | object | `{object}` | | The API properties for special APIs. |
| `cMKKeyName` | string | `''` | | The name of the customer managed key to use for encryption. Cannot be deployed together with the parameter 'systemAssignedIdentity' enabled. |
| `cMKKeyVaultResourceId` | string | `''` | | The resource ID of a key vault to reference a customer managed key for encryption from. |
| `cMKKeyVersion` | string | `''` | | The version of the customer managed key to reference for encryption. If not provided, latest is used. |
| `diagnosticEventHubAuthorizationRuleId` | string | `''` | | Resource ID of the diagnostic event hub authorization rule for the Event Hubs namespace in which the event hub should be created or streamed to. |
| `diagnosticEventHubName` | string | `''` | | Name of the diagnostic event hub within the namespace to which logs are streamed. Without this, an event hub is created for each log category. |
| `diagnosticLogCategoriesToEnable` | array | `[Audit, RequestResponse]` | `[Audit, RequestResponse]` | The name of logs that will be streamed. |
Expand All @@ -53,8 +57,8 @@ This module deploys different kinds of cognitive services resources
| `diagnosticStorageAccountId` | string | `''` | | Resource ID of the diagnostic storage account. |
| `diagnosticWorkspaceId` | string | `''` | | Resource ID of the diagnostic log analytics workspace. |
| `disableLocalAuth` | bool | `True` | | Allow only Azure AD authentication. Should be enabled for security reasons. |
| `dynamicThrottlingEnabled` | bool | `False` | | The flag to enable dynamic throttling. |
| `enableDefaultTelemetry` | bool | `True` | | Enable telemetry via a Globally Unique Identifier (GUID). |
| `encryption` | object | `{object}` | | Properties to configure encryption. |
| `location` | string | `[resourceGroup().location]` | | Location for all Resources. |
| `lock` | string | `''` | `['', CanNotDelete, ReadOnly]` | Specify the type of lock. |
| `migrationToken` | string | `''` | | Resource migration token. |
Expand Down Expand Up @@ -606,16 +610,10 @@ module accounts './Microsoft.CognitiveServices/accounts/deploy.bicep' = {
kind: 'SpeechServices'
name: '<<namePrefix>>csaencr001'
// Non-required parameters
cMKKeyName: '<cMKKeyName>'
cMKKeyVaultResourceId: '<cMKKeyVaultResourceId>'
cMKUserAssignedIdentityResourceId: '<cMKUserAssignedIdentityResourceId>'
enableDefaultTelemetry: '<enableDefaultTelemetry>'
encryption: {
keySource: 'Microsoft.KeyVault'
keyVaultProperties: {
identityClientId: '<identityClientId>'
keyName: '<keyName>'
keyVaultUri: '<keyVaultUri>'
keyversion: '<keyversion>'
}
}
publicNetworkAccess: 'Enabled'
sku: 'S0'
userAssignedIdentities: {
Expand Down Expand Up @@ -645,20 +643,18 @@ module accounts './Microsoft.CognitiveServices/accounts/deploy.bicep' = {
"value": "<<namePrefix>>csaencr001"
},
// Non-required parameters
"cMKKeyName": {
"value": "<cMKKeyName>"
},
"cMKKeyVaultResourceId": {
"value": "<cMKKeyVaultResourceId>"
},
"cMKUserAssignedIdentityResourceId": {
"value": "<cMKUserAssignedIdentityResourceId>"
},
"enableDefaultTelemetry": {
"value": "<enableDefaultTelemetry>"
},
"encryption": {
"value": {
"keySource": "Microsoft.KeyVault",
"keyVaultProperties": {
"identityClientId": "<identityClientId>",
"keyName": "<keyName>",
"keyVaultUri": "<keyVaultUri>",
"keyversion": "<keyversion>"
}
}
},
"publicNetworkAccess": {
"value": "Enabled"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,38 +17,18 @@ param count int = 1
param sourceResourceId string = ''

@description('Optional. Whether to enable auto-scaler.')
@allowed([
true
false
])
param enableAutoScaling bool = false

@description('Optional. This is only supported on certain VM sizes and in certain Azure regions. For more information, see: /azure/aks/enable-host-encryption. For security reasons, this setting should be enabled.')
@allowed([
true
false
])
param enableEncryptionAtHost bool = false

@description('Optional. See Add a FIPS-enabled node pool (https://docs.microsoft.com/en-us/azure/aks/use-multiple-node-pools#add-a-fips-enabled-node-pool-preview) for more details.')
@allowed([
true
false
])
param enableFIPS bool = false

@description('Optional. Some scenarios may require nodes in a node pool to receive their own dedicated public IP addresses. A common scenario is for gaming workloads, where a console needs to make a direct connection to a cloud virtual machine to minimize hops. For more information see assigning a public IP per node (https://docs.microsoft.com/en-us/azure/aks/use-multiple-node-pools#assign-a-public-ip-per-node-for-your-node-pools). The default is false.')
@allowed([
true
false
])
@description('Optional. Some scenarios may require nodes in a node pool to receive their own dedicated public IP addresses. A common scenario is for gaming workloads, where a console needs to make a direct connection to a cloud virtual machine to minimize hops. For more information see assigning a public IP per node (https://docs.microsoft.com/en-us/azure/aks/use-multiple-node-pools#assign-a-public-ip-per-node-for-your-node-pools).')
param enableNodePublicIP bool = false

@description('Optional. Whether to enable UltraSSD.')
@allowed([
true
false
])
param enableUltraSSD bool = false

@description('Optional. GPUInstanceProfile to be used to specify GPU MIG instance profile for supported GPU VM SKU.')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ This module deploys an Agent Pool for a Container Service Managed Cluster
| :-- | :-- | :-- | :-- | :-- |
| `availabilityZones` | array | `[]` | | The list of Availability zones to use for nodes. This can only be specified if the AgentPoolType property is "VirtualMachineScaleSets". |
| `count` | int | `1` | | Desired Number of agents (VMs) specified to host docker containers. Allowed values must be in the range of 0 to 1000 (inclusive) for user pools and in the range of 1 to 1000 (inclusive) for system pools. The default value is 1. |
| `enableAutoScaling` | bool | `False` | `[False, True]` | Whether to enable auto-scaler. |
| `enableAutoScaling` | bool | `False` | | Whether to enable auto-scaler. |
| `enableDefaultTelemetry` | bool | `True` | | Enable telemetry via a Globally Unique Identifier (GUID). |
| `enableEncryptionAtHost` | bool | `False` | `[False, True]` | This is only supported on certain VM sizes and in certain Azure regions. For more information, see: /azure/aks/enable-host-encryption. For security reasons, this setting should be enabled. |
| `enableFIPS` | bool | `False` | `[False, True]` | See Add a FIPS-enabled node pool (https://docs.microsoft.com/en-us/azure/aks/use-multiple-node-pools#add-a-fips-enabled-node-pool-preview) for more details. |
| `enableNodePublicIP` | bool | `False` | `[False, True]` | Some scenarios may require nodes in a node pool to receive their own dedicated public IP addresses. A common scenario is for gaming workloads, where a console needs to make a direct connection to a cloud virtual machine to minimize hops. For more information see assigning a public IP per node (https://docs.microsoft.com/en-us/azure/aks/use-multiple-node-pools#assign-a-public-ip-per-node-for-your-node-pools). The default is false. |
| `enableUltraSSD` | bool | `False` | `[False, True]` | Whether to enable UltraSSD. |
| `enableEncryptionAtHost` | bool | `False` | | This is only supported on certain VM sizes and in certain Azure regions. For more information, see: /azure/aks/enable-host-encryption. For security reasons, this setting should be enabled. |
| `enableFIPS` | bool | `False` | | See Add a FIPS-enabled node pool (https://docs.microsoft.com/en-us/azure/aks/use-multiple-node-pools#add-a-fips-enabled-node-pool-preview) for more details. |
| `enableNodePublicIP` | bool | `False` | | Some scenarios may require nodes in a node pool to receive their own dedicated public IP addresses. A common scenario is for gaming workloads, where a console needs to make a direct connection to a cloud virtual machine to minimize hops. For more information see assigning a public IP per node (https://docs.microsoft.com/en-us/azure/aks/use-multiple-node-pools#assign-a-public-ip-per-node-for-your-node-pools). |
| `enableUltraSSD` | bool | `False` | | Whether to enable UltraSSD. |
| `gpuInstanceProfile` | string | `''` | `['', MIG1g, MIG2g, MIG3g, MIG4g, MIG7g]` | GPUInstanceProfile to be used to specify GPU MIG instance profile for supported GPU VM SKU. |
| `kubeletDiskType` | string | `''` | | Determines the placement of emptyDir volumes, container runtime data root, and Kubelet ephemeral storage. |
| `maxCount` | int | `-1` | | The maximum number of nodes for auto-scaling. |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ param publicNetworkAccess string = 'Enabled'
@description('Optional. Default Action for Network Rule Set. Default is "Allow". It will not be set if publicNetworkAccess is "Disabled". Otherwise, it will be set to "Deny" if ipRules or virtualNetworkRules are being used.')
param defaultAction string = 'Allow'

@allowed([
true
false
])
@description('Optional. Value that indicates whether Trusted Service Access is enabled or not. Default is "true". It will not be set if publicNetworkAccess is "Disabled".')
param trustedServiceAccessEnabled bool = true

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ This module deploys EventHub Namespaces NetworkRuleSets.
| `enableDefaultTelemetry` | bool | `True` | | Enable telemetry via a Globally Unique Identifier (GUID). |
| `ipRules` | array | `[]` | | List of IpRules. It will not be set if publicNetworkAccess is "Disabled". Otherwise, when used, defaultAction will be set to "Deny". |
| `publicNetworkAccess` | string | `'Enabled'` | `[Disabled, Enabled]` | This determines if traffic is allowed over public network. Default is "Enabled". If set to "Disabled", traffic to this namespace will be restricted over Private Endpoints only and network rules will not be applied. |
| `trustedServiceAccessEnabled` | bool | `True` | `[False, True]` | Value that indicates whether Trusted Service Access is enabled or not. Default is "true". It will not be set if publicNetworkAccess is "Disabled". |
| `trustedServiceAccessEnabled` | bool | `True` | | Value that indicates whether Trusted Service Access is enabled or not. Default is "true". It will not be set if publicNetworkAccess is "Disabled". |
| `virtualNetworkRules` | array | `[]` | | List virtual network rules. It will not be set if publicNetworkAccess is "Disabled". Otherwise, when used, defaultAction will be set to "Deny". |


Expand Down
12 changes: 0 additions & 12 deletions modules/Microsoft.KeyVault/vaults/deploy.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,12 @@ param secrets object = {}
param keys array = []

@description('Optional. Specifies if the vault is enabled for deployment by script or compute.')
@allowed([
true
false
])
param enableVaultForDeployment bool = true

@description('Optional. Specifies if the vault is enabled for a template deployment.')
@allowed([
true
false
])
param enableVaultForTemplateDeployment bool = true

@description('Optional. Specifies if the azure platform has access to the vault for enabling disk encryption scenarios.')
@allowed([
true
false
])
param enableVaultForDiskEncryption bool = true

@description('Optional. Switch to enable/disable Key Vault\'s soft delete feature.')
Expand Down
Loading