bicep icon indicating copy to clipboard operation
bicep copied to clipboard

Issue with keyvault access policy resource

Open bveerendrakumar opened this issue 6 years ago • 7 comments

Bicep version Bicep CLI version 0.2.59 (5b0314c03c)

Describe the bug I was trying to create a module for keyvault policies. The keyvaultaccess resource is not allowing to specify the pattern "keyvaultname/add" in the name parameter of the resource. But this is the only way we can add an access policy through the ARM template. Bicep throws a compilation error. image

Please check the screenshot below.

To Reproduce Steps to reproduce the behavior: image

Additional context If I modify the ARM template it works. See the screenshot here. image

bveerendrakumar avatar Dec 02 '20 10:12 bveerendrakumar

I have done a workaround like this and I am good for now. But please look into the issue.

image

bveerendrakumar avatar Dec 02 '20 10:12 bveerendrakumar

I know this was closed, but it feels like this should be addressed still. While the work around is working it isn't consistent even within Key Vault child resources. I like the idea of having the name suggestions but not enforcing it to something so strict.

image

JimPaine avatar Mar 13 '21 22:03 JimPaine

I know this was closed, but it feels like this should be addressed still. While the work around is working it isn't consistent even within Key Vault child resources. I like the idea of having the name suggestions but not enforcing it to something so strict.

Long-term, we will have the nested resource syntax as well as the parent property syntax to improve deployment of child resources - at which point, this issue and the issues under #657 (similar root case) will be sorted. Below are some previews of both options, and note that neither option requires any string formatting with '/' characters:

Nested resource syntax (#1516):

resource keyvault 'Microsoft.KeyVault/vaults@2020-04-01-preview' = {
  ...

  resource accesspolicy 'accessPolicies' = {
    name: 'add'
    ...
  }
}

Parent property syntax (#1800):

resource keyvault 'Microsoft.KeyVault/vaults@2020-04-01-preview' = {
  ...
}

resource accesspolicy 'Microsoft.KeyVault/vaults/accessPolicies@2020-04-01-preview' = {
  parent: keyvault
  name: 'add'
  ...
}

anthony-c-martin avatar Mar 15 '21 14:03 anthony-c-martin

Awesome, thanks for the update

JimPaine avatar Mar 15 '21 15:03 JimPaine

Parent property syntax (#1800):

resource keyvault 'Microsoft.KeyVault/vaults@2020-04-01-preview' = {
  ...
}

resource accesspolicy 'Microsoft.KeyVault/vaults/accessPolicies@2020-04-01-preview' = {
  parent: keyvault
  name: 'add'
  ...
}

How can we do this in een loop?

I have the following:

resource kv 'Microsoft.KeyVault/vaults@2021-10-01' = {
  ...
}

resource accessPolicies 'Microsoft.KeyVault/vaults/accessPolicies@2021-10-01' = [for accessPolicy in accessPoliciesObject.accessPolicies: {
  name: 'add'
  parent: kv
  properties: {
    accessPolicies: [
      {
        tenantId: tenantId
        objectId: accessPolicy.objectId
        permissions: {
          keys: accessPolicy.keysPermissions
          secrets: accessPolicy.secretsPermissions
          certificates: accessPolicy.certificatesPermissions
        }
      }
    ]
  }
}]

LockTar avatar Mar 11 '22 11:03 LockTar

@LockTar - given this issue is a bit stale, can you ask this question in Bicep Discussions?

cc @brwilkinson as FYI

alex-frankel avatar Mar 11 '22 18:03 alex-frankel

@LockTar - given this issue is a bit stale, can you ask this question in Bicep Discussions?

I created discussion #6203

LockTar avatar Mar 14 '22 10:03 LockTar