"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! ***
Object.defineProperty(exports, "__esModule", { value: true });
exports.NetworkEndpointGroup = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
 * Network endpoint groups (NEGs) are zonal resources that represent
 * collections of IP address and port combinations for GCP resources within a
 * single subnet. Each IP address and port combination is called a network
 * endpoint.
 *
 * Network endpoint groups can be used as backends in backend services for
 * HTTP(S), TCP proxy, and SSL proxy load balancers. You cannot use NEGs as a
 * backend with internal load balancers. Because NEG backends allow you to
 * specify IP addresses and ports, you can distribute traffic in a granular
 * fashion among applications or containers running within VM instances.
 *
 * Recreating a network endpoint group that's in use by another resource will give a
 * `resourceInUseByAnotherResource` error. Use `lifecycle.create_before_destroy`
 * to avoid this type of error.
 *
 * To get more information about NetworkEndpointGroup, see:
 *
 * * [API documentation](https://cloud.google.com/compute/docs/reference/rest/beta/networkEndpointGroups)
 * * How-to Guides
 *     * [Official Documentation](https://cloud.google.com/load-balancing/docs/negs/)
 *
 * ## Example Usage
 *
 * ### Network Endpoint Group
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 *
 * const _default = new gcp.compute.Network("default", {
 *     name: "neg-network",
 *     autoCreateSubnetworks: false,
 * });
 * const defaultSubnetwork = new gcp.compute.Subnetwork("default", {
 *     name: "neg-subnetwork",
 *     ipCidrRange: "10.0.0.0/16",
 *     region: "us-central1",
 *     network: _default.id,
 * });
 * const neg = new gcp.compute.NetworkEndpointGroup("neg", {
 *     name: "my-lb-neg",
 *     network: _default.id,
 *     subnetwork: defaultSubnetwork.id,
 *     defaultPort: 90,
 *     zone: "us-central1-a",
 * });
 * ```
 * ### Network Endpoint Group Non Gcp
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 *
 * const _default = new gcp.compute.Network("default", {name: "neg-network"});
 * const neg = new gcp.compute.NetworkEndpointGroup("neg", {
 *     name: "my-lb-neg",
 *     network: _default.id,
 *     defaultPort: 90,
 *     zone: "us-central1-a",
 *     networkEndpointType: "NON_GCP_PRIVATE_IP_PORT",
 * });
 * const default_endpoint = new gcp.compute.NetworkEndpoint("default-endpoint", {
 *     networkEndpointGroup: neg.name,
 *     port: neg.defaultPort,
 *     ipAddress: "127.0.0.1",
 * });
 * ```
 *
 * ## Import
 *
 * NetworkEndpointGroup can be imported using any of these accepted formats:
 *
 * * `projects/{{project}}/zones/{{zone}}/networkEndpointGroups/{{name}}`
 *
 * * `{{project}}/{{zone}}/{{name}}`
 *
 * * `{{zone}}/{{name}}`
 *
 * * `{{name}}`
 *
 * When using the `pulumi import` command, NetworkEndpointGroup can be imported using one of the formats above. For example:
 *
 * ```sh
 * $ pulumi import gcp:compute/networkEndpointGroup:NetworkEndpointGroup default projects/{{project}}/zones/{{zone}}/networkEndpointGroups/{{name}}
 * ```
 *
 * ```sh
 * $ pulumi import gcp:compute/networkEndpointGroup:NetworkEndpointGroup default {{project}}/{{zone}}/{{name}}
 * ```
 *
 * ```sh
 * $ pulumi import gcp:compute/networkEndpointGroup:NetworkEndpointGroup default {{zone}}/{{name}}
 * ```
 *
 * ```sh
 * $ pulumi import gcp:compute/networkEndpointGroup:NetworkEndpointGroup default {{name}}
 * ```
 */
class NetworkEndpointGroup extends pulumi.CustomResource {
    /**
     * Get an existing NetworkEndpointGroup 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 NetworkEndpointGroup(name, state, { ...opts, id: id });
    }
    /**
     * Returns true if the given object is an instance of NetworkEndpointGroup.  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'] === NetworkEndpointGroup.__pulumiType;
    }
    constructor(name, argsOrState, opts) {
        let resourceInputs = {};
        opts = opts || {};
        if (opts.id) {
            const state = argsOrState;
            resourceInputs["defaultPort"] = state?.defaultPort;
            resourceInputs["description"] = state?.description;
            resourceInputs["generatedId"] = state?.generatedId;
            resourceInputs["name"] = state?.name;
            resourceInputs["network"] = state?.network;
            resourceInputs["networkEndpointType"] = state?.networkEndpointType;
            resourceInputs["project"] = state?.project;
            resourceInputs["selfLink"] = state?.selfLink;
            resourceInputs["size"] = state?.size;
            resourceInputs["subnetwork"] = state?.subnetwork;
            resourceInputs["zone"] = state?.zone;
        }
        else {
            const args = argsOrState;
            if (args?.network === undefined && !opts.urn) {
                throw new Error("Missing required property 'network'");
            }
            resourceInputs["defaultPort"] = args?.defaultPort;
            resourceInputs["description"] = args?.description;
            resourceInputs["name"] = args?.name;
            resourceInputs["network"] = args?.network;
            resourceInputs["networkEndpointType"] = args?.networkEndpointType;
            resourceInputs["project"] = args?.project;
            resourceInputs["subnetwork"] = args?.subnetwork;
            resourceInputs["zone"] = args?.zone;
            resourceInputs["generatedId"] = undefined /*out*/;
            resourceInputs["selfLink"] = undefined /*out*/;
            resourceInputs["size"] = undefined /*out*/;
        }
        opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
        super(NetworkEndpointGroup.__pulumiType, name, resourceInputs, opts);
    }
}
exports.NetworkEndpointGroup = NetworkEndpointGroup;
/** @internal */
NetworkEndpointGroup.__pulumiType = 'gcp:compute/networkEndpointGroup:NetworkEndpointGroup';
//# sourceMappingURL=networkEndpointGroup.js.map