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

DependsOn detection does not flow through existing resource definitions #1986

Closed
anthony-c-martin opened this issue Mar 23, 2021 · 0 comments · Fixed by #1991
Closed

DependsOn detection does not flow through existing resource definitions #1986

anthony-c-martin opened this issue Mar 23, 2021 · 0 comments · Fixed by #1991
Assignees

Comments

@anthony-c-martin
Copy link
Member

Repro:

var aksServicePrincipalObjectId = 'aksServicePrincipalObjectId'
var aksDefaultPoolSubnetName = 'asdf'
resource virtualNetwork 'Microsoft.Network/virtualNetworks@2020-08-01' = {
  name: 'asdfasdf'
}

resource userAssignedIdentities 'Microsoft.ManagedIdentity/userAssignedIdentities@2018-11-30' = {
  name: 'asdfsdf'
  location: 'West US'
}

resource aksDefaultPoolSubnet 'Microsoft.Network/virtualNetworks/subnets@2020-08-01' existing = {
  parent: virtualNetwork
  name: aksDefaultPoolSubnetName
}

resource roleAssignment 'Microsoft.Authorization/roleAssignments@2020-04-01-preview' = {
  name: guid(aksDefaultPoolSubnet.id, 'Network Contributor')
  scope: aksDefaultPoolSubnet
  properties: {
    principalId: aksServicePrincipalObjectId
    roleDefinitionId: '4d97b98b-1d4f-4787-a291-c67834d212e7'
  }
  dependsOn: [
    userAssignedIdentities
  ]
}
  • roleAssignment contains a reference to aksDefaultPoolSubnet. Although this resource has been marked as existing, it in turn has a dependency on virtualNetwork. This dependency is being ignored when the template is generated, meaning that the roleAssignment resource does not contain a dependsOn statement.

Generated resource statement from the template output:

{
  "type": "Microsoft.Authorization/roleAssignments",
  "apiVersion": "2020-04-01-preview",
  "scope": "[format('Microsoft.Network/virtualNetworks/{0}/subnets/{1}', 'asdfasdf', variables('aksDefaultPoolSubnetName'))]",
  "name": "[guid(resourceId('Microsoft.Network/virtualNetworks/subnets', 'asdfasdf', variables('aksDefaultPoolSubnetName')), 'Network Contributor')]",
  "properties": {
    "principalId": "[variables('aksServicePrincipalObjectId')]",
    "roleDefinitionId": "4d97b98b-1d4f-4787-a291-c67834d212e7"
  },
  "dependsOn": [
    "[resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', 'asdfsdf')]"
  ]
}

Bicep version: v0.3.135-g23fb6c0bc0

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant