NetworkPeering class
Manages a network peering within GCE. For more information see the official documentation and API.
> 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
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 pulumi
import pulumi_gcp as gcp
default = gcp.compute.Network("default",
name="foobar",
auto_create_subnetworks=False)
other = gcp.compute.Network("other",
name="other",
auto_create_subnetworks=False)
peering1 = gcp.compute.NetworkPeering("peering1",
name="peering1",
network=default.self_link,
peer_network=other.self_link)
peering2 = gcp.compute.NetworkPeering("peering2",
name="peering2",
network=other.self_link,
peer_network=default.self_link)
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;
return await Deployment.RunAsync(() =>
{
var @default = new Gcp.Compute.Network("default", new()
{
Name = "foobar",
AutoCreateSubnetworks = false,
});
var other = new Gcp.Compute.Network("other", new()
{
Name = "other",
AutoCreateSubnetworks = false,
});
var peering1 = new Gcp.Compute.NetworkPeering("peering1", new()
{
Name = "peering1",
Network = @default.SelfLink,
PeerNetwork = other.SelfLink,
});
var peering2 = new Gcp.Compute.NetworkPeering("peering2", new()
{
Name = "peering2",
Network = other.SelfLink,
PeerNetwork = @default.SelfLink,
});
});
package main
import (
"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/compute"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_default, err := compute.NewNetwork(ctx, "default", &compute.NetworkArgs{
Name: pulumi.String("foobar"),
AutoCreateSubnetworks: pulumi.Bool(false),
})
if err != nil {
return err
}
other, err := compute.NewNetwork(ctx, "other", &compute.NetworkArgs{
Name: pulumi.String("other"),
AutoCreateSubnetworks: pulumi.Bool(false),
})
if err != nil {
return err
}
_, err = compute.NewNetworkPeering(ctx, "peering1", &compute.NetworkPeeringArgs{
Name: pulumi.String("peering1"),
Network: _default.SelfLink,
PeerNetwork: other.SelfLink,
})
if err != nil {
return err
}
_, err = compute.NewNetworkPeering(ctx, "peering2", &compute.NetworkPeeringArgs{
Name: pulumi.String("peering2"),
Network: other.SelfLink,
PeerNetwork: _default.SelfLink,
})
if err != nil {
return err
}
return nil
})
}
pulumi {
required_providers {
gcp = {
source = "pulumi/gcp"
}
}
}
resource "gcp_compute_networkpeering" "peering1" {
name = "peering1"
network = gcp_compute_network.default.self_link
peer_network = gcp_compute_network.other.self_link
}
resource "gcp_compute_networkpeering" "peering2" {
name = "peering2"
network = gcp_compute_network.other.self_link
peer_network = gcp_compute_network.default.self_link
}
resource "gcp_compute_network" "default" {
name = "foobar"
auto_create_subnetworks = "false"
}
resource "gcp_compute_network" "other" {
name = "other"
auto_create_subnetworks = "false"
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.compute.Network;
import com.pulumi.gcp.compute.NetworkArgs;
import com.pulumi.gcp.compute.NetworkPeering;
import com.pulumi.gcp.compute.NetworkPeeringArgs;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var default_ = new Network("default", NetworkArgs.builder()
.name("foobar")
.autoCreateSubnetworks(false)
.build());
var other = new Network("other", NetworkArgs.builder()
.name("other")
.autoCreateSubnetworks(false)
.build());
var peering1 = new NetworkPeering("peering1", NetworkPeeringArgs.builder()
.name("peering1")
.network(default_.selfLink())
.peerNetwork(other.selfLink())
.build());
var peering2 = new NetworkPeering("peering2", NetworkPeeringArgs.builder()
.name("peering2")
.network(other.selfLink())
.peerNetwork(default_.selfLink())
.build());
}
}
resources:
peering1:
type: gcp:compute:NetworkPeering
properties:
name: peering1
network: ${default.selfLink}
peerNetwork: ${other.selfLink}
peering2:
type: gcp:compute:NetworkPeering
properties:
name: peering2
network: ${other.selfLink}
peerNetwork: ${default.selfLink}
default:
type: gcp:compute:Network
properties:
name: foobar
autoCreateSubnetworks: 'false'
other:
type: gcp:compute:Network
properties:
name: other
autoCreateSubnetworks: 'false'
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:
$ pulumi import gcp:compute/networkPeering:NetworkPeering default {{project_id}}/{{network_id}}/{{peering_id}}
Constructors
- NetworkPeering(String name, {NetworkPeeringArgs? args, CustomResourceOptions? options})
-
Creates a new NetworkPeering.
nameThe Pulumi resource name.argsArguments used to configure this NetworkPeering. The set of arguments for NetworkPeering.optionsResource options controlling this resource's behavior. - NetworkPeering.reference(String urn)
- Creates a typed reference to an existing NetworkPeering resource.
Properties
-
childResources
→ Set<
Resource> -
finalinherited
-
completionSources
↔ Map<
String, IOutputCompletionSource> -
latefinalinherited
-
deletionPolicy
↔ Output<
String> -
(Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE".
When a 'terraform destroy' or 'pulumi up' would delete the resource,
the command will fail if this field is set to "PREVENT" in Terraform state.
When set to "ABANDON", the command will remove the resource from Terraform
management without updating or deleting the resource in the API.
When set to "DELETE", deleting the resource is allowed.
latefinal
-
exportCustomRoutes
↔ Output<
bool?> -
Whether to export the custom routes to the peer network. Defaults to
false.latefinal -
exportSubnetRoutesWithPublicIp
↔ Output<
bool?> -
Whether subnet routes with public IP range are exported. The default value is true, all subnet routes are exported. The IPv4 special-use ranges (https://en.wikipedia.org/wiki/IPv4#Special_addresses) are always exported to peers and are not controlled by this field.
latefinal
- hashCode → int
-
The hash code for this object.
no setterinherited
-
id
↔ Output<
String> -
getter/setter pairinherited
-
importCustomRoutes
↔ Output<
bool?> -
Whether to import the custom routes from the peer network. Defaults to
false.latefinal -
importSubnetRoutesWithPublicIp
↔ Output<
bool?> -
Whether subnet routes with public IP range are imported. The default value is false. The IPv4 special-use ranges (https://en.wikipedia.org/wiki/IPv4#Special_addresses) are always imported from peers and are not controlled by this field.
latefinal
- isCustom → bool
-
Returns whether this resource is provider-managed.
no setterinherited
- isProtected → bool
-
Returns whether this resource is protected from deletion.
no setterinherited
- isRemote → bool
-
Whether this resource is registered as remote.
no setterinherited
- isResourceReference → bool
-
Whether this instance represents a resource value returned over RPC.
finalinherited
-
name
↔ Output<
String> -
Name of the peering.
latefinal
-
network
↔ Output<
String> -
The primary network of the peering.
latefinal
-
peerNetwork
↔ Output<
String> -
The peer network in the peering. The peer network
may belong to a different project.
latefinal
-
resourceTransforms
→ List<
ResourceTransform> -
Inherited/explicit async transforms.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
stackType
↔ Output<
String?> -
Which IP version(s) of traffic and routes are allowed to be imported or exported between peer networks. The default value is IPV4_ONLY. Possible values:
"IPV4_ONLY", "IPV4_IPV6".latefinal -
state
↔ Output<
String> -
State for the peering, either
ACTIVEorINACTIVE. The peering isACTIVEwhen there's a matching configuration in the peer network.latefinal -
stateDetails
↔ Output<
String> -
Details about the current state of the peering.
latefinal
-
transformations
→ List<
ResourceTransformation> -
Inherited/explicit legacy transformations.
no setterinherited
-
updateStrategy
↔ Output<
String?> -
The update strategy determines the semantics for updates and deletes to the peering connection configuration. The default value is INDEPENDENT. Possible values:
"INDEPENDENT", "CONSENSUS"latefinal -
urn
↔ Output<
String> -
latefinalinherited
Methods
-
failId(
Object error) → void -
Completes this resource ID with an error when registration fails.
inherited
-
failOutputs(
Object error) → void -
Completes all output properties with
error.inherited -
failUrn(
Object error) → void -
Completes this resource URN with an error when registration fails.
inherited
-
getProvider(
String moduleMember) → ProviderResource? -
Returns provider for
moduleMember's package, if configured.inherited -
getResourceName(
) → String -
Returns this resource's logical name.
inherited
-
getResourceType(
) → String -
Returns this resource's Pulumi type token.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
registerOutput<
T> (String propertyName, {Object? decoder(Object?)?, bool isSecret = false}) → Output< T> -
Registers a dynamic output property for this resource.
inherited
-
resolveId(
String? value, {required bool isKnown}) → void -
Resolves the provider-assigned ID for this resource.
inherited
-
resolveOutputs(
Struct outputs) → void -
Resolves all output properties from a monitor response payload.
inherited
-
resolveUrn(
String value) → void -
Resolves this resource's URN once assigned by the engine.
inherited
-
serializeProperties(
Map< String, dynamic> properties) → Future<Struct> -
Serializes resource properties for RPC transmission.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
get(
String name, Input< String> id, {NetworkPeeringState? state, CustomResourceOptions? options}) → NetworkPeering -
Gets an existing NetworkPeering resource's state with the given
nameandid.