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

ucloud.getInstances

Explore with Pulumi AI

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

    This data source providers a list of UHost instance resources according to their availability zone, instance ID and tag.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as ucloud from "@pulumi/ucloud";
    
    const example = ucloud.getInstances({
        availabilityZone: "cn-bj2-02",
    });
    export const first = example.then(example => example.instances?.[0]?.id);
    
    import pulumi
    import pulumi_ucloud as ucloud
    
    example = ucloud.get_instances(availability_zone="cn-bj2-02")
    pulumi.export("first", example.instances[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.GetInstances(ctx, &ucloud.GetInstancesArgs{
    			AvailabilityZone: pulumi.StringRef("cn-bj2-02"),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		ctx.Export("first", example.Instances[0].Id)
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Ucloud = Pulumi.Ucloud;
    
    return await Deployment.RunAsync(() => 
    {
        var example = Ucloud.GetInstances.Invoke(new()
        {
            AvailabilityZone = "cn-bj2-02",
        });
    
        return new Dictionary<string, object?>
        {
            ["first"] = example.Apply(getInstancesResult => getInstancesResult.Instances[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.GetInstancesArgs;
    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.getInstances(GetInstancesArgs.builder()
                .availabilityZone("cn-bj2-02")
                .build());
    
            ctx.export("first", example.applyValue(getInstancesResult -> getInstancesResult.instances()[0].id()));
        }
    }
    
    variables:
      example:
        fn::invoke:
          function: ucloud:getInstances
          arguments:
            availabilityZone: cn-bj2-02
    outputs:
      first: ${example.instances[0].id}
    

    Using getInstances

    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 getInstances(args: GetInstancesArgs, opts?: InvokeOptions): Promise<GetInstancesResult>
    function getInstancesOutput(args: GetInstancesOutputArgs, opts?: InvokeOptions): Output<GetInstancesResult>
    def get_instances(availability_zone: Optional[str] = None,
                      id: Optional[str] = None,
                      ids: Optional[Sequence[str]] = None,
                      name_regex: Optional[str] = None,
                      output_file: Optional[str] = None,
                      tag: Optional[str] = None,
                      opts: Optional[InvokeOptions] = None) -> GetInstancesResult
    def get_instances_output(availability_zone: Optional[pulumi.Input[str]] = None,
                      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,
                      opts: Optional[InvokeOptions] = None) -> Output[GetInstancesResult]
    func GetInstances(ctx *Context, args *GetInstancesArgs, opts ...InvokeOption) (*GetInstancesResult, error)
    func GetInstancesOutput(ctx *Context, args *GetInstancesOutputArgs, opts ...InvokeOption) GetInstancesResultOutput

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

    public static class GetInstances 
    {
        public static Task<GetInstancesResult> InvokeAsync(GetInstancesArgs args, InvokeOptions? opts = null)
        public static Output<GetInstancesResult> Invoke(GetInstancesInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetInstancesResult> getInstances(GetInstancesArgs args, InvokeOptions options)
    public static Output<GetInstancesResult> getInstances(GetInstancesArgs args, InvokeOptions options)
    
    fn::invoke:
      function: ucloud:index/getInstances:getInstances
      arguments:
        # arguments dictionary

    The following arguments are supported:

    AvailabilityZone string
    Availability zone where instances are located. Such as: "cn-bj2-02". You may refer to list of availability zone
    Id string
    The ID of disk.
    Ids List<string>
    A list of instance IDs, all the instances belongs to the defined region will be retrieved if this argument is [].
    NameRegex string
    A regex string to filter resulting instances by name.
    OutputFile string
    File name where to save data source results (after running pulumi preview).
    Tag string
    A tag assigned to instance.
    AvailabilityZone string
    Availability zone where instances are located. Such as: "cn-bj2-02". You may refer to list of availability zone
    Id string
    The ID of disk.
    Ids []string
    A list of instance IDs, all the instances belongs to the defined region will be retrieved if this argument is [].
    NameRegex string
    A regex string to filter resulting instances by name.
    OutputFile string
    File name where to save data source results (after running pulumi preview).
    Tag string
    A tag assigned to instance.
    availabilityZone String
    Availability zone where instances are located. Such as: "cn-bj2-02". You may refer to list of availability zone
    id String
    The ID of disk.
    ids List<String>
    A list of instance IDs, all the instances belongs to the defined region will be retrieved if this argument is [].
    nameRegex String
    A regex string to filter resulting instances by name.
    outputFile String
    File name where to save data source results (after running pulumi preview).
    tag String
    A tag assigned to instance.
    availabilityZone string
    Availability zone where instances are located. Such as: "cn-bj2-02". You may refer to list of availability zone
    id string
    The ID of disk.
    ids string[]
    A list of instance IDs, all the instances belongs to the defined region will be retrieved if this argument is [].
    nameRegex string
    A regex string to filter resulting instances by name.
    outputFile string
    File name where to save data source results (after running pulumi preview).
    tag string
    A tag assigned to instance.
    availability_zone str
    Availability zone where instances are located. Such as: "cn-bj2-02". You may refer to list of availability zone
    id str
    The ID of disk.
    ids Sequence[str]
    A list of instance IDs, all the instances belongs to the defined region will be retrieved if this argument is [].
    name_regex str
    A regex string to filter resulting instances by name.
    output_file str
    File name where to save data source results (after running pulumi preview).
    tag str
    A tag assigned to instance.
    availabilityZone String
    Availability zone where instances are located. Such as: "cn-bj2-02". You may refer to list of availability zone
    id String
    The ID of disk.
    ids List<String>
    A list of instance IDs, all the instances belongs to the defined region will be retrieved if this argument is [].
    nameRegex String
    A regex string to filter resulting instances by name.
    outputFile String
    File name where to save data source results (after running pulumi preview).
    tag String
    A tag assigned to instance.

    getInstances Result

    The following output properties are available:

    Id string
    The ID of disk.
    Ids List<string>
    Instances List<GetInstancesInstance>
    It is a nested type. instances documented below.
    TotalCount double
    Total number of instances that satisfy the condition.
    AvailabilityZone string
    Availability zone where instances are located.
    NameRegex string
    OutputFile string
    Tag string
    A tag assigned to the instance.
    Id string
    The ID of disk.
    Ids []string
    Instances []GetInstancesInstance
    It is a nested type. instances documented below.
    TotalCount float64
    Total number of instances that satisfy the condition.
    AvailabilityZone string
    Availability zone where instances are located.
    NameRegex string
    OutputFile string
    Tag string
    A tag assigned to the instance.
    id String
    The ID of disk.
    ids List<String>
    instances List<GetInstancesInstance>
    It is a nested type. instances documented below.
    totalCount Double
    Total number of instances that satisfy the condition.
    availabilityZone String
    Availability zone where instances are located.
    nameRegex String
    outputFile String
    tag String
    A tag assigned to the instance.
    id string
    The ID of disk.
    ids string[]
    instances GetInstancesInstance[]
    It is a nested type. instances documented below.
    totalCount number
    Total number of instances that satisfy the condition.
    availabilityZone string
    Availability zone where instances are located.
    nameRegex string
    outputFile string
    tag string
    A tag assigned to the instance.
    id str
    The ID of disk.
    ids Sequence[str]
    instances Sequence[GetInstancesInstance]
    It is a nested type. instances documented below.
    total_count float
    Total number of instances that satisfy the condition.
    availability_zone str
    Availability zone where instances are located.
    name_regex str
    output_file str
    tag str
    A tag assigned to the instance.
    id String
    The ID of disk.
    ids List<String>
    instances List<Property Map>
    It is a nested type. instances documented below.
    totalCount Number
    Total number of instances that satisfy the condition.
    availabilityZone String
    Availability zone where instances are located.
    nameRegex String
    outputFile String
    tag String
    A tag assigned to the instance.

    Supporting Types

    GetInstancesInstance

    AutoRenew bool
    Whether to renew an instance automatically or not.
    AvailabilityZone string
    Availability zone where instances are located. Such as: "cn-bj2-02". You may refer to list of availability zone
    ChargeType string
    The charge type of instance, possible values are: year, month and dynamic as pay by hour.
    Cpu double
    The number of cores of virtual CPU, measureed in core.
    CreateTime string
    The time of creation for instance, formatted in RFC3339 time string.
    DiskSets List<GetInstancesInstanceDiskSet>
    It is a nested type which documented below.
    ExpireTime string
    The expiration time for instance, formatted in RFC3339 time string.
    Id string
    The ID of disk.
    InstanceType string
    The type of instance.
    IpSets List<GetInstancesInstanceIpSet>
    It is a nested type which documented below.
    Memory double
    The size of memory, measured in MB (Megabyte).
    Name string
    The name of the instance.
    PrivateIp string
    The private IP address assigned to the instance.
    Remark string
    The remarks of instance.
    Status string
    Instance current status. Possible values are Initializing, Starting, Running, Stopping, Stopped, Install Fail and Rebooting.
    SubnetId string
    The ID of subnet linked to the instance.
    Tag string
    A tag assigned to instance.
    VpcId string
    The ID of VPC linked to the instance.
    AutoRenew bool
    Whether to renew an instance automatically or not.
    AvailabilityZone string
    Availability zone where instances are located. Such as: "cn-bj2-02". You may refer to list of availability zone
    ChargeType string
    The charge type of instance, possible values are: year, month and dynamic as pay by hour.
    Cpu float64
    The number of cores of virtual CPU, measureed in core.
    CreateTime string
    The time of creation for instance, formatted in RFC3339 time string.
    DiskSets []GetInstancesInstanceDiskSet
    It is a nested type which documented below.
    ExpireTime string
    The expiration time for instance, formatted in RFC3339 time string.
    Id string
    The ID of disk.
    InstanceType string
    The type of instance.
    IpSets []GetInstancesInstanceIpSet
    It is a nested type which documented below.
    Memory float64
    The size of memory, measured in MB (Megabyte).
    Name string
    The name of the instance.
    PrivateIp string
    The private IP address assigned to the instance.
    Remark string
    The remarks of instance.
    Status string
    Instance current status. Possible values are Initializing, Starting, Running, Stopping, Stopped, Install Fail and Rebooting.
    SubnetId string
    The ID of subnet linked to the instance.
    Tag string
    A tag assigned to instance.
    VpcId string
    The ID of VPC linked to the instance.
    autoRenew Boolean
    Whether to renew an instance automatically or not.
    availabilityZone String
    Availability zone where instances are located. Such as: "cn-bj2-02". You may refer to list of availability zone
    chargeType String
    The charge type of instance, possible values are: year, month and dynamic as pay by hour.
    cpu Double
    The number of cores of virtual CPU, measureed in core.
    createTime String
    The time of creation for instance, formatted in RFC3339 time string.
    diskSets List<GetInstancesInstanceDiskSet>
    It is a nested type which documented below.
    expireTime String
    The expiration time for instance, formatted in RFC3339 time string.
    id String
    The ID of disk.
    instanceType String
    The type of instance.
    ipSets List<GetInstancesInstanceIpSet>
    It is a nested type which documented below.
    memory Double
    The size of memory, measured in MB (Megabyte).
    name String
    The name of the instance.
    privateIp String
    The private IP address assigned to the instance.
    remark String
    The remarks of instance.
    status String
    Instance current status. Possible values are Initializing, Starting, Running, Stopping, Stopped, Install Fail and Rebooting.
    subnetId String
    The ID of subnet linked to the instance.
    tag String
    A tag assigned to instance.
    vpcId String
    The ID of VPC linked to the instance.
    autoRenew boolean
    Whether to renew an instance automatically or not.
    availabilityZone string
    Availability zone where instances are located. Such as: "cn-bj2-02". You may refer to list of availability zone
    chargeType string
    The charge type of instance, possible values are: year, month and dynamic as pay by hour.
    cpu number
    The number of cores of virtual CPU, measureed in core.
    createTime string
    The time of creation for instance, formatted in RFC3339 time string.
    diskSets GetInstancesInstanceDiskSet[]
    It is a nested type which documented below.
    expireTime string
    The expiration time for instance, formatted in RFC3339 time string.
    id string
    The ID of disk.
    instanceType string
    The type of instance.
    ipSets GetInstancesInstanceIpSet[]
    It is a nested type which documented below.
    memory number
    The size of memory, measured in MB (Megabyte).
    name string
    The name of the instance.
    privateIp string
    The private IP address assigned to the instance.
    remark string
    The remarks of instance.
    status string
    Instance current status. Possible values are Initializing, Starting, Running, Stopping, Stopped, Install Fail and Rebooting.
    subnetId string
    The ID of subnet linked to the instance.
    tag string
    A tag assigned to instance.
    vpcId string
    The ID of VPC linked to the instance.
    auto_renew bool
    Whether to renew an instance automatically or not.
    availability_zone str
    Availability zone where instances are located. Such as: "cn-bj2-02". You may refer to list of availability zone
    charge_type str
    The charge type of instance, possible values are: year, month and dynamic as pay by hour.
    cpu float
    The number of cores of virtual CPU, measureed in core.
    create_time str
    The time of creation for instance, formatted in RFC3339 time string.
    disk_sets Sequence[GetInstancesInstanceDiskSet]
    It is a nested type which documented below.
    expire_time str
    The expiration time for instance, formatted in RFC3339 time string.
    id str
    The ID of disk.
    instance_type str
    The type of instance.
    ip_sets Sequence[GetInstancesInstanceIpSet]
    It is a nested type which documented below.
    memory float
    The size of memory, measured in MB (Megabyte).
    name str
    The name of the instance.
    private_ip str
    The private IP address assigned to the instance.
    remark str
    The remarks of instance.
    status str
    Instance current status. Possible values are Initializing, Starting, Running, Stopping, Stopped, Install Fail and Rebooting.
    subnet_id str
    The ID of subnet linked to the instance.
    tag str
    A tag assigned to instance.
    vpc_id str
    The ID of VPC linked to the instance.
    autoRenew Boolean
    Whether to renew an instance automatically or not.
    availabilityZone String
    Availability zone where instances are located. Such as: "cn-bj2-02". You may refer to list of availability zone
    chargeType String
    The charge type of instance, possible values are: year, month and dynamic as pay by hour.
    cpu Number
    The number of cores of virtual CPU, measureed in core.
    createTime String
    The time of creation for instance, formatted in RFC3339 time string.
    diskSets List<Property Map>
    It is a nested type which documented below.
    expireTime String
    The expiration time for instance, formatted in RFC3339 time string.
    id String
    The ID of disk.
    instanceType String
    The type of instance.
    ipSets List<Property Map>
    It is a nested type which documented below.
    memory Number
    The size of memory, measured in MB (Megabyte).
    name String
    The name of the instance.
    privateIp String
    The private IP address assigned to the instance.
    remark String
    The remarks of instance.
    status String
    Instance current status. Possible values are Initializing, Starting, Running, Stopping, Stopped, Install Fail and Rebooting.
    subnetId String
    The ID of subnet linked to the instance.
    tag String
    A tag assigned to instance.
    vpcId String
    The ID of VPC linked to the instance.

    GetInstancesInstanceDiskSet

    Id string
    The ID of disk.
    IsBoot bool
    Specifies whether boot disk or not.
    Size double
    The size of disk, measured in GB (Gigabyte).
    Type string
    The type of disk.
    Id string
    The ID of disk.
    IsBoot bool
    Specifies whether boot disk or not.
    Size float64
    The size of disk, measured in GB (Gigabyte).
    Type string
    The type of disk.
    id String
    The ID of disk.
    isBoot Boolean
    Specifies whether boot disk or not.
    size Double
    The size of disk, measured in GB (Gigabyte).
    type String
    The type of disk.
    id string
    The ID of disk.
    isBoot boolean
    Specifies whether boot disk or not.
    size number
    The size of disk, measured in GB (Gigabyte).
    type string
    The type of disk.
    id str
    The ID of disk.
    is_boot bool
    Specifies whether boot disk or not.
    size float
    The size of disk, measured in GB (Gigabyte).
    type str
    The type of disk.
    id String
    The ID of disk.
    isBoot Boolean
    Specifies whether boot disk or not.
    size Number
    The size of disk, measured in GB (Gigabyte).
    type String
    The type of disk.

    GetInstancesInstanceIpSet

    InternetType string
    Type of Elastic IP routes.
    Ip string
    Elastic IP address.
    InternetType string
    Type of Elastic IP routes.
    Ip string
    Elastic IP address.
    internetType String
    Type of Elastic IP routes.
    ip String
    Elastic IP address.
    internetType string
    Type of Elastic IP routes.
    ip string
    Elastic IP address.
    internet_type str
    Type of Elastic IP routes.
    ip str
    Elastic IP address.
    internetType String
    Type of Elastic IP routes.
    ip String
    Elastic IP address.

    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