Network

Manages a VPC network or legacy network resource on GCP.

To get more information about Network, see:

Example Usage

Network Basic

using Pulumi;
using Gcp = Pulumi.Gcp;

class MyStack : Stack
{
    public MyStack()
    {
        var vpcNetwork = new Gcp.Compute.Network("vpcNetwork", new Gcp.Compute.NetworkArgs
        {
        });
    }

}
package main

import (
	"github.com/pulumi/pulumi-gcp/sdk/v5/go/gcp/compute"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := compute.NewNetwork(ctx, "vpcNetwork", nil)
		if err != nil {
			return err
		}
		return nil
	})
}
import pulumi
import pulumi_gcp as gcp

vpc_network = gcp.compute.Network("vpcNetwork")
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";

const vpcNetwork = new gcp.compute.Network("vpc_network", {});

Network Custom Mtu

using Pulumi;
using Gcp = Pulumi.Gcp;

class MyStack : Stack
{
    public MyStack()
    {
        var vpcNetwork = new Gcp.Compute.Network("vpcNetwork", new Gcp.Compute.NetworkArgs
        {
            AutoCreateSubnetworks = true,
            Mtu = 1460,
            Project = "my-project-name",
        });
    }

}
package main

import (
	"github.com/pulumi/pulumi-gcp/sdk/v5/go/gcp/compute"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := compute.NewNetwork(ctx, "vpcNetwork", &compute.NetworkArgs{
			AutoCreateSubnetworks: pulumi.Bool(true),
			Mtu:                   pulumi.Int(1460),
			Project:               pulumi.String("my-project-name"),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
import pulumi
import pulumi_gcp as gcp

vpc_network = gcp.compute.Network("vpcNetwork",
    auto_create_subnetworks=True,
    mtu=1460,
    project="my-project-name")
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";

const vpcNetwork = new gcp.compute.Network("vpc_network", {
    autoCreateSubnetworks: true,
    mtu: 1460,
    project: "my-project-name",
});

Create a Network Resource

new Network(name: string, args?: NetworkArgs, opts?: CustomResourceOptions);
@overload
def Network(resource_name: str,
            opts: Optional[ResourceOptions] = None,
            auto_create_subnetworks: Optional[bool] = None,
            delete_default_routes_on_create: Optional[bool] = None,
            description: Optional[str] = None,
            mtu: Optional[int] = None,
            name: Optional[str] = None,
            project: Optional[str] = None,
            routing_mode: Optional[str] = None)
@overload
def Network(resource_name: str,
            args: Optional[NetworkArgs] = None,
            opts: Optional[ResourceOptions] = None)
func NewNetwork(ctx *Context, name string, args *NetworkArgs, opts ...ResourceOption) (*Network, error)
public Network(string name, NetworkArgs? args = null, CustomResourceOptions? opts = null)
name string
The unique name of the resource.
args NetworkArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name str
The unique name of the resource.
args NetworkArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name string
The unique name of the resource.
args NetworkArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args NetworkArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.

Network Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

The Network resource accepts the following input properties:

AutoCreateSubnetworks bool
When set to true, the network is created in “auto subnet mode” and it will create a subnet for each region automatically across the 10.128.0.0/9 address range. When set to false, the network is created in “custom subnet mode” so the user can explicitly connect subnetwork resources.
DeleteDefaultRoutesOnCreate bool
If set to true, default routes (0.0.0.0/0) will be deleted immediately after network creation. Defaults to false.
Description string
An optional description of this resource. The resource must be recreated to modify this field.
Mtu int
Maximum Transmission Unit in bytes. The minimum value for this field is 1460 and the maximum value is 1500 bytes.
Name string
Name of the resource. Provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression a-z? which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash.
Project string
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
RoutingMode string
The network-wide routing mode to use. If set to REGIONAL, this network’s cloud routers will only advertise routes with subnetworks of this network in the same region as the router. If set to GLOBAL, this network’s cloud routers will advertise routes with all subnetworks of this network, across regions. Possible values are REGIONAL and GLOBAL.
AutoCreateSubnetworks bool
When set to true, the network is created in “auto subnet mode” and it will create a subnet for each region automatically across the 10.128.0.0/9 address range. When set to false, the network is created in “custom subnet mode” so the user can explicitly connect subnetwork resources.
DeleteDefaultRoutesOnCreate bool
If set to true, default routes (0.0.0.0/0) will be deleted immediately after network creation. Defaults to false.
Description string
An optional description of this resource. The resource must be recreated to modify this field.
Mtu int
Maximum Transmission Unit in bytes. The minimum value for this field is 1460 and the maximum value is 1500 bytes.
Name string
Name of the resource. Provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression a-z? which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash.
Project string
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
RoutingMode string
The network-wide routing mode to use. If set to REGIONAL, this network’s cloud routers will only advertise routes with subnetworks of this network in the same region as the router. If set to GLOBAL, this network’s cloud routers will advertise routes with all subnetworks of this network, across regions. Possible values are REGIONAL and GLOBAL.
autoCreateSubnetworks boolean
When set to true, the network is created in “auto subnet mode” and it will create a subnet for each region automatically across the 10.128.0.0/9 address range. When set to false, the network is created in “custom subnet mode” so the user can explicitly connect subnetwork resources.
deleteDefaultRoutesOnCreate boolean
If set to true, default routes (0.0.0.0/0) will be deleted immediately after network creation. Defaults to false.
description string
An optional description of this resource. The resource must be recreated to modify this field.
mtu number
Maximum Transmission Unit in bytes. The minimum value for this field is 1460 and the maximum value is 1500 bytes.
name string
Name of the resource. Provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression a-z? which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash.
project string
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
routingMode string
The network-wide routing mode to use. If set to REGIONAL, this network’s cloud routers will only advertise routes with subnetworks of this network in the same region as the router. If set to GLOBAL, this network’s cloud routers will advertise routes with all subnetworks of this network, across regions. Possible values are REGIONAL and GLOBAL.
auto_create_subnetworks bool
When set to true, the network is created in “auto subnet mode” and it will create a subnet for each region automatically across the 10.128.0.0/9 address range. When set to false, the network is created in “custom subnet mode” so the user can explicitly connect subnetwork resources.
delete_default_routes_on_create bool
If set to true, default routes (0.0.0.0/0) will be deleted immediately after network creation. Defaults to false.
description str
An optional description of this resource. The resource must be recreated to modify this field.
mtu int
Maximum Transmission Unit in bytes. The minimum value for this field is 1460 and the maximum value is 1500 bytes.
name str
Name of the resource. Provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression a-z? which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash.
project str
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
routing_mode str
The network-wide routing mode to use. If set to REGIONAL, this network’s cloud routers will only advertise routes with subnetworks of this network in the same region as the router. If set to GLOBAL, this network’s cloud routers will advertise routes with all subnetworks of this network, across regions. Possible values are REGIONAL and GLOBAL.

Outputs

All input properties are implicitly available as output properties. Additionally, the Network resource produces the following output properties:

GatewayIpv4 string
The gateway address for default routing out of the network. This value is selected by GCP.
Id string
The provider-assigned unique ID for this managed resource.
SelfLink string
The URI of the created resource.
GatewayIpv4 string
The gateway address for default routing out of the network. This value is selected by GCP.
Id string
The provider-assigned unique ID for this managed resource.
SelfLink string
The URI of the created resource.
gatewayIpv4 string
The gateway address for default routing out of the network. This value is selected by GCP.
id string
The provider-assigned unique ID for this managed resource.
selfLink string
The URI of the created resource.
gateway_ipv4 str
The gateway address for default routing out of the network. This value is selected by GCP.
id str
The provider-assigned unique ID for this managed resource.
self_link str
The URI of the created resource.

Look up an Existing Network Resource

Get an existing Network resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: NetworkState, opts?: CustomResourceOptions): Network
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        auto_create_subnetworks: Optional[bool] = None,
        delete_default_routes_on_create: Optional[bool] = None,
        description: Optional[str] = None,
        gateway_ipv4: Optional[str] = None,
        mtu: Optional[int] = None,
        name: Optional[str] = None,
        project: Optional[str] = None,
        routing_mode: Optional[str] = None,
        self_link: Optional[str] = None) -> Network
func GetNetwork(ctx *Context, name string, id IDInput, state *NetworkState, opts ...ResourceOption) (*Network, error)
public static Network Get(string name, Input<string> id, NetworkState? state, CustomResourceOptions? opts = null)
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.

The following state arguments are supported:

AutoCreateSubnetworks bool
When set to true, the network is created in “auto subnet mode” and it will create a subnet for each region automatically across the 10.128.0.0/9 address range. When set to false, the network is created in “custom subnet mode” so the user can explicitly connect subnetwork resources.
DeleteDefaultRoutesOnCreate bool
If set to true, default routes (0.0.0.0/0) will be deleted immediately after network creation. Defaults to false.
Description string
An optional description of this resource. The resource must be recreated to modify this field.
GatewayIpv4 string
The gateway address for default routing out of the network. This value is selected by GCP.
Mtu int
Maximum Transmission Unit in bytes. The minimum value for this field is 1460 and the maximum value is 1500 bytes.
Name string
Name of the resource. Provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression a-z? which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash.
Project string
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
RoutingMode string
The network-wide routing mode to use. If set to REGIONAL, this network’s cloud routers will only advertise routes with subnetworks of this network in the same region as the router. If set to GLOBAL, this network’s cloud routers will advertise routes with all subnetworks of this network, across regions. Possible values are REGIONAL and GLOBAL.
SelfLink string
The URI of the created resource.
AutoCreateSubnetworks bool
When set to true, the network is created in “auto subnet mode” and it will create a subnet for each region automatically across the 10.128.0.0/9 address range. When set to false, the network is created in “custom subnet mode” so the user can explicitly connect subnetwork resources.
DeleteDefaultRoutesOnCreate bool
If set to true, default routes (0.0.0.0/0) will be deleted immediately after network creation. Defaults to false.
Description string
An optional description of this resource. The resource must be recreated to modify this field.
GatewayIpv4 string
The gateway address for default routing out of the network. This value is selected by GCP.
Mtu int
Maximum Transmission Unit in bytes. The minimum value for this field is 1460 and the maximum value is 1500 bytes.
Name string
Name of the resource. Provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression a-z? which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash.
Project string
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
RoutingMode string
The network-wide routing mode to use. If set to REGIONAL, this network’s cloud routers will only advertise routes with subnetworks of this network in the same region as the router. If set to GLOBAL, this network’s cloud routers will advertise routes with all subnetworks of this network, across regions. Possible values are REGIONAL and GLOBAL.
SelfLink string
The URI of the created resource.
autoCreateSubnetworks boolean
When set to true, the network is created in “auto subnet mode” and it will create a subnet for each region automatically across the 10.128.0.0/9 address range. When set to false, the network is created in “custom subnet mode” so the user can explicitly connect subnetwork resources.
deleteDefaultRoutesOnCreate boolean
If set to true, default routes (0.0.0.0/0) will be deleted immediately after network creation. Defaults to false.
description string
An optional description of this resource. The resource must be recreated to modify this field.
gatewayIpv4 string
The gateway address for default routing out of the network. This value is selected by GCP.
mtu number
Maximum Transmission Unit in bytes. The minimum value for this field is 1460 and the maximum value is 1500 bytes.
name string
Name of the resource. Provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression a-z? which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash.
project string
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
routingMode string
The network-wide routing mode to use. If set to REGIONAL, this network’s cloud routers will only advertise routes with subnetworks of this network in the same region as the router. If set to GLOBAL, this network’s cloud routers will advertise routes with all subnetworks of this network, across regions. Possible values are REGIONAL and GLOBAL.
selfLink string
The URI of the created resource.
auto_create_subnetworks bool
When set to true, the network is created in “auto subnet mode” and it will create a subnet for each region automatically across the 10.128.0.0/9 address range. When set to false, the network is created in “custom subnet mode” so the user can explicitly connect subnetwork resources.
delete_default_routes_on_create bool
If set to true, default routes (0.0.0.0/0) will be deleted immediately after network creation. Defaults to false.
description str
An optional description of this resource. The resource must be recreated to modify this field.
gateway_ipv4 str
The gateway address for default routing out of the network. This value is selected by GCP.
mtu int
Maximum Transmission Unit in bytes. The minimum value for this field is 1460 and the maximum value is 1500 bytes.
name str
Name of the resource. Provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression a-z? which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash.
project str
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
routing_mode str
The network-wide routing mode to use. If set to REGIONAL, this network’s cloud routers will only advertise routes with subnetworks of this network in the same region as the router. If set to GLOBAL, this network’s cloud routers will advertise routes with all subnetworks of this network, across regions. Possible values are REGIONAL and GLOBAL.
self_link str
The URI of the created resource.

Import

Network can be imported using any of these accepted formats

 $ pulumi import gcp:compute/network:Network default projects/{{project}}/global/networks/{{name}}
 $ pulumi import gcp:compute/network:Network default {{project}}/{{name}}
 $ pulumi import gcp:compute/network:Network default {{name}}

Package Details

Repository
https://github.com/pulumi/pulumi-gcp
License
Apache-2.0
Notes
This Pulumi package is based on the google-beta Terraform Provider.