Azure / arm-template-whatif

A repository to track issues related to what-if noise suppression
MIT License
90 stars 14 forks source link

References in VNet peerings are not resolved to the actually value of the reference #350

Open HorizonNet opened 10 months ago

HorizonNet commented 10 months ago

Describe the noise

Resource type Microsoft.Network/virtualNetworks

apiVersion 2023-06-01

Client Azure CLI

Relevant ARM Template code (we only need the resource object for the above resourceType and apiVersion, but if it's easier you can include the entire template

resource xxx 'Microsoft.Network/virtualNetworks@2023-06-01' = {
  name: 'xxx'
  location: 'germanywestcentral'

  properties: {
    ...

    virtualNetworkPeerings: [
      {
        name: network.name

        properties: {
          peeringState: 'Connected'
          peeringSyncLevel: 'FullyInSync'

          remoteVirtualNetwork: {
            id: network.id
          }

          allowVirtualNetworkAccess: true
          allowForwardedTraffic: false
          allowGatewayTransit: false
          useRemoteGateways: false
          doNotVerifyRemoteGateways: false

          remoteAddressSpace: {
            addressPrefixes: [
              network.properties.addressSpace.addressPrefixes[0]
            ]
          }

          remoteVirtualNetworkAddressSpace: {
            addressPrefixes: [
              network.properties.addressSpace.addressPrefixes[0]
            ]
          }
        }
      }
    ]

    enableDdosProtection: false
  }

  ...
}

@description('Remote VNet to peer with')
resource network 'Microsoft.Network/virtualNetworks@2023-06-01' existing = {
  name: 'network'
  scope: resourceGroup('aaa')
}

Expected response (i.e. "I expected no noise since the template has not been modified since the resources were deployed)

I expected no noise and the deployment instead picking up the appropriate address prefixes from the referenced resource instead of showing a change in the address prefix for the remote VNet.

Current (noisy) response (either include a screenshot of the what-if output, or copy/paste the text)

  ~ Microsoft.Network/virtualNetworks/xxx [2023-06-01]
    ~ properties.virtualNetworkPeerings: [
      ~ 0:

        - properties.peerCompleteVnets: true
        ~ properties.remoteAddressSpace.addressPrefixes: [
          - 0: "xx.xx.x.x/16"
          + 0: "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, 'aaa'), 'Microsoft.Network/virtualNetworks', 'network'), '2023-06-01').addressSpace.addressPrefixes[0]]"
          ]
        ~ properties.remoteVirtualNetworkAddressSpace.addressPrefixes: [
          - 0: "xx.xx.x.x/16"
          + 0: "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, 'aaa'), 'Microsoft.Network/virtualNetworks', 'network'), '2023-06-01').addressSpace.addressPrefixes[0]]"
          ]

      ]

Additional context Add any other context about the problem here.