Skip to content

[Feature Request]: Align CMK Implementation for Key Vault Key referencing across modules #2838

Closed

Description

Description

Currently, our modules contain a combination of CMK Key object referencing mechanism. Also some of them contain different API versions of the Key Vault / Key being referenced (i.e. 2022-07-01 or 2021-10-01. 2021-06-01-preview)

Examples:

Automation Accounts, Batch, Cognitive Services, Container Instance, Service Bus, Synapse

resource cMKKeyVault 'Microsoft.KeyVault/vaults@2021-10-01' existing = if (!empty(cMKKeyVaultResourceId)) {
  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])
}

Container Registry, DB for PostgreSQL, Machine Learning, Synapse Keys

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])
}

Data Factory, Storage Account

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

Following a recent discussion, we proposed aligning the method across modules to use the inner resource referencing approach as implemented in the following module (PR #2657)

DB for MySQL Flexible

resource cMKKeyVault 'Microsoft.KeyVault/vaults@2022-07-01' existing = if (!empty(cMKKeyVaultResourceId)) {
  name: last(split(cMKKeyVaultResourceId, '/'))!
  scope: resourceGroup(split(cMKKeyVaultResourceId, '/')[2], split(cMKKeyVaultResourceId, '/')[4])

  resource cMKKey 'keys@2022-07-01' existing = if (!empty(cMKKeyName)) {
    name: cMKKeyName
  }
}

We should revisit our modules that use CMK and see where we can have a consistent approach across all our modules for using CMK. May also require us to update our documentation for guidance.

Activity

  1. eriqua commented on Feb 24, 2023

    @eriqua
    Contributor

    Suggestion

    resource cMKKeyVault 'Microsoft.KeyVault/vaults@2022-07-01' existing = if (!empty(cMKKeyVaultResourceId) && (!empty(cMKKeyName)) ) {
      name: last(split(cMKKeyVaultResourceId, '/'))!
      scope: resourceGroup(split(cMKKeyVaultResourceId, '/')[2], split(cMKKeyVaultResourceId, '/')[4])
    
      resource cMKKey 'keys@2022-07-01' existing =  {
        name: cMKKeyName
      }
    }
    
  2. ahmadabdalla commented on Mar 4, 2023

    @ahmadabdalla
    ContributorAuthor

    Alexander Sehr (@AlexanderSehr) Erika Gressi (@eriqua) sounds like we need to create a vote :D

  3. eriqua commented on Mar 9, 2023

    @eriqua
    Contributor

    Team decides to go on with the suggested implementation and address comments in the PR itself

  4. moved this from Needs triage to To do in Backlogon Mar 9, 2023
  5. ahmadabdalla commented on Apr 10, 2023

    @ahmadabdalla
    ContributorAuthor

    Erika Gressi (@eriqua) are you referring to your suggestion? or the one we did for #2657

  6. AlexanderSehr commented on Jun 15, 2024

    @AlexanderSehr
    Contributor
  7. moved this from To do to Done in Backlogon Jun 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    [cat] modulesenhancement

    Type

    No type

    Projects

    • Status
      Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions