1. Packages
  2. Gcore Provider
  3. API Docs
  4. getSubnet
gcore 0.20.0 published on Tuesday, Apr 22, 2025 by g-core

gcore.getSubnet

Explore with Pulumi AI

gcore 0.20.0 published on Tuesday, Apr 22, 2025 by g-core

Example Usage

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

const pr = gcore.getProject({
    name: "test",
});
const rg = gcore.getRegion({
    name: "ED-10 Preprod",
});
const tsn = Promise.all([rg, pr]).then(([rg, pr]) => gcore.getSubnet({
    name: "subtest",
    regionId: rg.id,
    projectId: pr.id,
}));
export const view = tsn;
Copy
import pulumi
import pulumi_gcore as gcore

pr = gcore.get_project(name="test")
rg = gcore.get_region(name="ED-10 Preprod")
tsn = gcore.get_subnet(name="subtest",
    region_id=rg.id,
    project_id=pr.id)
pulumi.export("view", tsn)
Copy
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 {
		pr, err := gcore.GetProject(ctx, &gcore.GetProjectArgs{
			Name: "test",
		}, nil)
		if err != nil {
			return err
		}
		rg, err := gcore.GetRegion(ctx, &gcore.GetRegionArgs{
			Name: "ED-10 Preprod",
		}, nil)
		if err != nil {
			return err
		}
		tsn, err := gcore.LookupSubnet(ctx, &gcore.LookupSubnetArgs{
			Name:      "subtest",
			RegionId:  pulumi.Float64Ref(rg.Id),
			ProjectId: pulumi.Float64Ref(pr.Id),
		}, nil)
		if err != nil {
			return err
		}
		ctx.Export("view", tsn)
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcore = Pulumi.Gcore;

return await Deployment.RunAsync(() => 
{
    var pr = Gcore.GetProject.Invoke(new()
    {
        Name = "test",
    });

    var rg = Gcore.GetRegion.Invoke(new()
    {
        Name = "ED-10 Preprod",
    });

    var tsn = Gcore.GetSubnet.Invoke(new()
    {
        Name = "subtest",
        RegionId = rg.Apply(getRegionResult => getRegionResult.Id),
        ProjectId = pr.Apply(getProjectResult => getProjectResult.Id),
    });

    return new Dictionary<string, object?>
    {
        ["view"] = tsn,
    };
});
Copy
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.inputs.GetSubnetArgs;
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 pr = GcoreFunctions.getProject(GetProjectArgs.builder()
            .name("test")
            .build());

        final var rg = GcoreFunctions.getRegion(GetRegionArgs.builder()
            .name("ED-10 Preprod")
            .build());

        final var tsn = GcoreFunctions.getSubnet(GetSubnetArgs.builder()
            .name("subtest")
            .regionId(rg.applyValue(getRegionResult -> getRegionResult.id()))
            .projectId(pr.applyValue(getProjectResult -> getProjectResult.id()))
            .build());

        ctx.export("view", tsn.applyValue(getSubnetResult -> getSubnetResult));
    }
}
Copy
variables:
  pr:
    fn::invoke:
      function: gcore:getProject
      arguments:
        name: test
  rg:
    fn::invoke:
      function: gcore:getRegion
      arguments:
        name: ED-10 Preprod
  tsn:
    fn::invoke:
      function: gcore:getSubnet
      arguments:
        name: subtest
        regionId: ${rg.id}
        projectId: ${pr.id}
outputs:
  view: ${tsn}
Copy

Using getSubnet

Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

function getSubnet(args: GetSubnetArgs, opts?: InvokeOptions): Promise<GetSubnetResult>
function getSubnetOutput(args: GetSubnetOutputArgs, opts?: InvokeOptions): Output<GetSubnetResult>
Copy
def get_subnet(id: Optional[str] = None,
               metadata_k: Optional[str] = None,
               metadata_kv: Optional[Mapping[str, str]] = 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,
               opts: Optional[InvokeOptions] = None) -> GetSubnetResult
def get_subnet_output(id: Optional[pulumi.Input[str]] = None,
               metadata_k: Optional[pulumi.Input[str]] = None,
               metadata_kv: Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]] = None,
               name: Optional[pulumi.Input[str]] = None,
               network_id: Optional[pulumi.Input[str]] = None,
               project_id: Optional[pulumi.Input[float]] = None,
               project_name: Optional[pulumi.Input[str]] = None,
               region_id: Optional[pulumi.Input[float]] = None,
               region_name: Optional[pulumi.Input[str]] = None,
               opts: Optional[InvokeOptions] = None) -> Output[GetSubnetResult]
Copy
func LookupSubnet(ctx *Context, args *LookupSubnetArgs, opts ...InvokeOption) (*LookupSubnetResult, error)
func LookupSubnetOutput(ctx *Context, args *LookupSubnetOutputArgs, opts ...InvokeOption) LookupSubnetResultOutput
Copy

> Note: This function is named LookupSubnet in the Go SDK.

public static class GetSubnet 
{
    public static Task<GetSubnetResult> InvokeAsync(GetSubnetArgs args, InvokeOptions? opts = null)
    public static Output<GetSubnetResult> Invoke(GetSubnetInvokeArgs args, InvokeOptions? opts = null)
}
Copy
public static CompletableFuture<GetSubnetResult> getSubnet(GetSubnetArgs args, InvokeOptions options)
public static Output<GetSubnetResult> getSubnet(GetSubnetArgs args, InvokeOptions options)
Copy
fn::invoke:
  function: gcore:index/getSubnet:getSubnet
  arguments:
    # arguments dictionary
Copy

The following arguments are supported:

Name This property is required. string
Id string
The ID of this resource.
MetadataK string
MetadataKv Dictionary<string, string>
NetworkId string
ProjectId double
ProjectName string
RegionId double
RegionName string
Name This property is required. string
Id string
The ID of this resource.
MetadataK string
MetadataKv map[string]string
NetworkId string
ProjectId float64
ProjectName string
RegionId float64
RegionName string
name This property is required. String
id String
The ID of this resource.
metadataK String
metadataKv Map<String,String>
networkId String
projectId Double
projectName String
regionId Double
regionName String
name This property is required. string
id string
The ID of this resource.
metadataK string
metadataKv {[key: string]: string}
networkId string
projectId number
projectName string
regionId number
regionName string
name This property is required. str
id str
The ID of this resource.
metadata_k str
metadata_kv Mapping[str, str]
network_id str
project_id float
project_name str
region_id float
region_name str
name This property is required. String
id String
The ID of this resource.
metadataK String
metadataKv Map<String>
networkId String
projectId Number
projectName String
regionId Number
regionName String

getSubnet Result

The following output properties are available:

Cidr string
ConnectToNetworkRouter bool
DnsNameservers List<string>
EnableDhcp bool
GatewayIp string
HostRoutes List<GetSubnetHostRoute>
Id string
The ID of this resource.
MetadataReadOnlies List<GetSubnetMetadataReadOnly>
Name string
NetworkId string
MetadataK string
MetadataKv Dictionary<string, string>
ProjectId double
ProjectName string
RegionId double
RegionName string
cidr String
connectToNetworkRouter Boolean
dnsNameservers List<String>
enableDhcp Boolean
gatewayIp String
hostRoutes List<GetSubnetHostRoute>
id String
The ID of this resource.
metadataReadOnlies List<GetSubnetMetadataReadOnly>
name String
networkId String
metadataK String
metadataKv Map<String,String>
projectId Double
projectName String
regionId Double
regionName String
cidr string
connectToNetworkRouter boolean
dnsNameservers string[]
enableDhcp boolean
gatewayIp string
hostRoutes GetSubnetHostRoute[]
id string
The ID of this resource.
metadataReadOnlies GetSubnetMetadataReadOnly[]
name string
networkId string
metadataK string
metadataKv {[key: string]: string}
projectId number
projectName string
regionId number
regionName string
cidr String
connectToNetworkRouter Boolean
dnsNameservers List<String>
enableDhcp Boolean
gatewayIp String
hostRoutes List<Property Map>
id String
The ID of this resource.
metadataReadOnlies List<Property Map>
name String
networkId String
metadataK String
metadataKv Map<String>
projectId Number
projectName String
regionId Number
regionName String

Supporting Types

GetSubnetHostRoute

Destination This property is required. string
Nexthop This property is required. string
Destination This property is required. string
Nexthop This property is required. string
destination This property is required. String
nexthop This property is required. String
destination This property is required. string
nexthop This property is required. string
destination This property is required. str
nexthop This property is required. str
destination This property is required. String
nexthop This property is required. String

GetSubnetMetadataReadOnly

Key This property is required. string
ReadOnly This property is required. bool
Value This property is required. string
Key This property is required. string
ReadOnly This property is required. bool
Value This property is required. string
key This property is required. String
readOnly This property is required. Boolean
value This property is required. String
key This property is required. string
readOnly This property is required. boolean
value This property is required. string
key This property is required. str
read_only This property is required. bool
value This property is required. str
key This property is required. String
readOnly This property is required. Boolean
value This property is required. String

Package Details

Repository
gcore g-core/terraform-provider-gcore
License
Notes
This Pulumi package is based on the gcore Terraform Provider.
gcore 0.20.0 published on Tuesday, Apr 22, 2025 by g-core