ucloud 1.39.1 published on Monday, Apr 14, 2025 by ucloud
ucloud.getSubnets
Explore with Pulumi AI
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
[]
. - Name
Regex string - A regex string to filter resulting Subnet resources by name.
- Output
File string - File name where to save data source results (after running
pulumi preview
). - Tag string
- A tag assigned to Subnet.
- Vpc
Id 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
[]
. - Name
Regex string - A regex string to filter resulting Subnet resources by name.
- Output
File string - File name where to save data source results (after running
pulumi preview
). - Tag string
- A tag assigned to Subnet.
- Vpc
Id 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
[]
. - name
Regex String - A regex string to filter resulting Subnet resources by name.
- output
File String - File name where to save data source results (after running
pulumi preview
). - tag String
- A tag assigned to Subnet.
- vpc
Id 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
[]
. - name
Regex string - A regex string to filter resulting Subnet resources by name.
- output
File string - File name where to save data source results (after running
pulumi preview
). - tag string
- A tag assigned to Subnet.
- vpc
Id 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
[]
. - name
Regex String - A regex string to filter resulting Subnet resources by name.
- output
File String - File name where to save data source results (after running
pulumi preview
). - tag String
- A tag assigned to Subnet.
- vpc
Id 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<Get
Subnets Subnet> - It is a nested type which documented below.
- Total
Count double - Total number of Subnet resources that satisfy the condition.
- Name
Regex string - Output
File string - Tag string
- A tag assigned to Subnet.
- Vpc
Id string - The id of the VPC that the desired Subnet belongs to.
- Id string
- The ID of Subnet.
- Ids []string
- Subnets
[]Get
Subnets Subnet - It is a nested type which documented below.
- Total
Count float64 - Total number of Subnet resources that satisfy the condition.
- Name
Regex string - Output
File string - Tag string
- A tag assigned to Subnet.
- Vpc
Id string - The id of the VPC that the desired Subnet belongs to.
- id String
- The ID of Subnet.
- ids List<String>
- subnets
List<Get
Subnets Subnet> - It is a nested type which documented below.
- total
Count Double - Total number of Subnet resources that satisfy the condition.
- name
Regex String - output
File String - tag String
- A tag assigned to Subnet.
- vpc
Id String - The id of the VPC that the desired Subnet belongs to.
- id string
- The ID of Subnet.
- ids string[]
- subnets
Get
Subnets Subnet[] - It is a nested type which documented below.
- total
Count number - Total number of Subnet resources that satisfy the condition.
- name
Regex string - output
File string - tag string
- A tag assigned to Subnet.
- vpc
Id string - The id of the VPC that the desired Subnet belongs to.
- id str
- The ID of Subnet.
- ids Sequence[str]
- subnets
Sequence[Get
Subnets Subnet] - 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.
- total
Count Number - Total number of Subnet resources that satisfy the condition.
- name
Regex String - output
File String - tag String
- A tag assigned to Subnet.
- vpc
Id String - The id of the VPC that the desired Subnet belongs to.
Supporting Types
GetSubnetsSubnet
- Cidr
Block string - The cidr block of the desired Subnet.
- Create
Time 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.
- Vpc
Id string - The id of the VPC that the desired Subnet belongs to.
- Cidr
Block string - The cidr block of the desired Subnet.
- Create
Time 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.
- Vpc
Id string - The id of the VPC that the desired Subnet belongs to.
- cidr
Block String - The cidr block of the desired Subnet.
- create
Time 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.
- vpc
Id String - The id of the VPC that the desired Subnet belongs to.
- cidr
Block string - The cidr block of the desired Subnet.
- create
Time 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.
- vpc
Id 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.
- cidr
Block String - The cidr block of the desired Subnet.
- create
Time 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.
- vpc
Id 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.