1. Packages
  2. Ucloud Provider
  3. API Docs
  4. getSubnets
ucloud 1.39.1 published on Monday, Apr 14, 2025 by ucloud

ucloud.getSubnets

Explore with Pulumi AI

ucloud logo
ucloud 1.39.1 published on Monday, Apr 14, 2025 by ucloud

    This data source provides a list of Subnet resources according to their Subnet ID, name and the VPC they belong to.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as ucloud from "@pulumi/ucloud";
    
    const example = ucloud.getSubnets({
        vpcId: "uvnet-xxx",
    });
    export const first = example.then(example => example.subnets?.[0]?.id);
    
    import pulumi
    import pulumi_ucloud as ucloud
    
    example = ucloud.get_subnets(vpc_id="uvnet-xxx")
    pulumi.export("first", example.subnets[0].id)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-terraform-provider/sdks/go/ucloud/ucloud"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		example, err := ucloud.GetSubnets(ctx, &ucloud.GetSubnetsArgs{
    			VpcId: pulumi.StringRef("uvnet-xxx"),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		ctx.Export("first", example.Subnets[0].Id)
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Ucloud = Pulumi.Ucloud;
    
    return await Deployment.RunAsync(() => 
    {
        var example = Ucloud.GetSubnets.Invoke(new()
        {
            VpcId = "uvnet-xxx",
        });
    
        return new Dictionary<string, object?>
        {
            ["first"] = example.Apply(getSubnetsResult => getSubnetsResult.Subnets[0]?.Id),
        };
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.ucloud.UcloudFunctions;
    import com.pulumi.ucloud.inputs.GetSubnetsArgs;
    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 example = UcloudFunctions.getSubnets(GetSubnetsArgs.builder()
                .vpcId("uvnet-xxx")
                .build());
    
            ctx.export("first", example.applyValue(getSubnetsResult -> getSubnetsResult.subnets()[0].id()));
        }
    }
    
    variables:
      example:
        fn::invoke:
          function: ucloud:getSubnets
          arguments:
            vpcId: uvnet-xxx
    outputs:
      first: ${example.subnets[0].id}
    

    Using getSubnets

    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 getSubnets(args: GetSubnetsArgs, opts?: InvokeOptions): Promise<GetSubnetsResult>
    function getSubnetsOutput(args: GetSubnetsOutputArgs, opts?: InvokeOptions): Output<GetSubnetsResult>
    def get_subnets(id: Optional[str] = None,
                    ids: Optional[Sequence[str]] = None,
                    name_regex: Optional[str] = None,
                    output_file: Optional[str] = None,
                    tag: Optional[str] = None,
                    vpc_id: Optional[str] = None,
                    opts: Optional[InvokeOptions] = None) -> GetSubnetsResult
    def get_subnets_output(id: Optional[pulumi.Input[str]] = None,
                    ids: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,
                    name_regex: Optional[pulumi.Input[str]] = None,
                    output_file: Optional[pulumi.Input[str]] = None,
                    tag: Optional[pulumi.Input[str]] = None,
                    vpc_id: Optional[pulumi.Input[str]] = None,
                    opts: Optional[InvokeOptions] = None) -> Output[GetSubnetsResult]
    func GetSubnets(ctx *Context, args *GetSubnetsArgs, opts ...InvokeOption) (*GetSubnetsResult, error)
    func GetSubnetsOutput(ctx *Context, args *GetSubnetsOutputArgs, opts ...InvokeOption) GetSubnetsResultOutput

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

    public static class GetSubnets 
    {
        public static Task<GetSubnetsResult> InvokeAsync(GetSubnetsArgs args, InvokeOptions? opts = null)
        public static Output<GetSubnetsResult> Invoke(GetSubnetsInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetSubnetsResult> getSubnets(GetSubnetsArgs args, InvokeOptions options)
    public static Output<GetSubnetsResult> getSubnets(GetSubnetsArgs args, InvokeOptions options)
    
    fn::invoke:
      function: ucloud:index/getSubnets:getSubnets
      arguments:
        # arguments dictionary

    The following arguments are supported:

    Id string
    The ID of Subnet.
    Ids List<string>
    A list of Subnet IDs, all the Subnet resources belong to this region will be retrieved if the ID is [].
    NameRegex string
    A regex string to filter resulting Subnet resources by name.
    OutputFile string
    File name where to save data source results (after running pulumi preview).
    Tag string
    A tag assigned to Subnet.
    VpcId string
    The id of the VPC that the desired Subnet belongs to.
    Id string
    The ID of Subnet.
    Ids []string
    A list of Subnet IDs, all the Subnet resources belong to this region will be retrieved if the ID is [].
    NameRegex string
    A regex string to filter resulting Subnet resources by name.
    OutputFile string
    File name where to save data source results (after running pulumi preview).
    Tag string
    A tag assigned to Subnet.
    VpcId string
    The id of the VPC that the desired Subnet belongs to.
    id String
    The ID of Subnet.
    ids List<String>
    A list of Subnet IDs, all the Subnet resources belong to this region will be retrieved if the ID is [].
    nameRegex String
    A regex string to filter resulting Subnet resources by name.
    outputFile String
    File name where to save data source results (after running pulumi preview).
    tag String
    A tag assigned to Subnet.
    vpcId String
    The id of the VPC that the desired Subnet belongs to.
    id string
    The ID of Subnet.
    ids string[]
    A list of Subnet IDs, all the Subnet resources belong to this region will be retrieved if the ID is [].
    nameRegex string
    A regex string to filter resulting Subnet resources by name.
    outputFile string
    File name where to save data source results (after running pulumi preview).
    tag string
    A tag assigned to Subnet.
    vpcId string
    The id of the VPC that the desired Subnet belongs to.
    id str
    The ID of Subnet.
    ids Sequence[str]
    A list of Subnet IDs, all the Subnet resources belong to this region will be retrieved if the ID is [].
    name_regex str
    A regex string to filter resulting Subnet resources by name.
    output_file str
    File name where to save data source results (after running pulumi preview).
    tag str
    A tag assigned to Subnet.
    vpc_id str
    The id of the VPC that the desired Subnet belongs to.
    id String
    The ID of Subnet.
    ids List<String>
    A list of Subnet IDs, all the Subnet resources belong to this region will be retrieved if the ID is [].
    nameRegex String
    A regex string to filter resulting Subnet resources by name.
    outputFile String
    File name where to save data source results (after running pulumi preview).
    tag String
    A tag assigned to Subnet.
    vpcId String
    The id of the VPC that the desired Subnet belongs to.

    getSubnets Result

    The following output properties are available:

    Id string
    The ID of Subnet.
    Ids List<string>
    Subnets List<GetSubnetsSubnet>
    It is a nested type which documented below.
    TotalCount double
    Total number of Subnet resources that satisfy the condition.
    NameRegex string
    OutputFile string
    Tag string
    A tag assigned to Subnet.
    VpcId string
    The id of the VPC that the desired Subnet belongs to.
    Id string
    The ID of Subnet.
    Ids []string
    Subnets []GetSubnetsSubnet
    It is a nested type which documented below.
    TotalCount float64
    Total number of Subnet resources that satisfy the condition.
    NameRegex string
    OutputFile string
    Tag string
    A tag assigned to Subnet.
    VpcId string
    The id of the VPC that the desired Subnet belongs to.
    id String
    The ID of Subnet.
    ids List<String>
    subnets List<GetSubnetsSubnet>
    It is a nested type which documented below.
    totalCount Double
    Total number of Subnet resources that satisfy the condition.
    nameRegex String
    outputFile String
    tag String
    A tag assigned to Subnet.
    vpcId String
    The id of the VPC that the desired Subnet belongs to.
    id string
    The ID of Subnet.
    ids string[]
    subnets GetSubnetsSubnet[]
    It is a nested type which documented below.
    totalCount number
    Total number of Subnet resources that satisfy the condition.
    nameRegex string
    outputFile string
    tag string
    A tag assigned to Subnet.
    vpcId string
    The id of the VPC that the desired Subnet belongs to.
    id str
    The ID of Subnet.
    ids Sequence[str]
    subnets Sequence[GetSubnetsSubnet]
    It is a nested type which documented below.
    total_count float
    Total number of Subnet resources that satisfy the condition.
    name_regex str
    output_file str
    tag str
    A tag assigned to Subnet.
    vpc_id str
    The id of the VPC that the desired Subnet belongs to.
    id String
    The ID of Subnet.
    ids List<String>
    subnets List<Property Map>
    It is a nested type which documented below.
    totalCount Number
    Total number of Subnet resources that satisfy the condition.
    nameRegex String
    outputFile String
    tag String
    A tag assigned to Subnet.
    vpcId String
    The id of the VPC that the desired Subnet belongs to.

    Supporting Types

    GetSubnetsSubnet

    CidrBlock string
    The cidr block of the desired Subnet.
    CreateTime string
    The time of creation of Subnet, formatted in RFC3339 time string.
    Id string
    The ID of Subnet.
    Name string
    The name of Subnet.
    Remark string
    The remark of the Subnet.
    Tag string
    A tag assigned to Subnet.
    VpcId string
    The id of the VPC that the desired Subnet belongs to.
    CidrBlock string
    The cidr block of the desired Subnet.
    CreateTime string
    The time of creation of Subnet, formatted in RFC3339 time string.
    Id string
    The ID of Subnet.
    Name string
    The name of Subnet.
    Remark string
    The remark of the Subnet.
    Tag string
    A tag assigned to Subnet.
    VpcId string
    The id of the VPC that the desired Subnet belongs to.
    cidrBlock String
    The cidr block of the desired Subnet.
    createTime String
    The time of creation of Subnet, formatted in RFC3339 time string.
    id String
    The ID of Subnet.
    name String
    The name of Subnet.
    remark String
    The remark of the Subnet.
    tag String
    A tag assigned to Subnet.
    vpcId String
    The id of the VPC that the desired Subnet belongs to.
    cidrBlock string
    The cidr block of the desired Subnet.
    createTime string
    The time of creation of Subnet, formatted in RFC3339 time string.
    id string
    The ID of Subnet.
    name string
    The name of Subnet.
    remark string
    The remark of the Subnet.
    tag string
    A tag assigned to Subnet.
    vpcId string
    The id of the VPC that the desired Subnet belongs to.
    cidr_block str
    The cidr block of the desired Subnet.
    create_time str
    The time of creation of Subnet, formatted in RFC3339 time string.
    id str
    The ID of Subnet.
    name str
    The name of Subnet.
    remark str
    The remark of the Subnet.
    tag str
    A tag assigned to Subnet.
    vpc_id str
    The id of the VPC that the desired Subnet belongs to.
    cidrBlock String
    The cidr block of the desired Subnet.
    createTime String
    The time of creation of Subnet, formatted in RFC3339 time string.
    id String
    The ID of Subnet.
    name String
    The name of Subnet.
    remark String
    The remark of the Subnet.
    tag String
    A tag assigned to Subnet.
    vpcId String
    The id of the VPC that the desired Subnet belongs to.

    Package Details

    Repository
    ucloud ucloud/terraform-provider-ucloud
    License
    Notes
    This Pulumi package is based on the ucloud Terraform Provider.
    ucloud logo
    ucloud 1.39.1 published on Monday, Apr 14, 2025 by ucloud