Skip to content

Dynamic loop to create a kv-access policy #2728

Discussion options

You must be logged in to vote

It appears that you cannot iterate over the object itself, however you can still iterate of the array of names that you used to create apps.

Then reference the other array app object via the index.

resource kv 'Microsoft.KeyVault/vaults@2019-09-01' = {
  name: 'kv-bicep-dev'
  location: location
  properties: {
    tenantId: tenantId
    sku: {
      name: 'standard'
      family: 'A'
    }
    accessPolicies: [for (app, i) in names : {
          tenantId: tenantId
          objectId: apps[i].identity.principalId
          permissions: {
            secrets: [
              'all'
            ]
          }
    }]
  }
}

or adding more info to the array to make it an object... just for demon…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by matthiasguentert
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants