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

ucloud.getDbInstances

Explore with Pulumi AI

This data source provides a list of database instance resources according to their database instance ID and name.

Example Usage

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

const example = ucloud.getDbInstances({});
export const first = example.then(example => example.dbInstances?.[0]?.id);
Copy
import pulumi
import pulumi_ucloud as ucloud

example = ucloud.get_db_instances()
pulumi.export("first", example.db_instances[0].id)
Copy
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.GetDbInstances(ctx, &ucloud.GetDbInstancesArgs{}, nil)
		if err != nil {
			return err
		}
		ctx.Export("first", example.DbInstances[0].Id)
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Ucloud = Pulumi.Ucloud;

return await Deployment.RunAsync(() => 
{
    var example = Ucloud.GetDbInstances.Invoke();

    return new Dictionary<string, object?>
    {
        ["first"] = example.Apply(getDbInstancesResult => getDbInstancesResult.DbInstances[0]?.Id),
    };
});
Copy
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.GetDbInstancesArgs;
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.getDbInstances();

        ctx.export("first", example.applyValue(getDbInstancesResult -> getDbInstancesResult.dbInstances()[0].id()));
    }
}
Copy
variables:
  example:
    fn::invoke:
      function: ucloud:getDbInstances
      arguments: {}
outputs:
  first: ${example.dbInstances[0].id}
Copy

Using getDbInstances

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 getDbInstances(args: GetDbInstancesArgs, opts?: InvokeOptions): Promise<GetDbInstancesResult>
function getDbInstancesOutput(args: GetDbInstancesOutputArgs, opts?: InvokeOptions): Output<GetDbInstancesResult>
Copy
def get_db_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,
                     opts: Optional[InvokeOptions] = None) -> GetDbInstancesResult
def get_db_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,
                     opts: Optional[InvokeOptions] = None) -> Output[GetDbInstancesResult]
Copy
func GetDbInstances(ctx *Context, args *GetDbInstancesArgs, opts ...InvokeOption) (*GetDbInstancesResult, error)
func GetDbInstancesOutput(ctx *Context, args *GetDbInstancesOutputArgs, opts ...InvokeOption) GetDbInstancesResultOutput
Copy

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

public static class GetDbInstances 
{
    public static Task<GetDbInstancesResult> InvokeAsync(GetDbInstancesArgs args, InvokeOptions? opts = null)
    public static Output<GetDbInstancesResult> Invoke(GetDbInstancesInvokeArgs args, InvokeOptions? opts = null)
}
Copy
public static CompletableFuture<GetDbInstancesResult> getDbInstances(GetDbInstancesArgs args, InvokeOptions options)
public static Output<GetDbInstancesResult> getDbInstances(GetDbInstancesArgs args, InvokeOptions options)
Copy
fn::invoke:
  function: ucloud:index/getDbInstances:getDbInstances
  arguments:
    # arguments dictionary
Copy

The following arguments are supported:

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

getDbInstances Result

The following output properties are available:

DbInstances List<GetDbInstancesDbInstance>
It is a nested type which documented below.
Id string
The ID of database instance.
Ids List<string>
TotalCount double
Total number of database instances that satisfy the condition.
AvailabilityZone string
Availability zone where database instance is located.
NameRegex string
OutputFile string
DbInstances []GetDbInstancesDbInstance
It is a nested type which documented below.
Id string
The ID of database instance.
Ids []string
TotalCount float64
Total number of database instances that satisfy the condition.
AvailabilityZone string
Availability zone where database instance is located.
NameRegex string
OutputFile string
dbInstances List<GetDbInstancesDbInstance>
It is a nested type which documented below.
id String
The ID of database instance.
ids List<String>
totalCount Double
Total number of database instances that satisfy the condition.
availabilityZone String
Availability zone where database instance is located.
nameRegex String
outputFile String
dbInstances GetDbInstancesDbInstance[]
It is a nested type which documented below.
id string
The ID of database instance.
ids string[]
totalCount number
Total number of database instances that satisfy the condition.
availabilityZone string
Availability zone where database instance is located.
nameRegex string
outputFile string
db_instances Sequence[GetDbInstancesDbInstance]
It is a nested type which documented below.
id str
The ID of database instance.
ids Sequence[str]
total_count float
Total number of database instances that satisfy the condition.
availability_zone str
Availability zone where database instance is located.
name_regex str
output_file str
dbInstances List<Property Map>
It is a nested type which documented below.
id String
The ID of database instance.
ids List<String>
totalCount Number
Total number of database instances that satisfy the condition.
availabilityZone String
Availability zone where database instance is located.
nameRegex String
outputFile String

Supporting Types

GetDbInstancesDbInstance

AvailabilityZone This property is required. string
Availability zone where database instances are located. Such as: "cn-bj2-02". You may refer to list of availability zone
BackupBeginTime This property is required. double
Specifies when the backup starts, measured in hour.
BackupBlackLists This property is required. List<string>
The backup for database instance such as "test.%" or table such as "city.address" specified in the black lists are not supported.
BackupCount This property is required. double
Specifies the number of backup saved per week.
BackupDate This property is required. string
Specifies whether the backup took place from Sunday to Saturday by displaying 7 digits. 0 stands for backup disabled and 1 stands for backup enabled. The rightmost digit specifies whether the backup took place on Sunday, and the digits from right to left specify whether the backup took place from Monday to Saturday, it's mandatory required to backup twice per week at least. such as: digits "1100000" stands for the backup took place on Saturday and Friday.
ChargeType This property is required. string
The charge type of db instance.
CreateTime This property is required. string
The creation time of database instance , formatted by RFC3339 time string.
Engine This property is required. string
The type of database instance engine.
EngineVersion This property is required. string
The database instance engine version.
ExpireTime This property is required. string
The expiration time of database instance , formatted by RFC3339 time string.
Id This property is required. string
The ID of database instance.
InstanceStorage This property is required. double
Specifies the allocated storage size in gigabytes (GB).
InstanceType This property is required. string
Specifies the type of database instance.
ModifyTime This property is required. string
The modification time of database instance , formatted by RFC3339 time string.
Name This property is required. string
The name of database instance.
Port This property is required. double
The port on which the database instance accepts connections.
PrivateIp This property is required. string
The private IP address assigned to the database instance.
StandbyZone This property is required. string
Availability zone where the standby database instance is located for the high availability database instance with multiple zone.
Status This property is required. string
Specifies the status of database instance , possible values are: Init, Fail, Starting, Running, Shutdown, Shutoff, Delete, Upgrading, Promoting, Recovering and Recover fail.
SubnetId This property is required. string
The ID of subnet linked to the database instances.
Tag This property is required. string
A tag assigned to database instance.
VpcId This property is required. string
The ID of VPC linked to the database instances.
AvailabilityZone This property is required. string
Availability zone where database instances are located. Such as: "cn-bj2-02". You may refer to list of availability zone
BackupBeginTime This property is required. float64
Specifies when the backup starts, measured in hour.
BackupBlackLists This property is required. []string
The backup for database instance such as "test.%" or table such as "city.address" specified in the black lists are not supported.
BackupCount This property is required. float64
Specifies the number of backup saved per week.
BackupDate This property is required. string
Specifies whether the backup took place from Sunday to Saturday by displaying 7 digits. 0 stands for backup disabled and 1 stands for backup enabled. The rightmost digit specifies whether the backup took place on Sunday, and the digits from right to left specify whether the backup took place from Monday to Saturday, it's mandatory required to backup twice per week at least. such as: digits "1100000" stands for the backup took place on Saturday and Friday.
ChargeType This property is required. string
The charge type of db instance.
CreateTime This property is required. string
The creation time of database instance , formatted by RFC3339 time string.
Engine This property is required. string
The type of database instance engine.
EngineVersion This property is required. string
The database instance engine version.
ExpireTime This property is required. string
The expiration time of database instance , formatted by RFC3339 time string.
Id This property is required. string
The ID of database instance.
InstanceStorage This property is required. float64
Specifies the allocated storage size in gigabytes (GB).
InstanceType This property is required. string
Specifies the type of database instance.
ModifyTime This property is required. string
The modification time of database instance , formatted by RFC3339 time string.
Name This property is required. string
The name of database instance.
Port This property is required. float64
The port on which the database instance accepts connections.
PrivateIp This property is required. string
The private IP address assigned to the database instance.
StandbyZone This property is required. string
Availability zone where the standby database instance is located for the high availability database instance with multiple zone.
Status This property is required. string
Specifies the status of database instance , possible values are: Init, Fail, Starting, Running, Shutdown, Shutoff, Delete, Upgrading, Promoting, Recovering and Recover fail.
SubnetId This property is required. string
The ID of subnet linked to the database instances.
Tag This property is required. string
A tag assigned to database instance.
VpcId This property is required. string
The ID of VPC linked to the database instances.
availabilityZone This property is required. String
Availability zone where database instances are located. Such as: "cn-bj2-02". You may refer to list of availability zone
backupBeginTime This property is required. Double
Specifies when the backup starts, measured in hour.
backupBlackLists This property is required. List<String>
The backup for database instance such as "test.%" or table such as "city.address" specified in the black lists are not supported.
backupCount This property is required. Double
Specifies the number of backup saved per week.
backupDate This property is required. String
Specifies whether the backup took place from Sunday to Saturday by displaying 7 digits. 0 stands for backup disabled and 1 stands for backup enabled. The rightmost digit specifies whether the backup took place on Sunday, and the digits from right to left specify whether the backup took place from Monday to Saturday, it's mandatory required to backup twice per week at least. such as: digits "1100000" stands for the backup took place on Saturday and Friday.
chargeType This property is required. String
The charge type of db instance.
createTime This property is required. String
The creation time of database instance , formatted by RFC3339 time string.
engine This property is required. String
The type of database instance engine.
engineVersion This property is required. String
The database instance engine version.
expireTime This property is required. String
The expiration time of database instance , formatted by RFC3339 time string.
id This property is required. String
The ID of database instance.
instanceStorage This property is required. Double
Specifies the allocated storage size in gigabytes (GB).
instanceType This property is required. String
Specifies the type of database instance.
modifyTime This property is required. String
The modification time of database instance , formatted by RFC3339 time string.
name This property is required. String
The name of database instance.
port This property is required. Double
The port on which the database instance accepts connections.
privateIp This property is required. String
The private IP address assigned to the database instance.
standbyZone This property is required. String
Availability zone where the standby database instance is located for the high availability database instance with multiple zone.
status This property is required. String
Specifies the status of database instance , possible values are: Init, Fail, Starting, Running, Shutdown, Shutoff, Delete, Upgrading, Promoting, Recovering and Recover fail.
subnetId This property is required. String
The ID of subnet linked to the database instances.
tag This property is required. String
A tag assigned to database instance.
vpcId This property is required. String
The ID of VPC linked to the database instances.
availabilityZone This property is required. string
Availability zone where database instances are located. Such as: "cn-bj2-02". You may refer to list of availability zone
backupBeginTime This property is required. number
Specifies when the backup starts, measured in hour.
backupBlackLists This property is required. string[]
The backup for database instance such as "test.%" or table such as "city.address" specified in the black lists are not supported.
backupCount This property is required. number
Specifies the number of backup saved per week.
backupDate This property is required. string
Specifies whether the backup took place from Sunday to Saturday by displaying 7 digits. 0 stands for backup disabled and 1 stands for backup enabled. The rightmost digit specifies whether the backup took place on Sunday, and the digits from right to left specify whether the backup took place from Monday to Saturday, it's mandatory required to backup twice per week at least. such as: digits "1100000" stands for the backup took place on Saturday and Friday.
chargeType This property is required. string
The charge type of db instance.
createTime This property is required. string
The creation time of database instance , formatted by RFC3339 time string.
engine This property is required. string
The type of database instance engine.
engineVersion This property is required. string
The database instance engine version.
expireTime This property is required. string
The expiration time of database instance , formatted by RFC3339 time string.
id This property is required. string
The ID of database instance.
instanceStorage This property is required. number
Specifies the allocated storage size in gigabytes (GB).
instanceType This property is required. string
Specifies the type of database instance.
modifyTime This property is required. string
The modification time of database instance , formatted by RFC3339 time string.
name This property is required. string
The name of database instance.
port This property is required. number
The port on which the database instance accepts connections.
privateIp This property is required. string
The private IP address assigned to the database instance.
standbyZone This property is required. string
Availability zone where the standby database instance is located for the high availability database instance with multiple zone.
status This property is required. string
Specifies the status of database instance , possible values are: Init, Fail, Starting, Running, Shutdown, Shutoff, Delete, Upgrading, Promoting, Recovering and Recover fail.
subnetId This property is required. string
The ID of subnet linked to the database instances.
tag This property is required. string
A tag assigned to database instance.
vpcId This property is required. string
The ID of VPC linked to the database instances.
availability_zone This property is required. str
Availability zone where database instances are located. Such as: "cn-bj2-02". You may refer to list of availability zone
backup_begin_time This property is required. float
Specifies when the backup starts, measured in hour.
backup_black_lists This property is required. Sequence[str]
The backup for database instance such as "test.%" or table such as "city.address" specified in the black lists are not supported.
backup_count This property is required. float
Specifies the number of backup saved per week.
backup_date This property is required. str
Specifies whether the backup took place from Sunday to Saturday by displaying 7 digits. 0 stands for backup disabled and 1 stands for backup enabled. The rightmost digit specifies whether the backup took place on Sunday, and the digits from right to left specify whether the backup took place from Monday to Saturday, it's mandatory required to backup twice per week at least. such as: digits "1100000" stands for the backup took place on Saturday and Friday.
charge_type This property is required. str
The charge type of db instance.
create_time This property is required. str
The creation time of database instance , formatted by RFC3339 time string.
engine This property is required. str
The type of database instance engine.
engine_version This property is required. str
The database instance engine version.
expire_time This property is required. str
The expiration time of database instance , formatted by RFC3339 time string.
id This property is required. str
The ID of database instance.
instance_storage This property is required. float
Specifies the allocated storage size in gigabytes (GB).
instance_type This property is required. str
Specifies the type of database instance.
modify_time This property is required. str
The modification time of database instance , formatted by RFC3339 time string.
name This property is required. str
The name of database instance.
port This property is required. float
The port on which the database instance accepts connections.
private_ip This property is required. str
The private IP address assigned to the database instance.
standby_zone This property is required. str
Availability zone where the standby database instance is located for the high availability database instance with multiple zone.
status This property is required. str
Specifies the status of database instance , possible values are: Init, Fail, Starting, Running, Shutdown, Shutoff, Delete, Upgrading, Promoting, Recovering and Recover fail.
subnet_id This property is required. str
The ID of subnet linked to the database instances.
tag This property is required. str
A tag assigned to database instance.
vpc_id This property is required. str
The ID of VPC linked to the database instances.
availabilityZone This property is required. String
Availability zone where database instances are located. Such as: "cn-bj2-02". You may refer to list of availability zone
backupBeginTime This property is required. Number
Specifies when the backup starts, measured in hour.
backupBlackLists This property is required. List<String>
The backup for database instance such as "test.%" or table such as "city.address" specified in the black lists are not supported.
backupCount This property is required. Number
Specifies the number of backup saved per week.
backupDate This property is required. String
Specifies whether the backup took place from Sunday to Saturday by displaying 7 digits. 0 stands for backup disabled and 1 stands for backup enabled. The rightmost digit specifies whether the backup took place on Sunday, and the digits from right to left specify whether the backup took place from Monday to Saturday, it's mandatory required to backup twice per week at least. such as: digits "1100000" stands for the backup took place on Saturday and Friday.
chargeType This property is required. String
The charge type of db instance.
createTime This property is required. String
The creation time of database instance , formatted by RFC3339 time string.
engine This property is required. String
The type of database instance engine.
engineVersion This property is required. String
The database instance engine version.
expireTime This property is required. String
The expiration time of database instance , formatted by RFC3339 time string.
id This property is required. String
The ID of database instance.
instanceStorage This property is required. Number
Specifies the allocated storage size in gigabytes (GB).
instanceType This property is required. String
Specifies the type of database instance.
modifyTime This property is required. String
The modification time of database instance , formatted by RFC3339 time string.
name This property is required. String
The name of database instance.
port This property is required. Number
The port on which the database instance accepts connections.
privateIp This property is required. String
The private IP address assigned to the database instance.
standbyZone This property is required. String
Availability zone where the standby database instance is located for the high availability database instance with multiple zone.
status This property is required. String
Specifies the status of database instance , possible values are: Init, Fail, Starting, Running, Shutdown, Shutoff, Delete, Upgrading, Promoting, Recovering and Recover fail.
subnetId This property is required. String
The ID of subnet linked to the database instances.
tag This property is required. String
A tag assigned to database instance.
vpcId This property is required. String
The ID of VPC linked to the database instances.

Package Details

Repository
ucloud ucloud/terraform-provider-ucloud
License
Notes
This Pulumi package is based on the ucloud Terraform Provider.