"use strict";
// *** WARNING: this file was generated by pulumi-language-nodejs. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.VirtualNetworkPeering = void 0;
const pulumi = __importStar(require("@pulumi/pulumi"));
const utilities = __importStar(require("../utilities"));
/**
 * 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<any>("location") || [
 *     "uksouth",
 *     "southeastasia",
 * ];
 * const vnetAddressSpace = config.getObject<any>("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 section is generated, changes will be overwritten -->
 * 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
 * ```
 */
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, id, state, opts) {
        return new VirtualNetworkPeering(name, state, { ...opts, id: id });
    }
    /** @internal */
    static __pulumiType = 'azure:network/virtualNetworkPeering: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) {
        if (obj === undefined || obj === null) {
            return false;
        }
        return obj['__pulumiType'] === VirtualNetworkPeering.__pulumiType;
    }
    constructor(name, argsOrState, opts) {
        let resourceInputs = {};
        opts = opts || {};
        if (opts.id) {
            const state = argsOrState;
            resourceInputs["allowForwardedTraffic"] = state?.allowForwardedTraffic;
            resourceInputs["allowGatewayTransit"] = state?.allowGatewayTransit;
            resourceInputs["allowVirtualNetworkAccess"] = state?.allowVirtualNetworkAccess;
            resourceInputs["localSubnetNames"] = state?.localSubnetNames;
            resourceInputs["name"] = state?.name;
            resourceInputs["onlyIpv6PeeringEnabled"] = state?.onlyIpv6PeeringEnabled;
            resourceInputs["peerCompleteVirtualNetworksEnabled"] = state?.peerCompleteVirtualNetworksEnabled;
            resourceInputs["remoteSubnetNames"] = state?.remoteSubnetNames;
            resourceInputs["remoteVirtualNetworkId"] = state?.remoteVirtualNetworkId;
            resourceInputs["resourceGroupName"] = state?.resourceGroupName;
            resourceInputs["triggers"] = state?.triggers;
            resourceInputs["useRemoteGateways"] = state?.useRemoteGateways;
            resourceInputs["virtualNetworkName"] = state?.virtualNetworkName;
        }
        else {
            const args = argsOrState;
            if (args?.remoteVirtualNetworkId === undefined && !opts.urn) {
                throw new Error("Missing required property 'remoteVirtualNetworkId'");
            }
            if (args?.resourceGroupName === undefined && !opts.urn) {
                throw new Error("Missing required property 'resourceGroupName'");
            }
            if (args?.virtualNetworkName === undefined && !opts.urn) {
                throw new Error("Missing required property 'virtualNetworkName'");
            }
            resourceInputs["allowForwardedTraffic"] = args?.allowForwardedTraffic;
            resourceInputs["allowGatewayTransit"] = args?.allowGatewayTransit;
            resourceInputs["allowVirtualNetworkAccess"] = args?.allowVirtualNetworkAccess;
            resourceInputs["localSubnetNames"] = args?.localSubnetNames;
            resourceInputs["name"] = args?.name;
            resourceInputs["onlyIpv6PeeringEnabled"] = args?.onlyIpv6PeeringEnabled;
            resourceInputs["peerCompleteVirtualNetworksEnabled"] = args?.peerCompleteVirtualNetworksEnabled;
            resourceInputs["remoteSubnetNames"] = args?.remoteSubnetNames;
            resourceInputs["remoteVirtualNetworkId"] = args?.remoteVirtualNetworkId;
            resourceInputs["resourceGroupName"] = args?.resourceGroupName;
            resourceInputs["triggers"] = args?.triggers;
            resourceInputs["useRemoteGateways"] = args?.useRemoteGateways;
            resourceInputs["virtualNetworkName"] = args?.virtualNetworkName;
        }
        opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
        super(VirtualNetworkPeering.__pulumiType, name, resourceInputs, opts);
    }
}
exports.VirtualNetworkPeering = VirtualNetworkPeering;
//# sourceMappingURL=virtualNetworkPeering.js.map