1. Packages
  2. Gcore Provider
  3. API Docs
  4. Subnet
gcore 0.22.0 published on Wednesday, Apr 30, 2025 by g-core

gcore.Subnet

Explore with Pulumi AI

gcore logo
gcore 0.22.0 published on Wednesday, Apr 30, 2025 by g-core

    Represent subnets. Subnetwork is a range of IP addresses in a cloud network. Addresses from this range will be assigned to machines in the cloud.

    Example Usage

    Prerequisite

    import * as pulumi from "@pulumi/pulumi";
    
    const config = new pulumi.Config();
    const dnsNameservers = config.getObject<Array<string>>("dnsNameservers") || [
        "8.8.4.4",
        "1.1.1.1",
    ];
    const hostRoutes = config.getObject<Array<{destination?: string, nexthop?: string}>>("hostRoutes") || [
        {
            destination: "10.0.3.0/24",
            nexthop: "10.0.0.13",
        },
        {
            destination: "10.0.4.0/24",
            nexthop: "10.0.0.14",
        },
    ];
    
    import pulumi
    
    config = pulumi.Config()
    dns_nameservers = config.get_object("dnsNameservers")
    if dns_nameservers is None:
        dns_nameservers = [
            "8.8.4.4",
            "1.1.1.1",
        ]
    host_routes = config.get_object("hostRoutes")
    if host_routes is None:
        host_routes = [
            {
                "destination": "10.0.3.0/24",
                "nexthop": "10.0.0.13",
            },
            {
                "destination": "10.0.4.0/24",
                "nexthop": "10.0.0.14",
            },
        ]
    
    package main
    
    import (
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi/config"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		cfg := config.New(ctx, "")
    		dnsNameservers := []string{
    			"8.8.4.4",
    			"1.1.1.1",
    		}
    		if param := cfg.GetObject("dnsNameservers"); param != nil {
    			dnsNameservers = param
    		}
    		hostRoutes := []map[string]interface{}{
    			map[string]interface{}{
    				"destination": "10.0.3.0/24",
    				"nexthop":     "10.0.0.13",
    			},
    			map[string]interface{}{
    				"destination": "10.0.4.0/24",
    				"nexthop":     "10.0.0.14",
    			},
    		}
    		if param := cfg.GetObject("hostRoutes"); param != nil {
    			hostRoutes = param
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    
    return await Deployment.RunAsync(() => 
    {
        var config = new Config();
        var dnsNameservers = config.GetObject<string[]>("dnsNameservers") ?? new[]
        {
            "8.8.4.4",
            "1.1.1.1",
        };
        var hostRoutes = config.GetObject<HostRoutes[]>("hostRoutes") ?? new[]
        {
            
            {
                { "destination", "10.0.3.0/24" },
                { "nexthop", "10.0.0.13" },
            },
            
            {
                { "destination", "10.0.4.0/24" },
                { "nexthop", "10.0.0.14" },
            },
        };
    });
    
    public class HostRoutes
    {
        public string destination { get; set; }
        public string nexthop { get; set; }
    }
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import java.util.List;
    import java.util.ArrayList;
    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) {
            final var config = ctx.config();
            final var dnsNameservers = config.get("dnsNameservers").orElse(        
                "8.8.4.4",
                "1.1.1.1");
            final var hostRoutes = config.get("hostRoutes").orElse(        
                %!v(PANIC=Format method: runtime error: invalid memory address or nil pointer dereference),
                %!v(PANIC=Format method: runtime error: invalid memory address or nil pointer dereference));
        }
    }
    
    configuration:
      dnsNameservers:
        type: list(string)
        default:
          - 8.8.4.4
          - 1.1.1.1
      hostRoutes:
        type: list(object({destination = union(none, string), nexthop = union(none, string)}))
        default:
          - destination: 10.0.3.0/24
            nexthop: 10.0.0.13
          - destination: 10.0.4.0/24
            nexthop: 10.0.0.14
    
    import * as pulumi from "@pulumi/pulumi";
    import * as gcore from "@pulumi/gcore";
    
    const project = gcore.getProject({
        name: "Default",
    });
    const region = gcore.getRegion({
        name: "Luxembourg-2",
    });
    const network = new gcore.Network("network", {
        projectId: project.then(project => project.id),
        regionId: region.then(region => region.id),
        type: "vxlan",
    });
    
    import pulumi
    import pulumi_gcore as gcore
    
    project = gcore.get_project(name="Default")
    region = gcore.get_region(name="Luxembourg-2")
    network = gcore.Network("network",
        project_id=project.id,
        region_id=region.id,
        type="vxlan")
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-terraform-provider/sdks/go/gcore/gcore"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		project, err := gcore.GetProject(ctx, &gcore.GetProjectArgs{
    			Name: "Default",
    		}, nil)
    		if err != nil {
    			return err
    		}
    		region, err := gcore.GetRegion(ctx, &gcore.GetRegionArgs{
    			Name: "Luxembourg-2",
    		}, nil)
    		if err != nil {
    			return err
    		}
    		_, err = gcore.NewNetwork(ctx, "network", &gcore.NetworkArgs{
    			ProjectId: pulumi.String(project.Id),
    			RegionId:  pulumi.String(region.Id),
    			Type:      pulumi.String("vxlan"),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Gcore = Pulumi.Gcore;
    
    return await Deployment.RunAsync(() => 
    {
        var project = Gcore.GetProject.Invoke(new()
        {
            Name = "Default",
        });
    
        var region = Gcore.GetRegion.Invoke(new()
        {
            Name = "Luxembourg-2",
        });
    
        var network = new Gcore.Network("network", new()
        {
            ProjectId = project.Apply(getProjectResult => getProjectResult.Id),
            RegionId = region.Apply(getRegionResult => getRegionResult.Id),
            Type = "vxlan",
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.gcore.GcoreFunctions;
    import com.pulumi.gcore.inputs.GetProjectArgs;
    import com.pulumi.gcore.inputs.GetRegionArgs;
    import com.pulumi.gcore.Network;
    import com.pulumi.gcore.NetworkArgs;
    import java.util.List;
    import java.util.ArrayList;
    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) {
            final var project = GcoreFunctions.getProject(GetProjectArgs.builder()
                .name("Default")
                .build());
    
            final var region = GcoreFunctions.getRegion(GetRegionArgs.builder()
                .name("Luxembourg-2")
                .build());
    
            var network = new Network("network", NetworkArgs.builder()
                .projectId(project.applyValue(getProjectResult -> getProjectResult.id()))
                .regionId(region.applyValue(getRegionResult -> getRegionResult.id()))
                .type("vxlan")
                .build());
    
        }
    }
    
    resources:
      network:
        type: gcore:Network
        properties:
          projectId: ${project.id}
          regionId: ${region.id}
          type: vxlan
    variables:
      project:
        fn::invoke:
          function: gcore:getProject
          arguments:
            name: Default
      region:
        fn::invoke:
          function: gcore:getRegion
          arguments:
            name: Luxembourg-2
    

    IPv4

    Coming soon!
    
    Coming soon!
    
    Coming soon!
    
    Coming soon!
    
    Coming soon!
    
    resources:
      subnetIpv4:
        type: gcore:Subnet
        properties:
          projectId: ${data.gcore_project.project.id}
          regionId: ${data.gcore_region.region.id}
          cidr: 192.168.10.0/24
          networkId: ${gcore_network.network.id}
          dnsNameservers: ${var.dns_nameservers}
          dynamic:
            - iterator: ${hr}
              forEach: ${var.host_routes}
              content:
                - destination: ${hr.value.destination}
                  nexthop: ${hr.value.nexthop}
          gatewayIp: 192.168.10.1
    

    IPv6

    import * as pulumi from "@pulumi/pulumi";
    import * as gcore from "@pulumi/gcore";
    
    const subnetIpv6 = new gcore.Subnet("subnetIpv6", {
        projectId: data.gcore_project.project.id,
        regionId: data.gcore_region.region.id,
        cidr: "fd00::/8",
        networkId: gcore_network.network.id,
    });
    
    import pulumi
    import pulumi_gcore as gcore
    
    subnet_ipv6 = gcore.Subnet("subnetIpv6",
        project_id=data["gcore_project"]["project"]["id"],
        region_id=data["gcore_region"]["region"]["id"],
        cidr="fd00::/8",
        network_id=gcore_network["network"]["id"])
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-terraform-provider/sdks/go/gcore/gcore"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := gcore.NewSubnet(ctx, "subnetIpv6", &gcore.SubnetArgs{
    			ProjectId: pulumi.Any(data.Gcore_project.Project.Id),
    			RegionId:  pulumi.Any(data.Gcore_region.Region.Id),
    			Cidr:      pulumi.String("fd00::/8"),
    			NetworkId: pulumi.Any(gcore_network.Network.Id),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Gcore = Pulumi.Gcore;
    
    return await Deployment.RunAsync(() => 
    {
        var subnetIpv6 = new Gcore.Subnet("subnetIpv6", new()
        {
            ProjectId = data.Gcore_project.Project.Id,
            RegionId = data.Gcore_region.Region.Id,
            Cidr = "fd00::/8",
            NetworkId = gcore_network.Network.Id,
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.gcore.Subnet;
    import com.pulumi.gcore.SubnetArgs;
    import java.util.List;
    import java.util.ArrayList;
    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 subnetIpv6 = new Subnet("subnetIpv6", SubnetArgs.builder()
                .projectId(data.gcore_project().project().id())
                .regionId(data.gcore_region().region().id())
                .cidr("fd00::/8")
                .networkId(gcore_network.network().id())
                .build());
    
        }
    }
    
    resources:
      subnetIpv6:
        type: gcore:Subnet
        properties:
          projectId: ${data.gcore_project.project.id}
          regionId: ${data.gcore_region.region.id}
          cidr: fd00::/8
          networkId: ${gcore_network.network.id}
    

    Create Subnet Resource

    Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

    Constructor syntax

    new Subnet(name: string, args: SubnetArgs, opts?: CustomResourceOptions);
    @overload
    def Subnet(resource_name: str,
               args: SubnetArgs,
               opts: Optional[ResourceOptions] = None)
    
    @overload
    def Subnet(resource_name: str,
               opts: Optional[ResourceOptions] = None,
               cidr: Optional[str] = None,
               network_id: Optional[str] = None,
               metadata_map: Optional[Mapping[str, str]] = None,
               enable_dhcp: Optional[bool] = None,
               gateway_ip: Optional[str] = None,
               host_routes: Optional[Sequence[SubnetHostRouteArgs]] = None,
               dns_nameservers: Optional[Sequence[str]] = None,
               name: Optional[str] = None,
               connect_to_network_router: Optional[bool] = None,
               project_id: Optional[float] = None,
               project_name: Optional[str] = None,
               region_id: Optional[float] = None,
               region_name: Optional[str] = None,
               subnet_id: Optional[str] = None,
               timeouts: Optional[SubnetTimeoutsArgs] = None)
    func NewSubnet(ctx *Context, name string, args SubnetArgs, opts ...ResourceOption) (*Subnet, error)
    public Subnet(string name, SubnetArgs args, CustomResourceOptions? opts = null)
    public Subnet(String name, SubnetArgs args)
    public Subnet(String name, SubnetArgs args, CustomResourceOptions options)
    
    type: gcore:Subnet
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    

    Parameters

    name string
    The unique name of the resource.
    args SubnetArgs
    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 SubnetArgs
    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 SubnetArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args SubnetArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args SubnetArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    Constructor example

    The following reference example uses placeholder values for all input properties.

    var subnetResource = new Gcore.Subnet("subnetResource", new()
    {
        Cidr = "string",
        NetworkId = "string",
        MetadataMap = 
        {
            { "string", "string" },
        },
        EnableDhcp = false,
        GatewayIp = "string",
        HostRoutes = new[]
        {
            new Gcore.Inputs.SubnetHostRouteArgs
            {
                Destination = "string",
                Nexthop = "string",
            },
        },
        DnsNameservers = new[]
        {
            "string",
        },
        Name = "string",
        ConnectToNetworkRouter = false,
        ProjectId = 0,
        ProjectName = "string",
        RegionId = 0,
        RegionName = "string",
        SubnetId = "string",
        Timeouts = new Gcore.Inputs.SubnetTimeoutsArgs
        {
            Create = "string",
            Delete = "string",
        },
    });
    
    example, err := gcore.NewSubnet(ctx, "subnetResource", &gcore.SubnetArgs{
    	Cidr:      pulumi.String("string"),
    	NetworkId: pulumi.String("string"),
    	MetadataMap: pulumi.StringMap{
    		"string": pulumi.String("string"),
    	},
    	EnableDhcp: pulumi.Bool(false),
    	GatewayIp:  pulumi.String("string"),
    	HostRoutes: gcore.SubnetHostRouteArray{
    		&gcore.SubnetHostRouteArgs{
    			Destination: pulumi.String("string"),
    			Nexthop:     pulumi.String("string"),
    		},
    	},
    	DnsNameservers: pulumi.StringArray{
    		pulumi.String("string"),
    	},
    	Name:                   pulumi.String("string"),
    	ConnectToNetworkRouter: pulumi.Bool(false),
    	ProjectId:              pulumi.Float64(0),
    	ProjectName:            pulumi.String("string"),
    	RegionId:               pulumi.Float64(0),
    	RegionName:             pulumi.String("string"),
    	SubnetId:               pulumi.String("string"),
    	Timeouts: &gcore.SubnetTimeoutsArgs{
    		Create: pulumi.String("string"),
    		Delete: pulumi.String("string"),
    	},
    })
    
    var subnetResource = new Subnet("subnetResource", SubnetArgs.builder()
        .cidr("string")
        .networkId("string")
        .metadataMap(Map.of("string", "string"))
        .enableDhcp(false)
        .gatewayIp("string")
        .hostRoutes(SubnetHostRouteArgs.builder()
            .destination("string")
            .nexthop("string")
            .build())
        .dnsNameservers("string")
        .name("string")
        .connectToNetworkRouter(false)
        .projectId(0)
        .projectName("string")
        .regionId(0)
        .regionName("string")
        .subnetId("string")
        .timeouts(SubnetTimeoutsArgs.builder()
            .create("string")
            .delete("string")
            .build())
        .build());
    
    subnet_resource = gcore.Subnet("subnetResource",
        cidr="string",
        network_id="string",
        metadata_map={
            "string": "string",
        },
        enable_dhcp=False,
        gateway_ip="string",
        host_routes=[{
            "destination": "string",
            "nexthop": "string",
        }],
        dns_nameservers=["string"],
        name="string",
        connect_to_network_router=False,
        project_id=0,
        project_name="string",
        region_id=0,
        region_name="string",
        subnet_id="string",
        timeouts={
            "create": "string",
            "delete": "string",
        })
    
    const subnetResource = new gcore.Subnet("subnetResource", {
        cidr: "string",
        networkId: "string",
        metadataMap: {
            string: "string",
        },
        enableDhcp: false,
        gatewayIp: "string",
        hostRoutes: [{
            destination: "string",
            nexthop: "string",
        }],
        dnsNameservers: ["string"],
        name: "string",
        connectToNetworkRouter: false,
        projectId: 0,
        projectName: "string",
        regionId: 0,
        regionName: "string",
        subnetId: "string",
        timeouts: {
            create: "string",
            "delete": "string",
        },
    });
    
    type: gcore:Subnet
    properties:
        cidr: string
        connectToNetworkRouter: false
        dnsNameservers:
            - string
        enableDhcp: false
        gatewayIp: string
        hostRoutes:
            - destination: string
              nexthop: string
        metadataMap:
            string: string
        name: string
        networkId: string
        projectId: 0
        projectName: string
        regionId: 0
        regionName: string
        subnetId: string
        timeouts:
            create: string
            delete: string
    

    Subnet Resource Properties

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

    Inputs

    In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

    The Subnet resource accepts the following input properties:

    Cidr string
    Classless Inter-Domain Routing, can be IPv4 or IPv6.
    NetworkId string
    ID of the desired network to create subnet in.
    ConnectToNetworkRouter bool
    True if the network's router should get a gateway in this subnet. Must be explicitly 'false' when gateway_ip is null. Default true.
    DnsNameservers List<string>
    List of strings contains DNS addresses, e.g. 95.85.95.85.
    EnableDhcp bool
    Enable DHCP for this subnet.
    GatewayIp string
    Desired IP address of the subnet's gateway. Use disable value to disable gateway ip.
    HostRoutes List<SubnetHostRoute>
    MetadataMap Dictionary<string, string>
    Metadata map to apply to the subnet.
    Name string
    Name of the subnet.
    ProjectId double
    ID of the desired project to create subnet in. Alternative for project_name. One of them should be specified.
    ProjectName string
    Name of the desired project to create subnet in. Alternative for project_id. One of them should be specified.
    RegionId double
    ID of the desired region to create subnet in. Alternative for region_name. One of them should be specified.
    RegionName string
    Name of the desired region to create subnet in. Alternative for region_id. One of them should be specified.
    SubnetId string
    The ID of this resource.
    Timeouts SubnetTimeouts
    Cidr string
    Classless Inter-Domain Routing, can be IPv4 or IPv6.
    NetworkId string
    ID of the desired network to create subnet in.
    ConnectToNetworkRouter bool
    True if the network's router should get a gateway in this subnet. Must be explicitly 'false' when gateway_ip is null. Default true.
    DnsNameservers []string
    List of strings contains DNS addresses, e.g. 95.85.95.85.
    EnableDhcp bool
    Enable DHCP for this subnet.
    GatewayIp string
    Desired IP address of the subnet's gateway. Use disable value to disable gateway ip.
    HostRoutes []SubnetHostRouteArgs
    MetadataMap map[string]string
    Metadata map to apply to the subnet.
    Name string
    Name of the subnet.
    ProjectId float64
    ID of the desired project to create subnet in. Alternative for project_name. One of them should be specified.
    ProjectName string
    Name of the desired project to create subnet in. Alternative for project_id. One of them should be specified.
    RegionId float64
    ID of the desired region to create subnet in. Alternative for region_name. One of them should be specified.
    RegionName string
    Name of the desired region to create subnet in. Alternative for region_id. One of them should be specified.
    SubnetId string
    The ID of this resource.
    Timeouts SubnetTimeoutsArgs
    cidr String
    Classless Inter-Domain Routing, can be IPv4 or IPv6.
    networkId String
    ID of the desired network to create subnet in.
    connectToNetworkRouter Boolean
    True if the network's router should get a gateway in this subnet. Must be explicitly 'false' when gateway_ip is null. Default true.
    dnsNameservers List<String>
    List of strings contains DNS addresses, e.g. 95.85.95.85.
    enableDhcp Boolean
    Enable DHCP for this subnet.
    gatewayIp String
    Desired IP address of the subnet's gateway. Use disable value to disable gateway ip.
    hostRoutes List<SubnetHostRoute>
    metadataMap Map<String,String>
    Metadata map to apply to the subnet.
    name String
    Name of the subnet.
    projectId Double
    ID of the desired project to create subnet in. Alternative for project_name. One of them should be specified.
    projectName String
    Name of the desired project to create subnet in. Alternative for project_id. One of them should be specified.
    regionId Double
    ID of the desired region to create subnet in. Alternative for region_name. One of them should be specified.
    regionName String
    Name of the desired region to create subnet in. Alternative for region_id. One of them should be specified.
    subnetId String
    The ID of this resource.
    timeouts SubnetTimeouts
    cidr string
    Classless Inter-Domain Routing, can be IPv4 or IPv6.
    networkId string
    ID of the desired network to create subnet in.
    connectToNetworkRouter boolean
    True if the network's router should get a gateway in this subnet. Must be explicitly 'false' when gateway_ip is null. Default true.
    dnsNameservers string[]
    List of strings contains DNS addresses, e.g. 95.85.95.85.
    enableDhcp boolean
    Enable DHCP for this subnet.
    gatewayIp string
    Desired IP address of the subnet's gateway. Use disable value to disable gateway ip.
    hostRoutes SubnetHostRoute[]
    metadataMap {[key: string]: string}
    Metadata map to apply to the subnet.
    name string
    Name of the subnet.
    projectId number
    ID of the desired project to create subnet in. Alternative for project_name. One of them should be specified.
    projectName string
    Name of the desired project to create subnet in. Alternative for project_id. One of them should be specified.
    regionId number
    ID of the desired region to create subnet in. Alternative for region_name. One of them should be specified.
    regionName string
    Name of the desired region to create subnet in. Alternative for region_id. One of them should be specified.
    subnetId string
    The ID of this resource.
    timeouts SubnetTimeouts
    cidr str
    Classless Inter-Domain Routing, can be IPv4 or IPv6.
    network_id str
    ID of the desired network to create subnet in.
    connect_to_network_router bool
    True if the network's router should get a gateway in this subnet. Must be explicitly 'false' when gateway_ip is null. Default true.
    dns_nameservers Sequence[str]
    List of strings contains DNS addresses, e.g. 95.85.95.85.
    enable_dhcp bool
    Enable DHCP for this subnet.
    gateway_ip str
    Desired IP address of the subnet's gateway. Use disable value to disable gateway ip.
    host_routes Sequence[SubnetHostRouteArgs]
    metadata_map Mapping[str, str]
    Metadata map to apply to the subnet.
    name str
    Name of the subnet.
    project_id float
    ID of the desired project to create subnet in. Alternative for project_name. One of them should be specified.
    project_name str
    Name of the desired project to create subnet in. Alternative for project_id. One of them should be specified.
    region_id float
    ID of the desired region to create subnet in. Alternative for region_name. One of them should be specified.
    region_name str
    Name of the desired region to create subnet in. Alternative for region_id. One of them should be specified.
    subnet_id str
    The ID of this resource.
    timeouts SubnetTimeoutsArgs
    cidr String
    Classless Inter-Domain Routing, can be IPv4 or IPv6.
    networkId String
    ID of the desired network to create subnet in.
    connectToNetworkRouter Boolean
    True if the network's router should get a gateway in this subnet. Must be explicitly 'false' when gateway_ip is null. Default true.
    dnsNameservers List<String>
    List of strings contains DNS addresses, e.g. 95.85.95.85.
    enableDhcp Boolean
    Enable DHCP for this subnet.
    gatewayIp String
    Desired IP address of the subnet's gateway. Use disable value to disable gateway ip.
    hostRoutes List<Property Map>
    metadataMap Map<String>
    Metadata map to apply to the subnet.
    name String
    Name of the subnet.
    projectId Number
    ID of the desired project to create subnet in. Alternative for project_name. One of them should be specified.
    projectName String
    Name of the desired project to create subnet in. Alternative for project_id. One of them should be specified.
    regionId Number
    ID of the desired region to create subnet in. Alternative for region_name. One of them should be specified.
    regionName String
    Name of the desired region to create subnet in. Alternative for region_id. One of them should be specified.
    subnetId String
    The ID of this resource.
    timeouts Property Map

    Outputs

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

    Id string
    The provider-assigned unique ID for this managed resource.
    LastUpdated string
    Datetime when subnet was updated at the last time.
    MetadataReadOnlies List<SubnetMetadataReadOnly>
    List of metadata items.
    Id string
    The provider-assigned unique ID for this managed resource.
    LastUpdated string
    Datetime when subnet was updated at the last time.
    MetadataReadOnlies []SubnetMetadataReadOnly
    List of metadata items.
    id String
    The provider-assigned unique ID for this managed resource.
    lastUpdated String
    Datetime when subnet was updated at the last time.
    metadataReadOnlies List<SubnetMetadataReadOnly>
    List of metadata items.
    id string
    The provider-assigned unique ID for this managed resource.
    lastUpdated string
    Datetime when subnet was updated at the last time.
    metadataReadOnlies SubnetMetadataReadOnly[]
    List of metadata items.
    id str
    The provider-assigned unique ID for this managed resource.
    last_updated str
    Datetime when subnet was updated at the last time.
    metadata_read_onlies Sequence[SubnetMetadataReadOnly]
    List of metadata items.
    id String
    The provider-assigned unique ID for this managed resource.
    lastUpdated String
    Datetime when subnet was updated at the last time.
    metadataReadOnlies List<Property Map>
    List of metadata items.

    Look up Existing Subnet Resource

    Get an existing Subnet 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?: SubnetState, opts?: CustomResourceOptions): Subnet
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            cidr: Optional[str] = None,
            connect_to_network_router: Optional[bool] = None,
            dns_nameservers: Optional[Sequence[str]] = None,
            enable_dhcp: Optional[bool] = None,
            gateway_ip: Optional[str] = None,
            host_routes: Optional[Sequence[SubnetHostRouteArgs]] = None,
            last_updated: Optional[str] = None,
            metadata_map: Optional[Mapping[str, str]] = None,
            metadata_read_onlies: Optional[Sequence[SubnetMetadataReadOnlyArgs]] = None,
            name: Optional[str] = None,
            network_id: Optional[str] = None,
            project_id: Optional[float] = None,
            project_name: Optional[str] = None,
            region_id: Optional[float] = None,
            region_name: Optional[str] = None,
            subnet_id: Optional[str] = None,
            timeouts: Optional[SubnetTimeoutsArgs] = None) -> Subnet
    func GetSubnet(ctx *Context, name string, id IDInput, state *SubnetState, opts ...ResourceOption) (*Subnet, error)
    public static Subnet Get(string name, Input<string> id, SubnetState? state, CustomResourceOptions? opts = null)
    public static Subnet get(String name, Output<String> id, SubnetState state, CustomResourceOptions options)
    resources:  _:    type: gcore:Subnet    get:      id: ${id}
    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.
    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:
    Cidr string
    Classless Inter-Domain Routing, can be IPv4 or IPv6.
    ConnectToNetworkRouter bool
    True if the network's router should get a gateway in this subnet. Must be explicitly 'false' when gateway_ip is null. Default true.
    DnsNameservers List<string>
    List of strings contains DNS addresses, e.g. 95.85.95.85.
    EnableDhcp bool
    Enable DHCP for this subnet.
    GatewayIp string
    Desired IP address of the subnet's gateway. Use disable value to disable gateway ip.
    HostRoutes List<SubnetHostRoute>
    LastUpdated string
    Datetime when subnet was updated at the last time.
    MetadataMap Dictionary<string, string>
    Metadata map to apply to the subnet.
    MetadataReadOnlies List<SubnetMetadataReadOnly>
    List of metadata items.
    Name string
    Name of the subnet.
    NetworkId string
    ID of the desired network to create subnet in.
    ProjectId double
    ID of the desired project to create subnet in. Alternative for project_name. One of them should be specified.
    ProjectName string
    Name of the desired project to create subnet in. Alternative for project_id. One of them should be specified.
    RegionId double
    ID of the desired region to create subnet in. Alternative for region_name. One of them should be specified.
    RegionName string
    Name of the desired region to create subnet in. Alternative for region_id. One of them should be specified.
    SubnetId string
    The ID of this resource.
    Timeouts SubnetTimeouts
    Cidr string
    Classless Inter-Domain Routing, can be IPv4 or IPv6.
    ConnectToNetworkRouter bool
    True if the network's router should get a gateway in this subnet. Must be explicitly 'false' when gateway_ip is null. Default true.
    DnsNameservers []string
    List of strings contains DNS addresses, e.g. 95.85.95.85.
    EnableDhcp bool
    Enable DHCP for this subnet.
    GatewayIp string
    Desired IP address of the subnet's gateway. Use disable value to disable gateway ip.
    HostRoutes []SubnetHostRouteArgs
    LastUpdated string
    Datetime when subnet was updated at the last time.
    MetadataMap map[string]string
    Metadata map to apply to the subnet.
    MetadataReadOnlies []SubnetMetadataReadOnlyArgs
    List of metadata items.
    Name string
    Name of the subnet.
    NetworkId string
    ID of the desired network to create subnet in.
    ProjectId float64
    ID of the desired project to create subnet in. Alternative for project_name. One of them should be specified.
    ProjectName string
    Name of the desired project to create subnet in. Alternative for project_id. One of them should be specified.
    RegionId float64
    ID of the desired region to create subnet in. Alternative for region_name. One of them should be specified.
    RegionName string
    Name of the desired region to create subnet in. Alternative for region_id. One of them should be specified.
    SubnetId string
    The ID of this resource.
    Timeouts SubnetTimeoutsArgs
    cidr String
    Classless Inter-Domain Routing, can be IPv4 or IPv6.
    connectToNetworkRouter Boolean
    True if the network's router should get a gateway in this subnet. Must be explicitly 'false' when gateway_ip is null. Default true.
    dnsNameservers List<String>
    List of strings contains DNS addresses, e.g. 95.85.95.85.
    enableDhcp Boolean
    Enable DHCP for this subnet.
    gatewayIp String
    Desired IP address of the subnet's gateway. Use disable value to disable gateway ip.
    hostRoutes List<SubnetHostRoute>
    lastUpdated String
    Datetime when subnet was updated at the last time.
    metadataMap Map<String,String>
    Metadata map to apply to the subnet.
    metadataReadOnlies List<SubnetMetadataReadOnly>
    List of metadata items.
    name String
    Name of the subnet.
    networkId String
    ID of the desired network to create subnet in.
    projectId Double
    ID of the desired project to create subnet in. Alternative for project_name. One of them should be specified.
    projectName String
    Name of the desired project to create subnet in. Alternative for project_id. One of them should be specified.
    regionId Double
    ID of the desired region to create subnet in. Alternative for region_name. One of them should be specified.
    regionName String
    Name of the desired region to create subnet in. Alternative for region_id. One of them should be specified.
    subnetId String
    The ID of this resource.
    timeouts SubnetTimeouts
    cidr string
    Classless Inter-Domain Routing, can be IPv4 or IPv6.
    connectToNetworkRouter boolean
    True if the network's router should get a gateway in this subnet. Must be explicitly 'false' when gateway_ip is null. Default true.
    dnsNameservers string[]
    List of strings contains DNS addresses, e.g. 95.85.95.85.
    enableDhcp boolean
    Enable DHCP for this subnet.
    gatewayIp string
    Desired IP address of the subnet's gateway. Use disable value to disable gateway ip.
    hostRoutes SubnetHostRoute[]
    lastUpdated string
    Datetime when subnet was updated at the last time.
    metadataMap {[key: string]: string}
    Metadata map to apply to the subnet.
    metadataReadOnlies SubnetMetadataReadOnly[]
    List of metadata items.
    name string
    Name of the subnet.
    networkId string
    ID of the desired network to create subnet in.
    projectId number
    ID of the desired project to create subnet in. Alternative for project_name. One of them should be specified.
    projectName string
    Name of the desired project to create subnet in. Alternative for project_id. One of them should be specified.
    regionId number
    ID of the desired region to create subnet in. Alternative for region_name. One of them should be specified.
    regionName string
    Name of the desired region to create subnet in. Alternative for region_id. One of them should be specified.
    subnetId string
    The ID of this resource.
    timeouts SubnetTimeouts
    cidr str
    Classless Inter-Domain Routing, can be IPv4 or IPv6.
    connect_to_network_router bool
    True if the network's router should get a gateway in this subnet. Must be explicitly 'false' when gateway_ip is null. Default true.
    dns_nameservers Sequence[str]
    List of strings contains DNS addresses, e.g. 95.85.95.85.
    enable_dhcp bool
    Enable DHCP for this subnet.
    gateway_ip str
    Desired IP address of the subnet's gateway. Use disable value to disable gateway ip.
    host_routes Sequence[SubnetHostRouteArgs]
    last_updated str
    Datetime when subnet was updated at the last time.
    metadata_map Mapping[str, str]
    Metadata map to apply to the subnet.
    metadata_read_onlies Sequence[SubnetMetadataReadOnlyArgs]
    List of metadata items.
    name str
    Name of the subnet.
    network_id str
    ID of the desired network to create subnet in.
    project_id float
    ID of the desired project to create subnet in. Alternative for project_name. One of them should be specified.
    project_name str
    Name of the desired project to create subnet in. Alternative for project_id. One of them should be specified.
    region_id float
    ID of the desired region to create subnet in. Alternative for region_name. One of them should be specified.
    region_name str
    Name of the desired region to create subnet in. Alternative for region_id. One of them should be specified.
    subnet_id str
    The ID of this resource.
    timeouts SubnetTimeoutsArgs
    cidr String
    Classless Inter-Domain Routing, can be IPv4 or IPv6.
    connectToNetworkRouter Boolean
    True if the network's router should get a gateway in this subnet. Must be explicitly 'false' when gateway_ip is null. Default true.
    dnsNameservers List<String>
    List of strings contains DNS addresses, e.g. 95.85.95.85.
    enableDhcp Boolean
    Enable DHCP for this subnet.
    gatewayIp String
    Desired IP address of the subnet's gateway. Use disable value to disable gateway ip.
    hostRoutes List<Property Map>
    lastUpdated String
    Datetime when subnet was updated at the last time.
    metadataMap Map<String>
    Metadata map to apply to the subnet.
    metadataReadOnlies List<Property Map>
    List of metadata items.
    name String
    Name of the subnet.
    networkId String
    ID of the desired network to create subnet in.
    projectId Number
    ID of the desired project to create subnet in. Alternative for project_name. One of them should be specified.
    projectName String
    Name of the desired project to create subnet in. Alternative for project_id. One of them should be specified.
    regionId Number
    ID of the desired region to create subnet in. Alternative for region_name. One of them should be specified.
    regionName String
    Name of the desired region to create subnet in. Alternative for region_id. One of them should be specified.
    subnetId String
    The ID of this resource.
    timeouts Property Map

    Supporting Types

    SubnetHostRoute, SubnetHostRouteArgs

    Destination string
    Classless Inter-Domain Routing, can be IPv4 or IPv6.
    Nexthop string
    IPv4 address to forward traffic to if it's destination IP matches 'destination' CIDR
    Destination string
    Classless Inter-Domain Routing, can be IPv4 or IPv6.
    Nexthop string
    IPv4 address to forward traffic to if it's destination IP matches 'destination' CIDR
    destination String
    Classless Inter-Domain Routing, can be IPv4 or IPv6.
    nexthop String
    IPv4 address to forward traffic to if it's destination IP matches 'destination' CIDR
    destination string
    Classless Inter-Domain Routing, can be IPv4 or IPv6.
    nexthop string
    IPv4 address to forward traffic to if it's destination IP matches 'destination' CIDR
    destination str
    Classless Inter-Domain Routing, can be IPv4 or IPv6.
    nexthop str
    IPv4 address to forward traffic to if it's destination IP matches 'destination' CIDR
    destination String
    Classless Inter-Domain Routing, can be IPv4 or IPv6.
    nexthop String
    IPv4 address to forward traffic to if it's destination IP matches 'destination' CIDR

    SubnetMetadataReadOnly, SubnetMetadataReadOnlyArgs

    Key string
    ReadOnly bool
    Value string
    Key string
    ReadOnly bool
    Value string
    key String
    readOnly Boolean
    value String
    key string
    readOnly boolean
    value string
    key str
    read_only bool
    value str
    key String
    readOnly Boolean
    value String

    SubnetTimeouts, SubnetTimeoutsArgs

    Create string
    Delete string
    Create string
    Delete string
    create String
    delete String
    create string
    delete string
    create str
    delete str
    create String
    delete String

    Import

    import using <project_id>:<region_id>:<subnet_id> format

    $ pulumi import gcore:index/subnet:Subnet subnet1 1:6:447d2959-8ae0-4ca0-8d47-9f050a3637d7
    

    To learn more about importing existing cloud resources, see Importing resources.

    Package Details

    Repository
    gcore g-core/terraform-provider-gcore
    License
    Notes
    This Pulumi package is based on the gcore Terraform Provider.
    gcore logo
    gcore 0.22.0 published on Wednesday, Apr 30, 2025 by g-core