Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Definition of 'Microsoft.Network/loadBalancers@2021-02-01' results in cycle error #4239

Closed
asilverman opened this issue Aug 31, 2021 · 0 comments

Comments

@asilverman
Copy link
Contributor

asilverman commented Aug 31, 2021

Bicep version
Bicep CLI version 0.4.613 (d826ce8)

Describe the bug
It should be possible to reduce the need to specify the sections below without the need for a variable var backendAddressPoolName = 'kubernetes-lb-pool'

The resulting Bicep template (below) loses its simplicity and starts to suffer from christmas-tree like code. Why should the author need to specify both:

backendAddressPools: [
      {
        name: backendAddressPoolName
        properties: {}
      }
    ]

and

resource backEndAddrPool 'backendAddressPools' = {
    name: backendAddressPoolName
    properties: {}
  }

in

@description('The address to allow NSG access to')
param endpointAddress string

var vnetAddressPrefix = '10.240.0.0/24'
var location = resourceGroup().location

resource nsg 'Microsoft.Network/networkSecurityGroups@2021-02-01' = {
  name: 'kubernetes-nsg'
  location: location
  properties: {
    securityRules: [
      {
        name: 'kubernetes-allow-ssh'
        properties: {
          access: 'Allow'
          destinationAddressPrefix: '*'
          destinationPortRange: '22'
          direction: 'Inbound'
          protocol: 'Tcp'
          sourceAddressPrefix: endpointAddress
          sourcePortRange: '*'
          priority: 1001
        }
      }
      {
        name: 'kubernetes-allow-api-server'
        properties: {
          access: 'Allow'
          destinationAddressPrefix: '*'
          destinationPortRange: '6443'
          direction: 'Inbound'
          protocol: 'Tcp'
          sourceAddressPrefix: endpointAddress
          sourcePortRange: '*'
          priority: 1002
        }
      }
    ]
  }
}

resource pip 'Microsoft.Network/publicIPAddresses@2021-02-01' = {
  name: 'kubernetes-pip'
  location: location
  sku: {
    name: 'Standard'
    tier: 'Regional'
  }
  properties: {
    publicIPAllocationMethod: 'Static'
    publicIPAddressVersion: 'IPv4'
  }
}

var backendAddressPoolName = 'kubernetes-lb-pool'
resource lb 'Microsoft.Network/loadBalancers@2021-02-01' = {
  name: 'kubernetes-lb'
  location: location
  sku: {
    name: 'Standard'
    tier: 'Regional'
  }
  properties: {
    frontendIPConfigurations: [
      {
        name: 'LoadBalancerFrontEnd'
        properties: {
          privateIPAllocationMethod: 'Dynamic'
          publicIPAddress: {
            id: pip.id
          }
        }
      }
    ]
    backendAddressPools: [
      {
        name: backendAddressPoolName // using backEndAddrPool.name results in a cyclical dependency error, however current definition deploys successfully to Azure
        properties: {}
      }
    ]
  }
  resource backEndAddrPool 'backendAddressPools' = {
    name: backendAddressPoolName
    properties: {}
  }
}

resource vnet 'Microsoft.Network/virtualNetworks@2021-02-01' = {
  name: 'kubernetes-vnet'
  location: location
  properties: {
    addressSpace: {
      addressPrefixes: [
        vnetAddressPrefix
      ]
    }
    subnets: [
      {
        name: 'kubernetes-subnet'
        properties: {
          addressPrefix: vnetAddressPrefix
          networkSecurityGroup: {
            id: nsg.id
          }
        }
      }
    ]
  }
}

To Reproduce
Steps to reproduce the behavior:
N\A
Additional context
N\A

@ghost ghost added the Needs: Triage 🔍 label Aug 31, 2021
@Azure Azure locked and limited conversation to collaborators Sep 1, 2021

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Projects
None yet
Development

No branches or pull requests

2 participants