@pulumi/gcp
Version:
A Pulumi package for creating and managing Google Cloud Platform resources.
122 lines • 5.65 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.NetworkPeering = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
* Manages a network peering within GCE. For more information see
* [the official documentation](https://cloud.google.com/compute/docs/vpc/vpc-peering)
* and
* [API](https://cloud.google.com/compute/docs/reference/latest/networks).
*
* > Both networks must create a peering with each other for the peering
* to be functional.
*
* > Subnets IP ranges across peered VPC networks cannot overlap.
*
* ## Example Usage
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const _default = new gcp.compute.Network("default", {
* name: "foobar",
* autoCreateSubnetworks: false,
* });
* const other = new gcp.compute.Network("other", {
* name: "other",
* autoCreateSubnetworks: false,
* });
* const peering1 = new gcp.compute.NetworkPeering("peering1", {
* name: "peering1",
* network: _default.selfLink,
* peerNetwork: other.selfLink,
* });
* const peering2 = new gcp.compute.NetworkPeering("peering2", {
* name: "peering2",
* network: other.selfLink,
* peerNetwork: _default.selfLink,
* });
* ```
*
* ## Import
*
* VPC network peerings can be imported using the name and project of the primary network the peering exists in and the name of the network peering
*
* * `{{project_id}}/{{network_id}}/{{peering_id}}`
*
* When using the `pulumi import` command, VPC network peerings can be imported using one of the formats above. For example:
*
* ```sh
* $ pulumi import gcp:compute/networkPeering:NetworkPeering default {{project_id}}/{{network_id}}/{{peering_id}}
* ```
*/
class NetworkPeering extends pulumi.CustomResource {
/**
* Get an existing NetworkPeering 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 NetworkPeering(name, state, Object.assign(Object.assign({}, opts), { id: id }));
}
/**
* Returns true if the given object is an instance of NetworkPeering. 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'] === NetworkPeering.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["exportCustomRoutes"] = state ? state.exportCustomRoutes : undefined;
resourceInputs["exportSubnetRoutesWithPublicIp"] = state ? state.exportSubnetRoutesWithPublicIp : undefined;
resourceInputs["importCustomRoutes"] = state ? state.importCustomRoutes : undefined;
resourceInputs["importSubnetRoutesWithPublicIp"] = state ? state.importSubnetRoutesWithPublicIp : undefined;
resourceInputs["name"] = state ? state.name : undefined;
resourceInputs["network"] = state ? state.network : undefined;
resourceInputs["peerNetwork"] = state ? state.peerNetwork : undefined;
resourceInputs["stackType"] = state ? state.stackType : undefined;
resourceInputs["state"] = state ? state.state : undefined;
resourceInputs["stateDetails"] = state ? state.stateDetails : undefined;
}
else {
const args = argsOrState;
if ((!args || args.network === undefined) && !opts.urn) {
throw new Error("Missing required property 'network'");
}
if ((!args || args.peerNetwork === undefined) && !opts.urn) {
throw new Error("Missing required property 'peerNetwork'");
}
resourceInputs["exportCustomRoutes"] = args ? args.exportCustomRoutes : undefined;
resourceInputs["exportSubnetRoutesWithPublicIp"] = args ? args.exportSubnetRoutesWithPublicIp : undefined;
resourceInputs["importCustomRoutes"] = args ? args.importCustomRoutes : undefined;
resourceInputs["importSubnetRoutesWithPublicIp"] = args ? args.importSubnetRoutesWithPublicIp : undefined;
resourceInputs["name"] = args ? args.name : undefined;
resourceInputs["network"] = args ? args.network : undefined;
resourceInputs["peerNetwork"] = args ? args.peerNetwork : undefined;
resourceInputs["stackType"] = args ? args.stackType : undefined;
resourceInputs["state"] = undefined /*out*/;
resourceInputs["stateDetails"] = undefined /*out*/;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(NetworkPeering.__pulumiType, name, resourceInputs, opts);
}
}
exports.NetworkPeering = NetworkPeering;
/** @internal */
NetworkPeering.__pulumiType = 'gcp:compute/networkPeering:NetworkPeering';
//# sourceMappingURL=networkPeering.js.map