@pulumi/gcp
Version:
A Pulumi package for creating and managing Google Cloud Platform resources.
175 lines • 7.78 kB
JavaScript
;
// *** 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.NetworkEndpoint = void 0;
const pulumi = __importStar(require("@pulumi/pulumi"));
const utilities = __importStar(require("../utilities"));
/**
* A Network endpoint represents a IP address and port combination that is
* part of a specific network endpoint group (NEG). NEGs are zonal
* collections of these endpoints for GCP resources within a
* single subnet. **NOTE**: Network endpoints cannot be created outside of a
* network endpoint group.
*
* > **NOTE** In case the Endpoint's Instance is recreated, it's needed to
* perform `apply` twice. To avoid situations like this, please use this resource
* with the lifecycle `replaceTriggeredBy` method, with the passed Instance's ID.
*
* To get more information about NetworkEndpoint, 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
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const myImage = gcp.compute.getImage({
* family: "debian-11",
* project: "debian-cloud",
* });
* 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.1/16",
* region: "us-central1",
* network: _default.id,
* });
* const endpoint_instance = new gcp.compute.Instance("endpoint-instance", {
* networkInterfaces: [{
* accessConfigs: [{}],
* subnetwork: defaultSubnetwork.id,
* }],
* name: "endpoint-instance",
* machineType: "e2-medium",
* bootDisk: {
* initializeParams: {
* image: myImage.then(myImage => myImage.selfLink),
* },
* },
* });
* const default_endpoint = new gcp.compute.NetworkEndpoint("default-endpoint", {
* networkEndpointGroup: neg.name,
* instance: endpoint_instance.name,
* port: Number(neg.defaultPort),
* ipAddress: endpoint_instance.networkInterfaces.apply(networkInterfaces => networkInterfaces[0].networkIp),
* });
* const group = new gcp.compute.NetworkEndpointGroup("group", {
* name: "my-lb-neg",
* network: _default.id,
* subnetwork: defaultSubnetwork.id,
* defaultPort: 90,
* zone: "us-central1-a",
* });
* ```
*
* ## Import
*
* NetworkEndpoint can be imported using any of these accepted formats:
*
* * `projects/{{project}}/zones/{{zone}}/networkEndpointGroups/{{network_endpoint_group}}/{{instance}}/{{ip_address}}/{{port}}`
* * `{{project}}/{{zone}}/{{network_endpoint_group}}/{{instance}}/{{ip_address}}/{{port}}`
* * `{{zone}}/{{network_endpoint_group}}/{{instance}}/{{ip_address}}/{{port}}`
* * `{{network_endpoint_group}}/{{instance}}/{{ip_address}}/{{port}}`
*
* When using the `pulumi import` command, NetworkEndpoint can be imported using one of the formats above. For example:
*
* ```sh
* $ pulumi import gcp:compute/networkEndpoint:NetworkEndpoint default projects/{{project}}/zones/{{zone}}/networkEndpointGroups/{{network_endpoint_group}}/{{instance}}/{{ip_address}}/{{port}}
* $ pulumi import gcp:compute/networkEndpoint:NetworkEndpoint default {{project}}/{{zone}}/{{network_endpoint_group}}/{{instance}}/{{ip_address}}/{{port}}
* $ pulumi import gcp:compute/networkEndpoint:NetworkEndpoint default {{zone}}/{{network_endpoint_group}}/{{instance}}/{{ip_address}}/{{port}}
* $ pulumi import gcp:compute/networkEndpoint:NetworkEndpoint default {{network_endpoint_group}}/{{instance}}/{{ip_address}}/{{port}}
* ```
*/
class NetworkEndpoint extends pulumi.CustomResource {
/**
* Get an existing NetworkEndpoint 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 NetworkEndpoint(name, state, { ...opts, id: id });
}
/** @internal */
static __pulumiType = 'gcp:compute/networkEndpoint:NetworkEndpoint';
/**
* Returns true if the given object is an instance of NetworkEndpoint. 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'] === NetworkEndpoint.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["deletionPolicy"] = state?.deletionPolicy;
resourceInputs["instance"] = state?.instance;
resourceInputs["ipAddress"] = state?.ipAddress;
resourceInputs["networkEndpointGroup"] = state?.networkEndpointGroup;
resourceInputs["port"] = state?.port;
resourceInputs["project"] = state?.project;
resourceInputs["zone"] = state?.zone;
}
else {
const args = argsOrState;
if (args?.ipAddress === undefined && !opts.urn) {
throw new Error("Missing required property 'ipAddress'");
}
if (args?.networkEndpointGroup === undefined && !opts.urn) {
throw new Error("Missing required property 'networkEndpointGroup'");
}
resourceInputs["deletionPolicy"] = args?.deletionPolicy;
resourceInputs["instance"] = args?.instance;
resourceInputs["ipAddress"] = args?.ipAddress;
resourceInputs["networkEndpointGroup"] = args?.networkEndpointGroup;
resourceInputs["port"] = args?.port;
resourceInputs["project"] = args?.project;
resourceInputs["zone"] = args?.zone;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(NetworkEndpoint.__pulumiType, name, resourceInputs, opts);
}
}
exports.NetworkEndpoint = NetworkEndpoint;
//# sourceMappingURL=networkEndpoint.js.map