@pulumi/gcp
Version:
A Pulumi package for creating and managing Google Cloud Platform resources.
315 lines • 12.6 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.Route = void 0;
const pulumi = __importStar(require("@pulumi/pulumi"));
const utilities = __importStar(require("../utilities"));
/**
* Represents a Route resource.
*
* A route is a rule that specifies how certain packets should be handled by
* the virtual network. Routes are associated with virtual machines by tag,
* and the set of routes for a particular virtual machine is called its
* routing table. For each packet leaving a virtual machine, the system
* searches that virtual machine's routing table for a single best matching
* route.
*
* Routes match packets by destination IP address, preferring smaller or more
* specific ranges over larger ones. If there is a tie, the system selects
* the route with the smallest priority value. If there is still a tie, it
* uses the layer three and four packet headers to select just one of the
* remaining matching routes. The packet is then forwarded as specified by
* the nextHop field of the winning route -- either to another virtual
* machine destination, a virtual machine gateway or a Compute
* Engine-operated gateway. Packets that do not match any route in the
* sending virtual machine's routing table will be dropped.
*
* A Route resource must have exactly one specification of either
* nextHopGateway, nextHopInstance, nextHopIp, nextHopVpnTunnel, or
* nextHopIlb.
*
* To get more information about Route, see:
*
* * [API documentation](https://cloud.google.com/compute/docs/reference/rest/v1/routes)
* * How-to Guides
* * [Using Routes](https://cloud.google.com/vpc/docs/using-routes)
*
* ## Example Usage
*
* ### Route Basic
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const defaultNetwork = new gcp.compute.Network("default", {name: "compute-network"});
* const _default = new gcp.compute.Route("default", {
* name: "network-route",
* destRange: "15.0.0.0/24",
* network: defaultNetwork.name,
* nextHopIp: "10.132.1.5",
* priority: 100,
* });
* ```
* ### Route Ilb
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const _default = new gcp.compute.Network("default", {
* name: "compute-network",
* autoCreateSubnetworks: false,
* });
* const defaultSubnetwork = new gcp.compute.Subnetwork("default", {
* name: "compute-subnet",
* ipCidrRange: "10.0.1.0/24",
* region: "us-central1",
* network: _default.id,
* });
* const hc = new gcp.compute.HealthCheck("hc", {
* name: "proxy-health-check",
* checkIntervalSec: 1,
* timeoutSec: 1,
* tcpHealthCheck: {
* port: 80,
* },
* });
* const backend = new gcp.compute.RegionBackendService("backend", {
* name: "compute-backend",
* region: "us-central1",
* healthChecks: hc.id,
* });
* const defaultForwardingRule = new gcp.compute.ForwardingRule("default", {
* name: "compute-forwarding-rule",
* region: "us-central1",
* loadBalancingScheme: "INTERNAL",
* backendService: backend.id,
* allPorts: true,
* network: _default.name,
* subnetwork: defaultSubnetwork.name,
* });
* const route_ilb = new gcp.compute.Route("route-ilb", {
* name: "route-ilb",
* destRange: "0.0.0.0/0",
* network: _default.name,
* nextHopIlb: defaultForwardingRule.id,
* priority: 2000,
* });
* ```
* ### Route Ilb Vip
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const producer = new gcp.compute.Network("producer", {
* name: "producer-vpc",
* autoCreateSubnetworks: false,
* });
* const producerSubnetwork = new gcp.compute.Subnetwork("producer", {
* name: "producer-subnet",
* ipCidrRange: "10.0.1.0/24",
* region: "us-central1",
* network: producer.id,
* });
* const consumer = new gcp.compute.Network("consumer", {
* name: "consumer-vpc",
* autoCreateSubnetworks: false,
* });
* const consumerSubnetwork = new gcp.compute.Subnetwork("consumer", {
* name: "consumer-subnet",
* ipCidrRange: "10.0.2.0/24",
* region: "us-central1",
* network: consumer.id,
* });
* const peering1 = new gcp.compute.NetworkPeering("peering1", {
* name: "peering-producer-to-consumer",
* network: consumer.id,
* peerNetwork: producer.id,
* });
* const peering2 = new gcp.compute.NetworkPeering("peering2", {
* name: "peering-consumer-to-producer",
* network: producer.id,
* peerNetwork: consumer.id,
* });
* const hc = new gcp.compute.HealthCheck("hc", {
* name: "proxy-health-check",
* checkIntervalSec: 1,
* timeoutSec: 1,
* tcpHealthCheck: {
* port: 80,
* },
* });
* const backend = new gcp.compute.RegionBackendService("backend", {
* name: "compute-backend",
* region: "us-central1",
* healthChecks: hc.id,
* });
* const _default = new gcp.compute.ForwardingRule("default", {
* name: "compute-forwarding-rule",
* region: "us-central1",
* loadBalancingScheme: "INTERNAL",
* backendService: backend.id,
* allPorts: true,
* network: producer.name,
* subnetwork: producerSubnetwork.name,
* });
* const route_ilb = new gcp.compute.Route("route-ilb", {
* name: "route-ilb",
* destRange: "0.0.0.0/0",
* network: consumer.name,
* nextHopIlb: _default.ipAddress,
* priority: 2000,
* tags: [
* "tag1",
* "tag2",
* ],
* }, {
* dependsOn: [
* peering1,
* peering2,
* ],
* });
* ```
*
* ## Import
*
* Route can be imported using any of these accepted formats:
*
* * `projects/{{project}}/global/routes/{{name}}`
* * `{{project}}/{{name}}`
* * `{{name}}`
*
* When using the `pulumi import` command, Route can be imported using one of the formats above. For example:
*
* ```sh
* $ pulumi import gcp:compute/route:Route default projects/{{project}}/global/routes/{{name}}
* $ pulumi import gcp:compute/route:Route default {{project}}/{{name}}
* $ pulumi import gcp:compute/route:Route default {{name}}
* ```
*/
class Route extends pulumi.CustomResource {
/**
* Get an existing Route 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 Route(name, state, { ...opts, id: id });
}
/** @internal */
static __pulumiType = 'gcp:compute/route:Route';
/**
* Returns true if the given object is an instance of Route. 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'] === Route.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["asPaths"] = state?.asPaths;
resourceInputs["creationTimestamp"] = state?.creationTimestamp;
resourceInputs["deletionPolicy"] = state?.deletionPolicy;
resourceInputs["description"] = state?.description;
resourceInputs["destRange"] = state?.destRange;
resourceInputs["name"] = state?.name;
resourceInputs["network"] = state?.network;
resourceInputs["nextHopGateway"] = state?.nextHopGateway;
resourceInputs["nextHopHub"] = state?.nextHopHub;
resourceInputs["nextHopIlb"] = state?.nextHopIlb;
resourceInputs["nextHopInstance"] = state?.nextHopInstance;
resourceInputs["nextHopInstanceZone"] = state?.nextHopInstanceZone;
resourceInputs["nextHopInterRegionCost"] = state?.nextHopInterRegionCost;
resourceInputs["nextHopIp"] = state?.nextHopIp;
resourceInputs["nextHopMed"] = state?.nextHopMed;
resourceInputs["nextHopNetwork"] = state?.nextHopNetwork;
resourceInputs["nextHopOrigin"] = state?.nextHopOrigin;
resourceInputs["nextHopPeering"] = state?.nextHopPeering;
resourceInputs["nextHopVpnTunnel"] = state?.nextHopVpnTunnel;
resourceInputs["params"] = state?.params;
resourceInputs["priority"] = state?.priority;
resourceInputs["project"] = state?.project;
resourceInputs["routeStatus"] = state?.routeStatus;
resourceInputs["routeType"] = state?.routeType;
resourceInputs["selfLink"] = state?.selfLink;
resourceInputs["tags"] = state?.tags;
resourceInputs["warnings"] = state?.warnings;
}
else {
const args = argsOrState;
if (args?.destRange === undefined && !opts.urn) {
throw new Error("Missing required property 'destRange'");
}
if (args?.network === undefined && !opts.urn) {
throw new Error("Missing required property 'network'");
}
resourceInputs["deletionPolicy"] = args?.deletionPolicy;
resourceInputs["description"] = args?.description;
resourceInputs["destRange"] = args?.destRange;
resourceInputs["name"] = args?.name;
resourceInputs["network"] = args?.network;
resourceInputs["nextHopGateway"] = args?.nextHopGateway;
resourceInputs["nextHopIlb"] = args?.nextHopIlb;
resourceInputs["nextHopInstance"] = args?.nextHopInstance;
resourceInputs["nextHopInstanceZone"] = args?.nextHopInstanceZone;
resourceInputs["nextHopIp"] = args?.nextHopIp;
resourceInputs["nextHopVpnTunnel"] = args?.nextHopVpnTunnel;
resourceInputs["params"] = args?.params;
resourceInputs["priority"] = args?.priority;
resourceInputs["project"] = args?.project;
resourceInputs["tags"] = args?.tags;
resourceInputs["asPaths"] = undefined /*out*/;
resourceInputs["creationTimestamp"] = undefined /*out*/;
resourceInputs["nextHopHub"] = undefined /*out*/;
resourceInputs["nextHopInterRegionCost"] = undefined /*out*/;
resourceInputs["nextHopMed"] = undefined /*out*/;
resourceInputs["nextHopNetwork"] = undefined /*out*/;
resourceInputs["nextHopOrigin"] = undefined /*out*/;
resourceInputs["nextHopPeering"] = undefined /*out*/;
resourceInputs["routeStatus"] = undefined /*out*/;
resourceInputs["routeType"] = undefined /*out*/;
resourceInputs["selfLink"] = undefined /*out*/;
resourceInputs["warnings"] = undefined /*out*/;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(Route.__pulumiType, name, resourceInputs, opts);
}
}
exports.Route = Route;
//# sourceMappingURL=route.js.map