Public/IaaS/vpngw/New-CmAzIaasVpnGw.json
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", "contentVersion": "1.0.0.0", "parameters": { "location": { "defaultValue": "[resourceGroup().location]", "type": "String", "metadata": { "description": "location" } }, "vpnGwObject": { "type": "SecureObject", "metadata": { "description": "vpn object to with all required parameters" } } }, "resources": [ { "type": "Microsoft.Resources/Deployments", "apiVersion": "2019-10-01", "name": "[concat('CmAz_vpnGw-', copyIndex('vpnGatewayCopy'))]", "copy": { "name": "vpnGatewayCopy", "count": "[length(parameters('vpnGwObject').vpnGw)]" }, "properties": { "mode": "Incremental", "expressionEvaluationOptions": { "scope": "outer" }, "template": { "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", "contentVersion": "1.0.0.0", "parameters": { }, "resources": [ { "condition": "[not(empty(parameters('vpnGwObject').vpnGw[copyIndex('vpnGatewayCopy')].GatewaySubnetPrefix))]", "type": "Microsoft.Network/virtualNetworks/subnets", "apiVersion": "2019-04-01", "name": "[concat(parameters('vpnGwObject').vpnGw[copyIndex('vpnGatewayCopy')].virtualNetworkName, '/', 'GatewaySubnet')]", "location": "[parameters('location')]", "properties": { "addressPrefix": "[parameters('vpnGwObject').vpnGw[copyIndex('vpnGatewayCopy')].GatewaySubnetPrefix]" } }, { "apiVersion": "2019-04-01", "type": "Microsoft.Network/publicIPAddresses", "name": "[parameters('vpnGwObject').vpnGw[copyIndex('vpnGatewayCopy')].GatewayPublicIPName]", "location": "[parameters('location')]", "properties": { "publicIPAllocationMethod": "Dynamic" }, "tags": { "cm-service": "[parameters('vpnGwObject').vpnGw[copyIndex('vpnGatewayCopy')].service.publish.publicIp]" } }, { "apiVersion": "2019-04-01", "type": "Microsoft.Network/virtualNetworkGateways", "name": "[parameters('vpnGwObject').vpnGw[copyIndex('vpnGatewayCopy')].GatewayName]", "location": "[parameters('location')]", "dependsOn": [ "[concat('Microsoft.Network/publicIPAddresses/', parameters('vpnGwObject').vpnGw[copyIndex('vpnGatewayCopy')].GatewayPublicIPName)]" ], "tags": { "cm-service": "[parameters('vpnGwObject').vpnGw[copyIndex('vpnGatewayCopy')].service.publish.virtualNetworkGateway]" }, "properties": { "ipConfigurations": [ { "properties": { "privateIPAllocationMethod": "Dynamic", "subnet": { "id": "[resourceId('Microsoft.Network/virtualNetworks/subnets', parameters('vpnGwObject').vpnGw[copyIndex('vpnGatewayCopy')].virtualNetworkName, 'GatewaySubnet')]" }, "publicIPAddress": { "id": "[resourceId('Microsoft.Network/publicIPAddresses',parameters('vpnGwObject').vpnGw[copyIndex('vpnGatewayCopy')].GatewayPublicIPName)]" } }, "name": "vnetGatewayConfig" } ], "sku": { "name": "[parameters('vpnGwObject').vpnGw[copyIndex('vpnGatewayCopy')].Sku]", "tier": "[parameters('vpnGwObject').vpnGw[copyIndex('vpnGatewayCopy')].Sku]" }, "gatewayType": "Vpn", "vpnType": "RouteBased", "enableBgp": false, "vpnClientConfiguration": { "vpnClientAddressPool": { "addressPrefixes": [ "[if(and(not(empty(parameters('vpnGwObject').vpnGw[copyIndex('vpnGatewayCopy')].P2s.VpnAddressPool)),not(empty(parameters('vpnGwObject').vpnGw[copyIndex('vpnGatewayCopy')].P2s.RootCertificateName)),not(empty(parameters('vpnGwObject').vpnGw[copyIndex('vpnGatewayCopy')].P2s.clientRootCertData))), parameters('vpnGwObject').vpnGw[copyIndex('vpnGatewayCopy')].P2s.VpnAddressPool, json('null'))]" ] }, "vpnClientRootCertificates": [ { "name": "[if(and(not(empty(parameters('vpnGwObject').vpnGw[copyIndex('vpnGatewayCopy')].P2s.VpnAddressPool)),not(empty(parameters('vpnGwObject').vpnGw[copyIndex('vpnGatewayCopy')].P2s.RootCertificateName)),not(empty(parameters('vpnGwObject').vpnGw[copyIndex('vpnGatewayCopy')].P2s.clientRootCertData))), parameters('vpnGwObject').vpnGw[copyIndex('vpnGatewayCopy')].P2s.RootCertificateName, json('null'))]", "properties": { "publicCertData": "[if(and(not(empty(parameters('vpnGwObject').vpnGw[copyIndex('vpnGatewayCopy')].P2s.VpnAddressPool)),not(empty(parameters('vpnGwObject').vpnGw[copyIndex('vpnGatewayCopy')].P2s.RootCertificateName)),not(empty(parameters('vpnGwObject').vpnGw[copyIndex('vpnGatewayCopy')].P2s.clientRootCertData))), parameters('vpnGwObject').vpnGw[copyIndex('vpnGatewayCopy')].P2s.clientRootCertData, json('null'))]" } } ] } } }, { "apiVersion": "2019-04-01", "condition": "[and(not(empty(parameters('vpnGwObject').vpnGw[copyIndex('vpnGatewayCopy')].S2s.cidrBlocks)), not(empty(parameters('vpnGwObject').vpnGw[copyIndex('vpnGatewayCopy')].S2s.clientSitePublicIP)),not(empty(parameters('vpnGwObject').vpnGw[copyIndex('vpnGatewayCopy')].S2s.SharedKey)))]", "type": "Microsoft.Network/localNetworkGateways", "name": "[parameters('vpnGwObject').vpnGw[copyIndex('vpnGatewayCopy')].S2s.localGatewayName]", "location": "[parameters('location')]", "tags": { "cm-service": "[parameters('vpnGwObject').vpnGw[copyIndex('vpnGatewayCopy')].service.publish.localNetworkGateway]" }, "properties": { "localNetworkAddressSpace": { "addressPrefixes": "[parameters('vpnGwObject').vpnGw[copyIndex('vpnGatewayCopy')].S2s.cidrBlocks]" }, "gatewayIpAddress": "[parameters('vpnGwObject').vpnGw[copyIndex('vpnGatewayCopy')].S2s.clientSitePublicIP]" } }, { "apiVersion": "2019-04-01", "condition": "[and(not(empty(parameters('vpnGwObject').vpnGw[copyIndex('vpnGatewayCopy')].S2s.cidrBlocks)),not(empty(parameters('vpnGwObject').vpnGw[copyIndex('vpnGatewayCopy')].S2s.clientSitePublicIP)),not(empty(parameters('vpnGwObject').vpnGw[copyIndex('vpnGatewayCopy')].S2s.SharedKey)))]", "name": "[parameters('vpnGwObject').vpnGw[copyIndex('vpnGatewayCopy')].S2s.localGatewayName]", "type": "Microsoft.Network/connections", "location": "[parameters('location')]", "dependsOn": [ "[resourceId('Microsoft.Network/virtualNetworkGateways', parameters('vpnGwObject').vpnGw[copyIndex('vpnGatewayCopy')].GatewayName)]", "[resourceId('Microsoft.Network/localNetworkGateways', parameters('vpnGwObject').vpnGw[copyIndex('vpnGatewayCopy')].S2s.localGatewayName)]" ], "properties": { "virtualNetworkGateway1": { "id": "[resourceId('Microsoft.Network/virtualNetworkGateways', parameters('vpnGwObject').vpnGw[copyIndex('vpnGatewayCopy')].GatewayName)]" }, "localNetworkGateway2": { "id": "[resourceId('Microsoft.Network/localNetworkGateways', concat('localGateway', parameters('vpnGwObject').vpnGw[copyIndex('vpnGatewayCopy')].GatewayName))]" }, "connectionType": "IPsec", "routingWeight": 10, "sharedKey": "[parameters('vpnGwObject').vpnGw[copyIndex('vpnGatewayCopy')].S2s.SharedKey]" } } ] } } } ], "outputs": { } } |