import * as pulumi from "@pulumi/pulumi"; /** * Manages a virtual network peering which allows resources to access other * resources in the linked virtual network. * * ## Example Usage * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as azure from "@pulumi/azure"; * * const example = new azure.core.ResourceGroup("example", { * name: "peeredvnets-rg", * location: "West Europe", * }); * const example_1 = new azure.network.VirtualNetwork("example-1", { * name: "peternetwork1", * resourceGroupName: example.name, * addressSpaces: ["10.0.1.0/24"], * location: example.location, * }); * const example_2 = new azure.network.VirtualNetwork("example-2", { * name: "peternetwork2", * resourceGroupName: example.name, * addressSpaces: ["10.0.2.0/24"], * location: example.location, * }); * const example_1VirtualNetworkPeering = new azure.network.VirtualNetworkPeering("example-1", { * name: "peer1to2", * resourceGroupName: example.name, * virtualNetworkName: example_1.name, * remoteVirtualNetworkId: example_2.id, * }); * const example_2VirtualNetworkPeering = new azure.network.VirtualNetworkPeering("example-2", { * name: "peer2to1", * resourceGroupName: example.name, * virtualNetworkName: example_2.name, * remoteVirtualNetworkId: example_1.id, * }); * ``` * * ### Global Virtual Network Peering) * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as azure from "@pulumi/azure"; * import * as std from "@pulumi/std"; * * const config = new pulumi.Config(); * const location = config.getObject("location") || [ * "uksouth", * "southeastasia", * ]; * const vnetAddressSpace = config.getObject("vnetAddressSpace") || [ * "10.0.0.0/16", * "10.1.0.0/16", * ]; * const example: azure.core.ResourceGroup[] = []; * for (const range = {value: 0}; range.value < location.length; range.value++) { * example.push(new azure.core.ResourceGroup(`example-${range.value}`, { * name: `rg-global-vnet-peering-${range.value}`, * location: location[range.value], * })); * } * const vnet: azure.network.VirtualNetwork[] = []; * for (const range = {value: 0}; range.value < location.length; range.value++) { * vnet.push(new azure.network.VirtualNetwork(`vnet-${range.value}`, { * name: `vnet-${range.value}`, * resourceGroupName: example.map(__item => __item.name)[range.value], * addressSpaces: [vnetAddressSpace[range.value]], * location: example.map(__item => __item.location)[range.value], * })); * } * const nva: azure.network.Subnet[] = []; * for (const range = {value: 0}; range.value < location.length; range.value++) { * nva.push(new azure.network.Subnet(`nva-${range.value}`, { * name: "nva", * resourceGroupName: example.map(__item => __item.name)[range.value], * virtualNetworkName: vnet.map(__item => __item.name)[range.value], * addressPrefix: std.cidrsubnet({ * input: vnet[range.value].addressSpace[range.value], * newbits: 13, * netnum: 0, * }).then(invoke => invoke.result), * })); * } * // enable global peering between the two virtual network * const peering: azure.network.VirtualNetworkPeering[] = []; * for (const range = {value: 0}; range.value < location.length; range.value++) { * peering.push(new azure.network.VirtualNetworkPeering(`peering-${range.value}`, { * name: vnet.map(__item => __item.name)[1 - range.value].apply(names => `peering-to-${names}`), * resourceGroupName: example.map(__item => __item.name)[range.value], * virtualNetworkName: vnet.map(__item => __item.name)[range.value], * remoteVirtualNetworkId: vnet.map(__item => __item.id)[1 - range.value], * allowVirtualNetworkAccess: true, * allowForwardedTraffic: true, * allowGatewayTransit: false, * })); * } * ``` * * ### Triggers) * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as azure from "@pulumi/azure"; * import * as std from "@pulumi/std"; * * const example = new azure.core.ResourceGroup("example", { * name: "peeredvnets-rg", * location: "West Europe", * }); * const example_1 = new azure.network.VirtualNetwork("example-1", { * name: "peternetwork1", * resourceGroupName: example.name, * addressSpaces: ["10.0.1.0/24"], * location: example.location, * }); * const example_2 = new azure.network.VirtualNetwork("example-2", { * name: "peternetwork2", * resourceGroupName: example.name, * addressSpaces: ["10.0.2.0/24"], * location: example.location, * }); * const example_1VirtualNetworkPeering = new azure.network.VirtualNetworkPeering("example-1", { * name: "peer1to2", * resourceGroupName: example.name, * virtualNetworkName: example_1.name, * remoteVirtualNetworkId: example_2.id, * triggers: { * remote_address_space: example_2.addressSpaces.apply(addressSpaces => std.joinOutput({ * separator: ",", * input: addressSpaces, * })).apply(invoke => invoke.result), * }, * }); * const example_2VirtualNetworkPeering = new azure.network.VirtualNetworkPeering("example-2", { * name: "peer2to1", * resourceGroupName: example.name, * virtualNetworkName: example_2.name, * remoteVirtualNetworkId: example_1.id, * triggers: { * remote_address_space: example_1.addressSpaces.apply(addressSpaces => std.joinOutput({ * separator: ",", * input: addressSpaces, * })).apply(invoke => invoke.result), * }, * }); * ``` * * ## Note * * Virtual Network peerings cannot be created, updated or deleted concurrently. * * ## API Providers * * * This resource uses the following Azure API Providers: * * * `Microsoft.Network` - 2025-01-01 * * ## Import * * Virtual Network Peerings can be imported using the `resource id`, e.g. * * ```sh * $ pulumi import azure:network/virtualNetworkPeering:VirtualNetworkPeering examplePeering /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Network/virtualNetworks/myvnet1/virtualNetworkPeerings/myvnet1peering * ``` */ export declare class VirtualNetworkPeering extends pulumi.CustomResource { /** * Get an existing VirtualNetworkPeering resource's state with the given name, ID, and optional extra * properties used to qualify the lookup. * * @param name The _unique_ name of the resulting resource. * @param id The _unique_ provider ID of the resource to lookup. * @param state Any extra arguments used during the lookup. * @param opts Optional settings to control the behavior of the CustomResource. */ static get(name: string, id: pulumi.Input, state?: VirtualNetworkPeeringState, opts?: pulumi.CustomResourceOptions): VirtualNetworkPeering; /** * Returns true if the given object is an instance of VirtualNetworkPeering. This is designed to work even * when multiple copies of the Pulumi SDK have been loaded into the same process. */ static isInstance(obj: any): obj is VirtualNetworkPeering; /** * Controls if forwarded traffic from VMs in the remote virtual network is allowed. Defaults to `false`. */ readonly allowForwardedTraffic: pulumi.Output; /** * Controls gatewayLinks can be used in the remote virtual network’s link to the local virtual network. Defaults to `false`. */ readonly allowGatewayTransit: pulumi.Output; /** * Controls if the traffic from the local virtual network can reach the remote virtual network. Defaults to `true`. */ readonly allowVirtualNetworkAccess: pulumi.Output; /** * A list of local Subnet names that are Subnet peered with remote Virtual Network. */ readonly localSubnetNames: pulumi.Output; /** * The name of the virtual network peering. Changing this forces a new resource to be created. */ readonly name: pulumi.Output; /** * Specifies whether only IPv6 address space is peered for Subnet peering. Changing this forces a new resource to be created. */ readonly onlyIpv6PeeringEnabled: pulumi.Output; /** * Specifies whether complete Virtual Network address space is peered. Defaults to `true`. Changing this forces a new resource to be created. */ readonly peerCompleteVirtualNetworksEnabled: pulumi.Output; /** * A list of remote Subnet names from remote Virtual Network that are Subnet peered. */ readonly remoteSubnetNames: pulumi.Output; /** * The full Azure resource ID of the remote virtual network. Changing this forces a new resource to be created. */ readonly remoteVirtualNetworkId: pulumi.Output; /** * The name of the resource group in which to create the virtual network peering. Changing this forces a new resource to be created. */ readonly resourceGroupName: pulumi.Output; /** * A mapping of key values pairs that can be used to sync network routes from the remote virtual network to the local virtual network. See the trigger example for an example on how to set it up. */ readonly triggers: pulumi.Output<{ [key: string]: string; } | undefined>; /** * Controls if remote gateways can be used on the local virtual network. If the flag is set to `true`, and `allowGatewayTransit` on the remote peering is also `true`, virtual network will use gateways of remote virtual network for transit. Only one peering can have this flag set to `true`. This flag cannot be set if virtual network already has a gateway. Defaults to `false`. * * > **Note:** `useRemoteGateways` must be set to `false` if using Global Virtual Network Peerings. */ readonly useRemoteGateways: pulumi.Output; /** * The name of the virtual network. Changing this forces a new resource to be created. */ readonly virtualNetworkName: pulumi.Output; /** * Create a VirtualNetworkPeering resource with the given unique name, arguments, and options. * * @param name The _unique_ name of the resource. * @param args The arguments to use to populate this resource's properties. * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args: VirtualNetworkPeeringArgs, opts?: pulumi.CustomResourceOptions); } /** * Input properties used for looking up and filtering VirtualNetworkPeering resources. */ export interface VirtualNetworkPeeringState { /** * Controls if forwarded traffic from VMs in the remote virtual network is allowed. Defaults to `false`. */ allowForwardedTraffic?: pulumi.Input; /** * Controls gatewayLinks can be used in the remote virtual network’s link to the local virtual network. Defaults to `false`. */ allowGatewayTransit?: pulumi.Input; /** * Controls if the traffic from the local virtual network can reach the remote virtual network. Defaults to `true`. */ allowVirtualNetworkAccess?: pulumi.Input; /** * A list of local Subnet names that are Subnet peered with remote Virtual Network. */ localSubnetNames?: pulumi.Input[]>; /** * The name of the virtual network peering. Changing this forces a new resource to be created. */ name?: pulumi.Input; /** * Specifies whether only IPv6 address space is peered for Subnet peering. Changing this forces a new resource to be created. */ onlyIpv6PeeringEnabled?: pulumi.Input; /** * Specifies whether complete Virtual Network address space is peered. Defaults to `true`. Changing this forces a new resource to be created. */ peerCompleteVirtualNetworksEnabled?: pulumi.Input; /** * A list of remote Subnet names from remote Virtual Network that are Subnet peered. */ remoteSubnetNames?: pulumi.Input[]>; /** * The full Azure resource ID of the remote virtual network. Changing this forces a new resource to be created. */ remoteVirtualNetworkId?: pulumi.Input; /** * The name of the resource group in which to create the virtual network peering. Changing this forces a new resource to be created. */ resourceGroupName?: pulumi.Input; /** * A mapping of key values pairs that can be used to sync network routes from the remote virtual network to the local virtual network. See the trigger example for an example on how to set it up. */ triggers?: pulumi.Input<{ [key: string]: pulumi.Input; }>; /** * Controls if remote gateways can be used on the local virtual network. If the flag is set to `true`, and `allowGatewayTransit` on the remote peering is also `true`, virtual network will use gateways of remote virtual network for transit. Only one peering can have this flag set to `true`. This flag cannot be set if virtual network already has a gateway. Defaults to `false`. * * > **Note:** `useRemoteGateways` must be set to `false` if using Global Virtual Network Peerings. */ useRemoteGateways?: pulumi.Input; /** * The name of the virtual network. Changing this forces a new resource to be created. */ virtualNetworkName?: pulumi.Input; } /** * The set of arguments for constructing a VirtualNetworkPeering resource. */ export interface VirtualNetworkPeeringArgs { /** * Controls if forwarded traffic from VMs in the remote virtual network is allowed. Defaults to `false`. */ allowForwardedTraffic?: pulumi.Input; /** * Controls gatewayLinks can be used in the remote virtual network’s link to the local virtual network. Defaults to `false`. */ allowGatewayTransit?: pulumi.Input; /** * Controls if the traffic from the local virtual network can reach the remote virtual network. Defaults to `true`. */ allowVirtualNetworkAccess?: pulumi.Input; /** * A list of local Subnet names that are Subnet peered with remote Virtual Network. */ localSubnetNames?: pulumi.Input[]>; /** * The name of the virtual network peering. Changing this forces a new resource to be created. */ name?: pulumi.Input; /** * Specifies whether only IPv6 address space is peered for Subnet peering. Changing this forces a new resource to be created. */ onlyIpv6PeeringEnabled?: pulumi.Input; /** * Specifies whether complete Virtual Network address space is peered. Defaults to `true`. Changing this forces a new resource to be created. */ peerCompleteVirtualNetworksEnabled?: pulumi.Input; /** * A list of remote Subnet names from remote Virtual Network that are Subnet peered. */ remoteSubnetNames?: pulumi.Input[]>; /** * The full Azure resource ID of the remote virtual network. Changing this forces a new resource to be created. */ remoteVirtualNetworkId: pulumi.Input; /** * The name of the resource group in which to create the virtual network peering. Changing this forces a new resource to be created. */ resourceGroupName: pulumi.Input; /** * A mapping of key values pairs that can be used to sync network routes from the remote virtual network to the local virtual network. See the trigger example for an example on how to set it up. */ triggers?: pulumi.Input<{ [key: string]: pulumi.Input; }>; /** * Controls if remote gateways can be used on the local virtual network. If the flag is set to `true`, and `allowGatewayTransit` on the remote peering is also `true`, virtual network will use gateways of remote virtual network for transit. Only one peering can have this flag set to `true`. This flag cannot be set if virtual network already has a gateway. Defaults to `false`. * * > **Note:** `useRemoteGateways` must be set to `false` if using Global Virtual Network Peerings. */ useRemoteGateways?: pulumi.Input; /** * The name of the virtual network. Changing this forces a new resource to be created. */ virtualNetworkName: pulumi.Input; }