Skip to content

Commit

Permalink
Updated cmk for container instance
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderSehr committed Oct 19, 2023
1 parent 89135eb commit 1fea92e
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions modules/container-instance/container-group/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,13 @@ resource defaultTelemetry 'Microsoft.Resources/deployments@2021-04-01' = if (ena
}
}

resource cmkKeyVault 'Microsoft.KeyVault/vaults@2021-06-01-preview' existing = if (!empty(cMKKeyVaultResourceId)) {
name: last(split(cMKKeyVaultResourceId, '/'))!
scope: resourceGroup(split(cMKKeyVaultResourceId, '/')[2], split(cMKKeyVaultResourceId, '/')[4])
}
resource cMKKeyVault 'Microsoft.KeyVault/vaults@2021-10-01' existing = if (!empty(cMKKeyVaultResourceId)) {
name: last(split((!empty(cMKKeyVaultResourceId) ? cMKKeyVaultResourceId : 'dummyVault'), '/'))!
scope: resourceGroup(split((!empty(cMKKeyVaultResourceId) ? cMKKeyVaultResourceId : '//'), '/')[2], split((!empty(cMKKeyVaultResourceId) ? 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 cMKKey 'keys@2023-02-01' existing = if (!empty(cMKKeyName)) {
name: !empty(cMKKeyName) ? cMKKeyName : 'dummyKey'
}
}

resource containergroup 'Microsoft.ContainerInstance/containerGroups@2022-09-01' = {
Expand All @@ -136,8 +135,8 @@ resource containergroup 'Microsoft.ContainerInstance/containerGroups@2022-09-01'
encryptionProperties: !empty(cMKKeyName) ? {
identity: cMKUserAssignedIdentityResourceId
keyName: cMKKeyName
keyVersion: !empty(cMKKeyVersion) ? cMKKeyVersion : last(split(cMKKeyVaultKey.properties.keyUriWithVersion, '/'))
vaultBaseUrl: cmkKeyVault.properties.vaultUri
keyVersion: !empty(cMKKeyVersion) ? cMKKeyVersion : last(split(cMKKeyVault::cMKKey.properties.keyUriWithVersion, '/'))
vaultBaseUrl: cMKKeyVault.properties.vaultUri
} : null
imageRegistryCredentials: imageRegistryCredentials
initContainers: initContainers
Expand Down

0 comments on commit 1fea92e

Please sign in to comment.