gcorelabs.Subnet
Explore with Pulumi AI
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
import * as pulumi from "@pulumi/pulumi";
import * as gcore from "@pulumi/gcore";
const network = new gcore.index.Gcore_network("network", {
name: "network_example",
mtu: 1450,
type: "vxlan",
regionId: 1,
projectId: 1,
});
const subnet = new gcore.index.Gcore_subnet("subnet", {
name: "subnet_example",
cidr: "192.168.10.0/24",
networkId: 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",
regionId: 1,
projectId: 1,
});
import pulumi
import pulumi_gcore as gcore
network = gcore.index.Gcore_network("network",
name=network_example,
mtu=1450,
type=vxlan,
region_id=1,
project_id=1)
subnet = gcore.index.Gcore_subnet("subnet",
name=subnet_example,
cidr=192.168.10.0/24,
network_id=network.id,
dns_nameservers=var.dns_nameservers,
dynamic=[{
iterator: hr,
forEach: var.host_routes,
content: [{
destination: hr.value.destination,
nexthop: hr.value.nexthop,
}],
}],
gateway_ip=192.168.10.1,
region_id=1,
project_id=1)
package main
import (
"github.com/pulumi/pulumi-gcore/sdk/go/gcore"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
network, err := gcore.NewGcore_network(ctx, "network", &gcore.Gcore_networkArgs{
Name: "network_example",
Mtu: 1450,
Type: "vxlan",
RegionId: 1,
ProjectId: 1,
})
if err != nil {
return err
}
_, err = gcore.NewGcore_subnet(ctx, "subnet", &gcore.Gcore_subnetArgs{
Name: "subnet_example",
Cidr: "192.168.10.0/24",
NetworkId: network.Id,
DnsNameservers: _var.Dns_nameservers,
Dynamic: []map[string]interface{}{
map[string]interface{}{
"iterator": hr,
"forEach": _var.Host_routes,
"content": []map[string]interface{}{
map[string]interface{}{
"destination": hr.Value.Destination,
"nexthop": hr.Value.Nexthop,
},
},
},
},
GatewayIp: "192.168.10.1",
RegionId: 1,
ProjectId: 1,
})
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 network = new Gcore.Index.Gcore_network("network", new()
{
Name = "network_example",
Mtu = 1450,
Type = "vxlan",
RegionId = 1,
ProjectId = 1,
});
var subnet = new Gcore.Index.Gcore_subnet("subnet", new()
{
Name = "subnet_example",
Cidr = "192.168.10.0/24",
NetworkId = network.Id,
DnsNameservers = @var.Dns_nameservers,
Dynamic = new[]
{
{
{ "iterator", hr },
{ "forEach", @var.Host_routes },
{ "content", new[]
{
{
{ "destination", hr.Value.Destination },
{ "nexthop", hr.Value.Nexthop },
},
} },
},
},
GatewayIp = "192.168.10.1",
RegionId = 1,
ProjectId = 1,
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcore.gcore_network;
import com.pulumi.gcore.Gcore_networkArgs;
import com.pulumi.gcore.gcore_subnet;
import com.pulumi.gcore.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 network = new Gcore_network("network", Gcore_networkArgs.builder()
.name("network_example")
.mtu(1450)
.type("vxlan")
.regionId(1)
.projectId(1)
.build());
var subnet = new Gcore_subnet("subnet", Gcore_subnetArgs.builder()
.name("subnet_example")
.cidr("192.168.10.0/24")
.networkId(network.id())
.dnsNameservers(var_.dns_nameservers())
.dynamic(%!v(PANIC=Format method: runtime error: invalid memory address or nil pointer dereference))
.gatewayIp("192.168.10.1")
.regionId(1)
.projectId(1)
.build());
}
}
resources:
network:
type: gcore:gcore_network
properties:
name: network_example
mtu: 1450
type: vxlan
regionId: 1
projectId: 1
subnet:
type: gcore:gcore_subnet
properties:
name: subnet_example
cidr: 192.168.10.0/24
networkId: ${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
regionId: 1
projectId: 1
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,
enable_dhcp: Optional[bool] = None,
dns_nameservers: Optional[Sequence[str]] = None,
gateway_ip: Optional[str] = None,
host_routes: Optional[Sequence[SubnetHostRouteArgs]] = None,
last_updated: Optional[str] = None,
metadata_map: Optional[Mapping[str, 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)
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: gcorelabs: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 Gcorelabs.Subnet("subnetResource", new()
{
Cidr = "string",
NetworkId = "string",
EnableDhcp = false,
DnsNameservers = new[]
{
"string",
},
GatewayIp = "string",
HostRoutes = new[]
{
new Gcorelabs.Inputs.SubnetHostRouteArgs
{
Destination = "string",
Nexthop = "string",
},
},
LastUpdated = "string",
MetadataMap =
{
{ "string", "string" },
},
Name = "string",
ConnectToNetworkRouter = false,
ProjectId = 0,
ProjectName = "string",
RegionId = 0,
RegionName = "string",
SubnetId = "string",
});
example, err := gcorelabs.NewSubnet(ctx, "subnetResource", &gcorelabs.SubnetArgs{
Cidr: pulumi.String("string"),
NetworkId: pulumi.String("string"),
EnableDhcp: pulumi.Bool(false),
DnsNameservers: pulumi.StringArray{
pulumi.String("string"),
},
GatewayIp: pulumi.String("string"),
HostRoutes: gcorelabs.SubnetHostRouteArray{
&gcorelabs.SubnetHostRouteArgs{
Destination: pulumi.String("string"),
Nexthop: pulumi.String("string"),
},
},
LastUpdated: pulumi.String("string"),
MetadataMap: pulumi.StringMap{
"string": 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"),
})
var subnetResource = new Subnet("subnetResource", SubnetArgs.builder()
.cidr("string")
.networkId("string")
.enableDhcp(false)
.dnsNameservers("string")
.gatewayIp("string")
.hostRoutes(SubnetHostRouteArgs.builder()
.destination("string")
.nexthop("string")
.build())
.lastUpdated("string")
.metadataMap(Map.of("string", "string"))
.name("string")
.connectToNetworkRouter(false)
.projectId(0)
.projectName("string")
.regionId(0)
.regionName("string")
.subnetId("string")
.build());
subnet_resource = gcorelabs.Subnet("subnetResource",
cidr="string",
network_id="string",
enable_dhcp=False,
dns_nameservers=["string"],
gateway_ip="string",
host_routes=[{
"destination": "string",
"nexthop": "string",
}],
last_updated="string",
metadata_map={
"string": "string",
},
name="string",
connect_to_network_router=False,
project_id=0,
project_name="string",
region_id=0,
region_name="string",
subnet_id="string")
const subnetResource = new gcorelabs.Subnet("subnetResource", {
cidr: "string",
networkId: "string",
enableDhcp: false,
dnsNameservers: ["string"],
gatewayIp: "string",
hostRoutes: [{
destination: "string",
nexthop: "string",
}],
lastUpdated: "string",
metadataMap: {
string: "string",
},
name: "string",
connectToNetworkRouter: false,
projectId: 0,
projectName: "string",
regionId: 0,
regionName: "string",
subnetId: "string",
});
type: gcorelabs:Subnet
properties:
cidr: string
connectToNetworkRouter: false
dnsNameservers:
- string
enableDhcp: false
gatewayIp: string
hostRoutes:
- destination: string
nexthop: string
lastUpdated: string
metadataMap:
string: string
name: string
networkId: string
projectId: 0
projectName: string
regionId: 0
regionName: string
subnetId: 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
- Network
Id string - Connect
To boolNetwork Router - 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 List<string> - Enable
Dhcp bool - Gateway
Ip string - Host
Routes List<SubnetHost Route> - Last
Updated string - Metadata
Map Dictionary<string, string> - Name string
- Project
Id double - Project
Name string - Region
Id double - Region
Name string - Subnet
Id string - The ID of this resource.
- Cidr string
- Network
Id string - Connect
To boolNetwork Router - 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 []string - Enable
Dhcp bool - Gateway
Ip string - Host
Routes []SubnetHost Route Args - Last
Updated string - Metadata
Map map[string]string - Name string
- Project
Id float64 - Project
Name string - Region
Id float64 - Region
Name string - Subnet
Id string - The ID of this resource.
- cidr String
- network
Id String - connect
To BooleanNetwork Router - 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 List<String> - enable
Dhcp Boolean - gateway
Ip String - host
Routes List<SubnetHost Route> - last
Updated String - metadata
Map Map<String,String> - name String
- project
Id Double - project
Name String - region
Id Double - region
Name String - subnet
Id String - The ID of this resource.
- cidr string
- network
Id string - connect
To booleanNetwork Router - 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 string[] - enable
Dhcp boolean - gateway
Ip string - host
Routes SubnetHost Route[] - last
Updated string - metadata
Map {[key: string]: string} - name string
- project
Id number - project
Name string - region
Id number - region
Name string - subnet
Id string - The ID of this resource.
- cidr str
- network_
id str - connect_
to_ boolnetwork_ router - 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] - enable_
dhcp bool - gateway_
ip str - host_
routes Sequence[SubnetHost Route Args] - last_
updated str - metadata_
map Mapping[str, str] - name str
- project_
id float - project_
name str - region_
id float - region_
name str - subnet_
id str - The ID of this resource.
- cidr String
- network
Id String - connect
To BooleanNetwork Router - 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 List<String> - enable
Dhcp Boolean - gateway
Ip String - host
Routes List<Property Map> - last
Updated String - metadata
Map Map<String> - name String
- project
Id Number - project
Name String - region
Id Number - region
Name String - subnet
Id String - The ID of this resource.
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.
- Metadata
Read List<SubnetOnlies Metadata Read Only>
- Id string
- The provider-assigned unique ID for this managed resource.
- Metadata
Read []SubnetOnlies Metadata Read Only
- id String
- The provider-assigned unique ID for this managed resource.
- metadata
Read List<SubnetOnlies Metadata Read Only>
- id string
- The provider-assigned unique ID for this managed resource.
- metadata
Read SubnetOnlies Metadata Read Only[]
- id str
- The provider-assigned unique ID for this managed resource.
- metadata_
read_ Sequence[Subnetonlies Metadata Read Only]
- id String
- The provider-assigned unique ID for this managed resource.
- metadata
Read List<Property Map>Onlies
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) -> 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: gcorelabs: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.
- Cidr string
- Connect
To boolNetwork Router - 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 List<string> - Enable
Dhcp bool - Gateway
Ip string - Host
Routes List<SubnetHost Route> - Last
Updated string - Metadata
Map Dictionary<string, string> - Metadata
Read List<SubnetOnlies Metadata Read Only> - Name string
- Network
Id string - Project
Id double - Project
Name string - Region
Id double - Region
Name string - Subnet
Id string - The ID of this resource.
- Cidr string
- Connect
To boolNetwork Router - 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 []string - Enable
Dhcp bool - Gateway
Ip string - Host
Routes []SubnetHost Route Args - Last
Updated string - Metadata
Map map[string]string - Metadata
Read []SubnetOnlies Metadata Read Only Args - Name string
- Network
Id string - Project
Id float64 - Project
Name string - Region
Id float64 - Region
Name string - Subnet
Id string - The ID of this resource.
- cidr String
- connect
To BooleanNetwork Router - 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 List<String> - enable
Dhcp Boolean - gateway
Ip String - host
Routes List<SubnetHost Route> - last
Updated String - metadata
Map Map<String,String> - metadata
Read List<SubnetOnlies Metadata Read Only> - name String
- network
Id String - project
Id Double - project
Name String - region
Id Double - region
Name String - subnet
Id String - The ID of this resource.
- cidr string
- connect
To booleanNetwork Router - 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 string[] - enable
Dhcp boolean - gateway
Ip string - host
Routes SubnetHost Route[] - last
Updated string - metadata
Map {[key: string]: string} - metadata
Read SubnetOnlies Metadata Read Only[] - name string
- network
Id string - project
Id number - project
Name string - region
Id number - region
Name string - subnet
Id string - The ID of this resource.
- cidr str
- connect_
to_ boolnetwork_ router - 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] - enable_
dhcp bool - gateway_
ip str - host_
routes Sequence[SubnetHost Route Args] - last_
updated str - metadata_
map Mapping[str, str] - metadata_
read_ Sequence[Subnetonlies Metadata Read Only Args] - name str
- network_
id str - project_
id float - project_
name str - region_
id float - region_
name str - subnet_
id str - The ID of this resource.
- cidr String
- connect
To BooleanNetwork Router - 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 List<String> - enable
Dhcp Boolean - gateway
Ip String - host
Routes List<Property Map> - last
Updated String - metadata
Map Map<String> - metadata
Read List<Property Map>Onlies - name String
- network
Id String - project
Id Number - project
Name String - region
Id Number - region
Name String - subnet
Id String - The ID of this resource.
Supporting Types
SubnetHostRoute, SubnetHostRouteArgs
- Destination string
- Nexthop string
- IPv4 address to forward traffic to if it's destination IP matches 'destination' CIDR
- Destination string
- Nexthop string
- IPv4 address to forward traffic to if it's destination IP matches 'destination' CIDR
- destination String
- nexthop String
- IPv4 address to forward traffic to if it's destination IP matches 'destination' CIDR
- destination string
- nexthop string
- IPv4 address to forward traffic to if it's destination IP matches 'destination' CIDR
- destination str
- nexthop str
- IPv4 address to forward traffic to if it's destination IP matches 'destination' CIDR
- destination String
- nexthop String
- IPv4 address to forward traffic to if it's destination IP matches 'destination' CIDR
SubnetMetadataReadOnly, SubnetMetadataReadOnlyArgs
Import
import using <project_id>:<region_id>:<subnet_id> format
$ pulumi import gcorelabs: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
- gcorelabs g-core/terraform-provider-gcorelabs
- License
- Notes
- This Pulumi package is based on the
gcorelabs
Terraform Provider.