Subnet class

A Distributed Cloud Edge subnet, which provides L2 isolation within a network.

To get more information about Subnet, see:

Example Usage

Edgenetwork Subnet

import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";

const exampleNetwork = new gcp.edgenetwork.Network("example_network", {
    networkId: "example-network",
    location: "us-west1",
    zone: "",
    description: "Example network.",
    mtu: 9000,
});
const exampleSubnet = new gcp.edgenetwork.Subnet("example_subnet", {
    subnetId: "example-subnet",
    location: "us-west1",
    zone: "",
    description: "Example subnet.",
    network: exampleNetwork.id,
    ipv4Cidrs: ["4.4.4.1/24"],
    labels: {
        environment: "dev",
    },
});
import pulumi
import pulumi_gcp as gcp

example_network = gcp.edgenetwork.Network("example_network",
    network_id="example-network",
    location="us-west1",
    zone="",
    description="Example network.",
    mtu=9000)
example_subnet = gcp.edgenetwork.Subnet("example_subnet",
    subnet_id="example-subnet",
    location="us-west1",
    zone="",
    description="Example subnet.",
    network=example_network.id,
    ipv4_cidrs=["4.4.4.1/24"],
    labels={
        "environment": "dev",
    })
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;

return await Deployment.RunAsync(() =>
{
    var exampleNetwork = new Gcp.EdgeNetwork.Network("example_network", new()
    {
        NetworkId = "example-network",
        Location = "us-west1",
        Zone = "",
        Description = "Example network.",
        Mtu = 9000,
    });

    var exampleSubnet = new Gcp.EdgeNetwork.Subnet("example_subnet", new()
    {
        SubnetId = "example-subnet",
        Location = "us-west1",
        Zone = "",
        Description = "Example subnet.",
        Network = exampleNetwork.Id,
        Ipv4Cidrs = new[]
        {
            "4.4.4.1/24",
        },
        Labels =
        {
            { "environment", "dev" },
        },
    });

});
package main

import (
	"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/edgenetwork"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		exampleNetwork, err := edgenetwork.NewNetwork(ctx, "example_network", &edgenetwork.NetworkArgs{
			NetworkId:   pulumi.String("example-network"),
			Location:    pulumi.String("us-west1"),
			Zone:        pulumi.String(""),
			Description: pulumi.String("Example network."),
			Mtu:         pulumi.Int(9000),
		})
		if err != nil {
			return err
		}
		_, err = edgenetwork.NewSubnet(ctx, "example_subnet", &edgenetwork.SubnetArgs{
			SubnetId:    pulumi.String("example-subnet"),
			Location:    pulumi.String("us-west1"),
			Zone:        pulumi.String(""),
			Description: pulumi.String("Example subnet."),
			Network:     exampleNetwork.ID().ToIDOutput().ToStringOutput(),
			Ipv4Cidrs: pulumi.StringArray{
				pulumi.String("4.4.4.1/24"),
			},
			Labels: pulumi.StringMap{
				"environment": pulumi.String("dev"),
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
pulumi {
  required_providers {
    gcp = {
      source = "pulumi/gcp"
    }
  }
}

resource "gcp_edgenetwork_subnet" "example_subnet" {
  subnet_id   = "example-subnet"
  location    = "us-west1"
  zone        = ""
  description = "Example subnet."
  network     = gcp_edgenetwork_network.example_network.id
  ipv4_cidrs  = ["4.4.4.1/24"]
  labels = {
    "environment" = "dev"
  }
}
resource "gcp_edgenetwork_network" "example_network" {
  network_id  = "example-network"
  location    = "us-west1"
  zone        = ""
  description = "Example network."
  mtu         = 9000
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.edgenetwork.Network;
import com.pulumi.gcp.edgenetwork.NetworkArgs;
import com.pulumi.gcp.edgenetwork.Subnet;
import com.pulumi.gcp.edgenetwork.SubnetArgs;
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 exampleNetwork = new Network("exampleNetwork", NetworkArgs.builder()
            .networkId("example-network")
            .location("us-west1")
            .zone("")
            .description("Example network.")
            .mtu(9000)
            .build());

        var exampleSubnet = new Subnet("exampleSubnet", SubnetArgs.builder()
            .subnetId("example-subnet")
            .location("us-west1")
            .zone("")
            .description("Example subnet.")
            .network(exampleNetwork.id())
            .ipv4Cidrs("4.4.4.1/24")
            .labels(Map.of("environment", "dev"))
            .build());

    }
}
resources:
  exampleSubnet:
    type: gcp:edgenetwork:Subnet
    name: example_subnet
    properties:
      subnetId: example-subnet
      location: us-west1
      zone: ""
      description: Example subnet.
      network: ${exampleNetwork.id}
      ipv4Cidrs:
        - 4.4.4.1/24
      labels:
        environment: dev
  exampleNetwork:
    type: gcp:edgenetwork:Network
    name: example_network
    properties:
      networkId: example-network
      location: us-west1
      zone: ""
      description: Example network.
      mtu: 9000

Edgenetwork Subnet With Vlan Id

import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";

const exampleNetwork = new gcp.edgenetwork.Network("example_network", {
    networkId: "example-network",
    location: "us-west1",
    zone: "",
    description: "Example network.",
    mtu: 9000,
});
const exampleSubnetWithVlanId = new gcp.edgenetwork.Subnet("example_subnet_with_vlan_id", {
    subnetId: "example-subnet-with-vlan-id",
    location: "us-west1",
    zone: "",
    description: "Example subnet with VLAN ID.",
    network: exampleNetwork.id,
    ipv6Cidrs: ["4444:4444:4444:4444::1/64"],
    vlanId: 44,
    labels: {
        environment: "dev",
    },
});
import pulumi
import pulumi_gcp as gcp

example_network = gcp.edgenetwork.Network("example_network",
    network_id="example-network",
    location="us-west1",
    zone="",
    description="Example network.",
    mtu=9000)
example_subnet_with_vlan_id = gcp.edgenetwork.Subnet("example_subnet_with_vlan_id",
    subnet_id="example-subnet-with-vlan-id",
    location="us-west1",
    zone="",
    description="Example subnet with VLAN ID.",
    network=example_network.id,
    ipv6_cidrs=["4444:4444:4444:4444::1/64"],
    vlan_id=44,
    labels={
        "environment": "dev",
    })
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;

return await Deployment.RunAsync(() =>
{
    var exampleNetwork = new Gcp.EdgeNetwork.Network("example_network", new()
    {
        NetworkId = "example-network",
        Location = "us-west1",
        Zone = "",
        Description = "Example network.",
        Mtu = 9000,
    });

    var exampleSubnetWithVlanId = new Gcp.EdgeNetwork.Subnet("example_subnet_with_vlan_id", new()
    {
        SubnetId = "example-subnet-with-vlan-id",
        Location = "us-west1",
        Zone = "",
        Description = "Example subnet with VLAN ID.",
        Network = exampleNetwork.Id,
        Ipv6Cidrs = new[]
        {
            "4444:4444:4444:4444::1/64",
        },
        VlanId = 44,
        Labels =
        {
            { "environment", "dev" },
        },
    });

});
package main

import (
	"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/edgenetwork"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		exampleNetwork, err := edgenetwork.NewNetwork(ctx, "example_network", &edgenetwork.NetworkArgs{
			NetworkId:   pulumi.String("example-network"),
			Location:    pulumi.String("us-west1"),
			Zone:        pulumi.String(""),
			Description: pulumi.String("Example network."),
			Mtu:         pulumi.Int(9000),
		})
		if err != nil {
			return err
		}
		_, err = edgenetwork.NewSubnet(ctx, "example_subnet_with_vlan_id", &edgenetwork.SubnetArgs{
			SubnetId:    pulumi.String("example-subnet-with-vlan-id"),
			Location:    pulumi.String("us-west1"),
			Zone:        pulumi.String(""),
			Description: pulumi.String("Example subnet with VLAN ID."),
			Network:     exampleNetwork.ID().ToIDOutput().ToStringOutput(),
			Ipv6Cidrs: pulumi.StringArray{
				pulumi.String("4444:4444:4444:4444::1/64"),
			},
			VlanId: pulumi.Int(44),
			Labels: pulumi.StringMap{
				"environment": pulumi.String("dev"),
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
pulumi {
  required_providers {
    gcp = {
      source = "pulumi/gcp"
    }
  }
}

resource "gcp_edgenetwork_subnet" "example_subnet_with_vlan_id" {
  subnet_id   = "example-subnet-with-vlan-id"
  location    = "us-west1"
  zone        = ""
  description = "Example subnet with VLAN ID."
  network     = gcp_edgenetwork_network.example_network.id
  ipv6_cidrs  = ["4444:4444:4444:4444::1/64"]
  vlan_id     = 44
  labels = {
    "environment" = "dev"
  }
}
resource "gcp_edgenetwork_network" "example_network" {
  network_id  = "example-network"
  location    = "us-west1"
  zone        = ""
  description = "Example network."
  mtu         = 9000
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.edgenetwork.Network;
import com.pulumi.gcp.edgenetwork.NetworkArgs;
import com.pulumi.gcp.edgenetwork.Subnet;
import com.pulumi.gcp.edgenetwork.SubnetArgs;
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 exampleNetwork = new Network("exampleNetwork", NetworkArgs.builder()
            .networkId("example-network")
            .location("us-west1")
            .zone("")
            .description("Example network.")
            .mtu(9000)
            .build());

        var exampleSubnetWithVlanId = new Subnet("exampleSubnetWithVlanId", SubnetArgs.builder()
            .subnetId("example-subnet-with-vlan-id")
            .location("us-west1")
            .zone("")
            .description("Example subnet with VLAN ID.")
            .network(exampleNetwork.id())
            .ipv6Cidrs("4444:4444:4444:4444::1/64")
            .vlanId(44)
            .labels(Map.of("environment", "dev"))
            .build());

    }
}
resources:
  exampleSubnetWithVlanId:
    type: gcp:edgenetwork:Subnet
    name: example_subnet_with_vlan_id
    properties:
      subnetId: example-subnet-with-vlan-id
      location: us-west1
      zone: ""
      description: Example subnet with VLAN ID.
      network: ${exampleNetwork.id}
      ipv6Cidrs:
        - 4444:4444:4444:4444::1/64
      vlanId: 44
      labels:
        environment: dev
  exampleNetwork:
    type: gcp:edgenetwork:Network
    name: example_network
    properties:
      networkId: example-network
      location: us-west1
      zone: ""
      description: Example network.
      mtu: 9000

Import

Subnet can be imported using any of these accepted formats:

  • projects/{{project}}/locations/{{location}}/zones/{{zone}}/subnets/{{subnet_id}}
  • {{project}}/{{location}}/{{zone}}/{{subnet_id}}
  • {{location}}/{{zone}}/{{subnet_id}}
  • {{location}}/{{subnet_id}}
  • {{name}}

When using the pulumi import command, Subnet can be imported using one of the formats above. For example:

$ pulumi import gcp:edgenetwork/subnet:Subnet default projects/{{project}}/locations/{{location}}/zones/{{zone}}/subnets/{{subnet_id}}
$ pulumi import gcp:edgenetwork/subnet:Subnet default {{project}}/{{location}}/{{zone}}/{{subnet_id}}
$ pulumi import gcp:edgenetwork/subnet:Subnet default {{location}}/{{zone}}/{{subnet_id}}
$ pulumi import gcp:edgenetwork/subnet:Subnet default {{location}}/{{subnet_id}}
$ pulumi import gcp:edgenetwork/subnet:Subnet default {{name}}

Constructors

Subnet(String name, {SubnetArgs? args, CustomResourceOptions? options})
Creates a new Subnet. name The Pulumi resource name. args Arguments used to configure this Subnet. The set of arguments for Subnet. options Resource options controlling this resource's behavior.
Subnet.reference(String urn)
Creates a typed reference to an existing Subnet resource.

Properties

childResources → Set<Resource>
finalinherited
completionSources ↔ Map<String, IOutputCompletionSource>
latefinalinherited
createTime ↔ Output<String>
The time when the subnet was created. A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. Examples: 2014-10-02T15:01:23Z and 2014-10-02T15:01:23.045123456Z.
latefinal
deletionPolicy ↔ Output<String>
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
description ↔ Output<String?>
A free-text description of the resource. Max length 1024 characters.
latefinal
effectiveLabels ↔ Output<Map<String, String>>
All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Pulumi, other clients and services.
latefinal
hashCode → int
The hash code for this object.
no setterinherited
id ↔ Output<String>
getter/setter pairinherited
ipv4Cidrs ↔ Output<List<String>?>
The ranges of ipv4 addresses that are owned by this subnetwork, in CIDR format.
latefinal
ipv6Cidrs ↔ Output<List<String>?>
The ranges of ipv6 addresses that are owned by this subnetwork, in CIDR format.
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
labels ↔ Output<Map<String, String>?>
Labels associated with this resource.
latefinal
location ↔ Output<String>
The Google Cloud region to which the target Distributed Cloud Edge zone belongs.
latefinal
name ↔ Output<String>
The canonical name of this resource, with format projects/{{project}}/locations/{{location}}/zones/{{zone}}/subnets/{{subnet_id}}
latefinal
network ↔ Output<String>
The ID of the network to which this router belongs. Must be of the form: projects/{{project}}/locations/{{location}}/zones/{{zone}}/networks/{{network_id}}
latefinal
project ↔ Output<String>
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
latefinal
pulumiLabels ↔ Output<Map<String, String>>
The combination of labels configured directly on the resource and default labels configured on the provider.
latefinal
resourceTransforms → List<ResourceTransform>
Inherited/explicit async transforms.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
state ↔ Output<String>
Current stage of the resource to the device by config push.
latefinal
subnetId ↔ Output<String>
A unique ID that identifies this subnet.
latefinal
transformations → List<ResourceTransformation>
Inherited/explicit legacy transformations.
no setterinherited
updateTime ↔ Output<String>
The time when the subnet was last updated. A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. Examples: 2014-10-02T15:01:23Z and 2014-10-02T15:01:23.045123456Z.
latefinal
urn ↔ Output<String>
latefinalinherited
vlanId ↔ Output<int>
VLAN ID for this subnetwork. If not specified, one is assigned automatically.
latefinal
zone ↔ Output<String>
The name of the target Distributed Cloud Edge zone.
latefinal

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, {SubnetState? state, CustomResourceOptions? options}) → Subnet
Gets an existing Subnet resource's state with the given name and id.