CompositionalIT / farmer

Repeatable Azure deployments with ARM templates - made easy!
https://compositionalit.github.io/farmer
MIT License
514 stars 156 forks source link

Need more property settings in Virtual Network #1073

Open Jiancao164 opened 8 months ago

Jiancao164 commented 8 months ago

Looking for the following settings for properties of Virtual Network:

VirtualNetwork Properties

VirtualNetwork/VirtualNetworkPeerings

ninjarobot commented 8 months ago

@Jiancao164 what's the use case for PeeringState and PeeringSyncLevel in an ARM deployment? Are those ever set or are you using the value in output or something like that?

ninjarobot commented 8 months ago

@Jiancao164 I have #1078 in progress for this, but I am not really sure how to confirm if some of these settings work. Here's a template generated by this test.

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "outputs": {},
  "parameters": {},
  "resources": [
    {
      "apiVersion": "2023-04-01",
      "dependsOn": [],
      "location": "westeurope",
      "name": "vnet1",
      "properties": {
        "addressSpace": {
          "addressPrefixes": [
            "10.100.50.0/24",
            "10.100.255.0/24"
          ]
        },
        "subnets": [
          {
            "name": "net1-1",
            "properties": {
              "addressPrefix": "10.100.50.0/28",
              "delegations": []
            }
          },
          {
            "name": "GatewaySubnet",
            "properties": {
              "addressPrefix": "10.100.255.0/24",
              "delegations": []
            }
          }
        ]
      },
      "tags": {},
      "type": "Microsoft.Network/virtualNetworks"
    },
    {
      "apiVersion": "2018-11-01",
      "location": "westeurope",
      "name": "vnet1-gw-ip",
      "properties": {
        "publicIPAllocationMethod": "Dynamic"
      },
      "sku": {
        "name": "Basic"
      },
      "tags": {},
      "type": "Microsoft.Network/publicIPAddresses"
    },
    {
      "apiVersion": "2020-05-01",
      "dependsOn": [
        "[resourceId('Microsoft.Network/virtualNetworks', 'vnet1')]",
        "[resourceId('Microsoft.Network/publicIPAddresses', 'vnet1-gw-ip')]"
      ],
      "location": "westeurope",
      "name": "vnet1-gw",
      "properties": {
        "activeActive": false,
        "enableBgp": true,
        "gatewayType": "Vpn",
        "ipConfigurations": [
          {
            "name": "ipconfig1",
            "properties": {
              "privateIpAllocationMethod": "Dynamic",
              "publicIPAddress": {
                "id": "[resourceId('Microsoft.Network/publicIPAddresses', 'vnet1-gw-ip')]"
              },
              "subnet": {
                "id": "[resourceId('Microsoft.Network/virtualNetworks/subnets', 'vnet1', 'GatewaySubnet')]"
              }
            }
          }
        ],
        "sku": {
          "name": "VpnGw1",
          "tier": "VpnGw1"
        },
        "vpnType": "RouteBased"
      },
      "tags": {},
      "type": "Microsoft.Network/virtualNetworkGateways"
    },
    {
      "apiVersion": "2023-04-01",
      "dependsOn": [],
      "location": "westeurope",
      "name": "vnet2",
      "properties": {
        "addressSpace": {
          "addressPrefixes": [
            "172.16.120.0/24"
          ]
        },
        "subnets": [
          {
            "name": "net2-1",
            "properties": {
              "addressPrefix": "172.16.120.0/28",
              "delegations": []
            }
          }
        ]
      },
      "tags": {},
      "type": "Microsoft.Network/virtualNetworks"
    },
    {
      "apiVersion": "2023-04-01",
      "dependsOn": [
        "[resourceId('Microsoft.Network/virtualNetworks', 'vnet2')]",
        "[resourceId('Microsoft.Network/virtualNetworks', 'vnet1')]",
        "[resourceId('Microsoft.Network/virtualNetworkGateways', 'vnet1-gw')]"
      ],
      "location": "westeurope",
      "name": "vnet2/peering-vnet1",
      "properties": {
        "allowForwardedTraffic": false,
        "allowGatewayTransit": true,
        "allowVirtualNetworkAccess": true,
        "peeringState": "Initiated",
        "peeringSyncLevel": "RemoteNotInSync",
        "remoteAddressSpace": {
          "addressPrefixes": [
            "10.100.200.0/24"
          ]
        },
        "remoteVirtualNetwork": {
          "id": "[resourceId('Microsoft.Network/virtualNetworks', 'vnet1')]"
        },
        "remoteVirtualNetworkAddressSpace": {
          "addressPrefixes": [
            "10.100.200.0/24"
          ]
        },
        "useRemoteGateways": true
      },
      "type": "Microsoft.Network/virtualNetworks/virtualNetworkPeerings"
    }
  ]
}
Jiancao164 commented 8 months ago

@Jiancao164 what's the use case for PeeringState and PeeringSyncLevel in an ARM deployment? Are those ever set or are you using the value in output or something like that?

Hi @ninjarobot, I am not sure about it either. We saw the properties in the JSON file from the latest API version so we thought we may need to control the settings of those properties. Now, we found they may come from the default value and not affect anything. I think we can postpone this issue. If later we find we need to set them, we can discuss them later. Thank you for looking into this.

ninjarobot commented 8 months ago

Ok, just let me know if there's a use case for them. The code is pretty much done for setting those, but I don't really see any effect from them so I'm not sure how to test. If you get more info, just add it to the issue and mention me to take a look.

Thanks.