@pulumi/gcp
Version:
A Pulumi package for creating and managing Google Cloud Platform resources.
296 lines • 12.1 kB
JavaScript
;
// *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
Object.defineProperty(exports, "__esModule", { value: true });
exports.Route = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = 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}}
* ```
*
* ```sh
* $ pulumi import gcp:compute/route:Route default {{project}}/{{name}}
* ```
*
* ```sh
* $ 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, Object.assign(Object.assign({}, opts), { id: id }));
}
/**
* 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 ? state.asPaths : undefined;
resourceInputs["creationTimestamp"] = state ? state.creationTimestamp : undefined;
resourceInputs["description"] = state ? state.description : undefined;
resourceInputs["destRange"] = state ? state.destRange : undefined;
resourceInputs["name"] = state ? state.name : undefined;
resourceInputs["network"] = state ? state.network : undefined;
resourceInputs["nextHopGateway"] = state ? state.nextHopGateway : undefined;
resourceInputs["nextHopHub"] = state ? state.nextHopHub : undefined;
resourceInputs["nextHopIlb"] = state ? state.nextHopIlb : undefined;
resourceInputs["nextHopInstance"] = state ? state.nextHopInstance : undefined;
resourceInputs["nextHopInstanceZone"] = state ? state.nextHopInstanceZone : undefined;
resourceInputs["nextHopInterRegionCost"] = state ? state.nextHopInterRegionCost : undefined;
resourceInputs["nextHopIp"] = state ? state.nextHopIp : undefined;
resourceInputs["nextHopMed"] = state ? state.nextHopMed : undefined;
resourceInputs["nextHopNetwork"] = state ? state.nextHopNetwork : undefined;
resourceInputs["nextHopOrigin"] = state ? state.nextHopOrigin : undefined;
resourceInputs["nextHopPeering"] = state ? state.nextHopPeering : undefined;
resourceInputs["nextHopVpnTunnel"] = state ? state.nextHopVpnTunnel : undefined;
resourceInputs["priority"] = state ? state.priority : undefined;
resourceInputs["project"] = state ? state.project : undefined;
resourceInputs["routeStatus"] = state ? state.routeStatus : undefined;
resourceInputs["routeType"] = state ? state.routeType : undefined;
resourceInputs["selfLink"] = state ? state.selfLink : undefined;
resourceInputs["tags"] = state ? state.tags : undefined;
resourceInputs["warnings"] = state ? state.warnings : undefined;
}
else {
const args = argsOrState;
if ((!args || args.destRange === undefined) && !opts.urn) {
throw new Error("Missing required property 'destRange'");
}
if ((!args || args.network === undefined) && !opts.urn) {
throw new Error("Missing required property 'network'");
}
resourceInputs["description"] = args ? args.description : undefined;
resourceInputs["destRange"] = args ? args.destRange : undefined;
resourceInputs["name"] = args ? args.name : undefined;
resourceInputs["network"] = args ? args.network : undefined;
resourceInputs["nextHopGateway"] = args ? args.nextHopGateway : undefined;
resourceInputs["nextHopIlb"] = args ? args.nextHopIlb : undefined;
resourceInputs["nextHopInstance"] = args ? args.nextHopInstance : undefined;
resourceInputs["nextHopInstanceZone"] = args ? args.nextHopInstanceZone : undefined;
resourceInputs["nextHopIp"] = args ? args.nextHopIp : undefined;
resourceInputs["nextHopVpnTunnel"] = args ? args.nextHopVpnTunnel : undefined;
resourceInputs["priority"] = args ? args.priority : undefined;
resourceInputs["project"] = args ? args.project : undefined;
resourceInputs["tags"] = args ? args.tags : undefined;
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;
/** @internal */
Route.__pulumiType = 'gcp:compute/route:Route';
//# sourceMappingURL=route.js.map