Alibaba Cloud v3.66.0 published on Friday, Nov 15, 2024 by Pulumi
alicloud.polardb.getAccounts
Explore with Pulumi AI
The alicloud.polardb.getAccounts
data source provides a collection of PolarDB cluster database account available in Alibaba Cloud account.
Filters support regular expression for the account name, searches by clusterId.
NOTE: Available since v1.70.0+.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as alicloud from "@pulumi/alicloud";
export = async () => {
const this = await alicloud.polardb.getNodeClasses({
dbType: "MySQL",
dbVersion: "8.0",
payType: "PostPaid",
category: "Normal",
});
const defaultNetwork = new alicloud.vpc.Network("default", {
vpcName: "terraform-example",
cidrBlock: "172.16.0.0/16",
});
const defaultSwitch = new alicloud.vpc.Switch("default", {
vpcId: defaultNetwork.id,
cidrBlock: "172.16.0.0/24",
zoneId: _this.classes?.[0]?.zoneId,
vswitchName: "terraform-example",
});
const cluster = new alicloud.polardb.Cluster("cluster", {
dbType: "MySQL",
dbVersion: "8.0",
payType: "PostPaid",
dbNodeCount: 2,
dbNodeClass: _this.classes?.[0]?.supportedEngines?.[0]?.availableResources?.[0]?.dbNodeClass,
vswitchId: defaultSwitch.id,
});
const polardbClustersDs = alicloud.polardb.getClustersOutput({
descriptionRegex: cluster.description,
status: "Running",
});
const account = new alicloud.polardb.Account("account", {
dbClusterId: polardbClustersDs.apply(polardbClustersDs => polardbClustersDs.clusters?.[0]?.id),
accountName: "tfnormal_01",
accountPassword: "Test12345",
accountDescription: "tf_account_description",
accountType: "Normal",
});
const default = pulumi.all([polardbClustersDs, account.accountName]).apply(([polardbClustersDs, accountName]) => alicloud.polardb.getAccountsOutput({
dbClusterId: polardbClustersDs.clusters?.[0]?.id,
nameRegex: accountName,
}));
return {
account: _default.apply(_default => _default.accounts?.[0]?.accountName),
};
}
import pulumi
import pulumi_alicloud as alicloud
this = alicloud.polardb.get_node_classes(db_type="MySQL",
db_version="8.0",
pay_type="PostPaid",
category="Normal")
default_network = alicloud.vpc.Network("default",
vpc_name="terraform-example",
cidr_block="172.16.0.0/16")
default_switch = alicloud.vpc.Switch("default",
vpc_id=default_network.id,
cidr_block="172.16.0.0/24",
zone_id=this.classes[0].zone_id,
vswitch_name="terraform-example")
cluster = alicloud.polardb.Cluster("cluster",
db_type="MySQL",
db_version="8.0",
pay_type="PostPaid",
db_node_count=2,
db_node_class=this.classes[0].supported_engines[0].available_resources[0].db_node_class,
vswitch_id=default_switch.id)
polardb_clusters_ds = alicloud.polardb.get_clusters_output(description_regex=cluster.description,
status="Running")
account = alicloud.polardb.Account("account",
db_cluster_id=polardb_clusters_ds.clusters[0].id,
account_name="tfnormal_01",
account_password="Test12345",
account_description="tf_account_description",
account_type="Normal")
default = pulumi.Output.all(
polardb_clusters_ds=polardb_clusters_ds,
account_name=account.account_name
).apply(lambda resolved_outputs: alicloud.polardb.get_accounts_output(db_cluster_id=polardb_clusters_ds.clusters[0].id,
name_regex=resolved_outputs['account_name']))
pulumi.export("account", default.accounts[0].account_name)
package main
import (
"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/polardb"
"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/vpc"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
this, err := polardb.GetNodeClasses(ctx, &polardb.GetNodeClassesArgs{
DbType: pulumi.StringRef("MySQL"),
DbVersion: pulumi.StringRef("8.0"),
PayType: "PostPaid",
Category: pulumi.StringRef("Normal"),
}, nil);
if err != nil {
return err
}
defaultNetwork, err := vpc.NewNetwork(ctx, "default", &vpc.NetworkArgs{
VpcName: pulumi.String("terraform-example"),
CidrBlock: pulumi.String("172.16.0.0/16"),
})
if err != nil {
return err
}
defaultSwitch, err := vpc.NewSwitch(ctx, "default", &vpc.SwitchArgs{
VpcId: defaultNetwork.ID(),
CidrBlock: pulumi.String("172.16.0.0/24"),
ZoneId: pulumi.String(this.Classes[0].ZoneId),
VswitchName: pulumi.String("terraform-example"),
})
if err != nil {
return err
}
cluster, err := polardb.NewCluster(ctx, "cluster", &polardb.ClusterArgs{
DbType: pulumi.String("MySQL"),
DbVersion: pulumi.String("8.0"),
PayType: pulumi.String("PostPaid"),
DbNodeCount: pulumi.Int(2),
DbNodeClass: pulumi.String(this.Classes[0].SupportedEngines[0].AvailableResources[0].DbNodeClass),
VswitchId: defaultSwitch.ID(),
})
if err != nil {
return err
}
polardbClustersDs := polardb.GetClustersOutput(ctx, polardb.GetClustersOutputArgs{
DescriptionRegex: cluster.Description,
Status: pulumi.String("Running"),
}, nil);
account, err := polardb.NewAccount(ctx, "account", &polardb.AccountArgs{
DbClusterId: pulumi.String(polardbClustersDs.ApplyT(func(polardbClustersDs polardb.GetClustersResult) (*string, error) {
return &polardbClustersDs.Clusters[0].Id, nil
}).(pulumi.StringPtrOutput)),
AccountName: pulumi.String("tfnormal_01"),
AccountPassword: pulumi.String("Test12345"),
AccountDescription: pulumi.String("tf_account_description"),
AccountType: pulumi.String("Normal"),
})
if err != nil {
return err
}
_default := pulumi.All(polardbClustersDs,account.AccountName).ApplyT(func(_args []interface{}) (polardb.GetAccountsResult, error) {
polardbClustersDs := _args[0].(polardb.GetClustersResult)
accountName := _args[1].(string)
return polardb.GetAccountsResult(interface{}(polardb.GetAccountsOutput(ctx, polardb.GetAccountsOutputArgs{
DbClusterId: polardbClustersDs.Clusters[0].Id,
NameRegex: accountName,
}, nil))), nil
}).(polardb.GetAccountsResultOutput)
ctx.Export("account", _default.ApplyT(func(_default polardb.GetAccountsResult) (*string, error) {
return &default.Accounts[0].AccountName, nil
}).(pulumi.StringPtrOutput))
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AliCloud = Pulumi.AliCloud;
return await Deployment.RunAsync(() =>
{
var @this = AliCloud.PolarDB.GetNodeClasses.Invoke(new()
{
DbType = "MySQL",
DbVersion = "8.0",
PayType = "PostPaid",
Category = "Normal",
});
var defaultNetwork = new AliCloud.Vpc.Network("default", new()
{
VpcName = "terraform-example",
CidrBlock = "172.16.0.0/16",
});
var defaultSwitch = new AliCloud.Vpc.Switch("default", new()
{
VpcId = defaultNetwork.Id,
CidrBlock = "172.16.0.0/24",
ZoneId = @this.Apply(@this => @this.Apply(getNodeClassesResult => getNodeClassesResult.Classes[0]?.ZoneId)),
VswitchName = "terraform-example",
});
var cluster = new AliCloud.PolarDB.Cluster("cluster", new()
{
DbType = "MySQL",
DbVersion = "8.0",
PayType = "PostPaid",
DbNodeCount = 2,
DbNodeClass = @this.Apply(@this => @this.Apply(getNodeClassesResult => getNodeClassesResult.Classes[0]?.SupportedEngines[0]?.AvailableResources[0]?.DbNodeClass)),
VswitchId = defaultSwitch.Id,
});
var polardbClustersDs = AliCloud.PolarDB.GetClusters.Invoke(new()
{
DescriptionRegex = cluster.Description,
Status = "Running",
});
var account = new AliCloud.PolarDB.Account("account", new()
{
DbClusterId = polardbClustersDs.Apply(getClustersResult => getClustersResult.Clusters[0]?.Id),
AccountName = "tfnormal_01",
AccountPassword = "Test12345",
AccountDescription = "tf_account_description",
AccountType = "Normal",
});
var @default = AliCloud.PolarDB.GetAccounts.Invoke(new()
{
DbClusterId = polardbClustersDs.Apply(getClustersResult => getClustersResult.Clusters[0]?.Id),
NameRegex = account.AccountName,
});
return new Dictionary<string, object?>
{
["account"] = @default.Apply(@default => @default.Apply(getAccountsResult => getAccountsResult.Accounts[0]?.AccountName)),
};
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.alicloud.polardb.PolardbFunctions;
import com.pulumi.alicloud.polardb.inputs.GetNodeClassesArgs;
import com.pulumi.alicloud.vpc.Network;
import com.pulumi.alicloud.vpc.NetworkArgs;
import com.pulumi.alicloud.vpc.Switch;
import com.pulumi.alicloud.vpc.SwitchArgs;
import com.pulumi.alicloud.polardb.Cluster;
import com.pulumi.alicloud.polardb.ClusterArgs;
import com.pulumi.alicloud.polardb.inputs.GetClustersArgs;
import com.pulumi.alicloud.polardb.Account;
import com.pulumi.alicloud.polardb.AccountArgs;
import com.pulumi.alicloud.polardb.inputs.GetAccountsArgs;
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 this = PolardbFunctions.getNodeClasses(GetNodeClassesArgs.builder()
.dbType("MySQL")
.dbVersion("8.0")
.payType("PostPaid")
.category("Normal")
.build());
var defaultNetwork = new Network("defaultNetwork", NetworkArgs.builder()
.vpcName("terraform-example")
.cidrBlock("172.16.0.0/16")
.build());
var defaultSwitch = new Switch("defaultSwitch", SwitchArgs.builder()
.vpcId(defaultNetwork.id())
.cidrBlock("172.16.0.0/24")
.zoneId(this_.classes()[0].zoneId())
.vswitchName("terraform-example")
.build());
var cluster = new Cluster("cluster", ClusterArgs.builder()
.dbType("MySQL")
.dbVersion("8.0")
.payType("PostPaid")
.dbNodeCount("2")
.dbNodeClass(this_.classes()[0].supportedEngines()[0].availableResources()[0].dbNodeClass())
.vswitchId(defaultSwitch.id())
.build());
final var polardbClustersDs = PolardbFunctions.getClusters(GetClustersArgs.builder()
.descriptionRegex(cluster.description())
.status("Running")
.build());
var account = new Account("account", AccountArgs.builder()
.dbClusterId(polardbClustersDs.applyValue(getClustersResult -> getClustersResult).applyValue(polardbClustersDs -> polardbClustersDs.applyValue(getClustersResult -> getClustersResult.clusters()[0].id())))
.accountName("tfnormal_01")
.accountPassword("Test12345")
.accountDescription("tf_account_description")
.accountType("Normal")
.build());
final var default = PolardbFunctions.getAccounts(GetAccountsArgs.builder()
.dbClusterId(polardbClustersDs.applyValue(getClustersResult -> getClustersResult).applyValue(polardbClustersDs -> polardbClustersDs.applyValue(getClustersResult -> getClustersResult.clusters()[0].id())))
.nameRegex(account.accountName())
.build());
ctx.export("account", default_.applyValue(default_ -> default_.accounts()[0].accountName()));
}
}
resources:
defaultNetwork:
type: alicloud:vpc:Network
name: default
properties:
vpcName: terraform-example
cidrBlock: 172.16.0.0/16
defaultSwitch:
type: alicloud:vpc:Switch
name: default
properties:
vpcId: ${defaultNetwork.id}
cidrBlock: 172.16.0.0/24
zoneId: ${this.classes[0].zoneId}
vswitchName: terraform-example
cluster:
type: alicloud:polardb:Cluster
properties:
dbType: MySQL
dbVersion: '8.0'
payType: PostPaid
dbNodeCount: '2'
dbNodeClass: ${this.classes[0].supportedEngines[0].availableResources[0].dbNodeClass}
vswitchId: ${defaultSwitch.id}
account:
type: alicloud:polardb:Account
properties:
dbClusterId: ${polardbClustersDs.clusters[0].id}
accountName: tfnormal_01
accountPassword: Test12345
accountDescription: tf_account_description
accountType: Normal
variables:
this:
fn::invoke:
Function: alicloud:polardb:getNodeClasses
Arguments:
dbType: MySQL
dbVersion: '8.0'
payType: PostPaid
category: Normal
polardbClustersDs:
fn::invoke:
Function: alicloud:polardb:getClusters
Arguments:
descriptionRegex: ${cluster.description}
status: Running
default:
fn::invoke:
Function: alicloud:polardb:getAccounts
Arguments:
dbClusterId: ${polardbClustersDs.clusters[0].id}
nameRegex: ${account.accountName}
outputs:
account: ${default.accounts[0].accountName}
Using getAccounts
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 getAccounts(args: GetAccountsArgs, opts?: InvokeOptions): Promise<GetAccountsResult>
function getAccountsOutput(args: GetAccountsOutputArgs, opts?: InvokeOptions): Output<GetAccountsResult>
def get_accounts(db_cluster_id: Optional[str] = None,
name_regex: Optional[str] = None,
opts: Optional[InvokeOptions] = None) -> GetAccountsResult
def get_accounts_output(db_cluster_id: Optional[pulumi.Input[str]] = None,
name_regex: Optional[pulumi.Input[str]] = None,
opts: Optional[InvokeOptions] = None) -> Output[GetAccountsResult]
func GetAccounts(ctx *Context, args *GetAccountsArgs, opts ...InvokeOption) (*GetAccountsResult, error)
func GetAccountsOutput(ctx *Context, args *GetAccountsOutputArgs, opts ...InvokeOption) GetAccountsResultOutput
> Note: This function is named GetAccounts
in the Go SDK.
public static class GetAccounts
{
public static Task<GetAccountsResult> InvokeAsync(GetAccountsArgs args, InvokeOptions? opts = null)
public static Output<GetAccountsResult> Invoke(GetAccountsInvokeArgs args, InvokeOptions? opts = null)
}
public static CompletableFuture<GetAccountsResult> getAccounts(GetAccountsArgs args, InvokeOptions options)
// Output-based functions aren't available in Java yet
fn::invoke:
function: alicloud:polardb/getAccounts:getAccounts
arguments:
# arguments dictionary
The following arguments are supported:
- Db
Cluster stringId - The polarDB cluster ID.
- Name
Regex string - A regex string to filter results by account name.
- Db
Cluster stringId - The polarDB cluster ID.
- Name
Regex string - A regex string to filter results by account name.
- db
Cluster StringId - The polarDB cluster ID.
- name
Regex String - A regex string to filter results by account name.
- db
Cluster stringId - The polarDB cluster ID.
- name
Regex string - A regex string to filter results by account name.
- db_
cluster_ strid - The polarDB cluster ID.
- name_
regex str - A regex string to filter results by account name.
- db
Cluster StringId - The polarDB cluster ID.
- name
Regex String - A regex string to filter results by account name.
getAccounts Result
The following output properties are available:
- Accounts
List<Pulumi.
Ali Cloud. Polar DB. Outputs. Get Accounts Account> - A list of PolarDB cluster accounts. Each element contains the following attributes:
- Db
Cluster stringId - Id string
- The provider-assigned unique ID for this managed resource.
- Names List<string>
- Account name of the cluster.
- Name
Regex string
- Accounts
[]Get
Accounts Account - A list of PolarDB cluster accounts. Each element contains the following attributes:
- Db
Cluster stringId - Id string
- The provider-assigned unique ID for this managed resource.
- Names []string
- Account name of the cluster.
- Name
Regex string
- accounts
List<Get
Accounts Account> - A list of PolarDB cluster accounts. Each element contains the following attributes:
- db
Cluster StringId - id String
- The provider-assigned unique ID for this managed resource.
- names List<String>
- Account name of the cluster.
- name
Regex String
- accounts
Get
Accounts Account[] - A list of PolarDB cluster accounts. Each element contains the following attributes:
- db
Cluster stringId - id string
- The provider-assigned unique ID for this managed resource.
- names string[]
- Account name of the cluster.
- name
Regex string
- accounts
Sequence[Get
Accounts Account] - A list of PolarDB cluster accounts. Each element contains the following attributes:
- db_
cluster_ strid - id str
- The provider-assigned unique ID for this managed resource.
- names Sequence[str]
- Account name of the cluster.
- name_
regex str
- accounts List<Property Map>
- A list of PolarDB cluster accounts. Each element contains the following attributes:
- db
Cluster StringId - id String
- The provider-assigned unique ID for this managed resource.
- names List<String>
- Account name of the cluster.
- name
Regex String
Supporting Types
GetAccountsAccount
- Account
Description string - Account description.
- Account
Lock stringState - Account lock state, Valid values are
Lock
,UnLock
. - Account
Name string - Account name.
- Account
Status string - Cluster address type.
Cluster
: the default address of the Cluster.Primary
: Primary address.Custom
: Custom cluster addresses. - Account
Type string - Account type, Valid values are
Normal
,Super
. - Database
Privileges List<Pulumi.Ali Cloud. Polar DB. Inputs. Get Accounts Account Database Privilege> - A list of database privilege. Each element contains the following attributes.
- Account
Description string - Account description.
- Account
Lock stringState - Account lock state, Valid values are
Lock
,UnLock
. - Account
Name string - Account name.
- Account
Status string - Cluster address type.
Cluster
: the default address of the Cluster.Primary
: Primary address.Custom
: Custom cluster addresses. - Account
Type string - Account type, Valid values are
Normal
,Super
. - Database
Privileges []GetAccounts Account Database Privilege - A list of database privilege. Each element contains the following attributes.
- account
Description String - Account description.
- account
Lock StringState - Account lock state, Valid values are
Lock
,UnLock
. - account
Name String - Account name.
- account
Status String - Cluster address type.
Cluster
: the default address of the Cluster.Primary
: Primary address.Custom
: Custom cluster addresses. - account
Type String - Account type, Valid values are
Normal
,Super
. - database
Privileges List<GetAccounts Account Database Privilege> - A list of database privilege. Each element contains the following attributes.
- account
Description string - Account description.
- account
Lock stringState - Account lock state, Valid values are
Lock
,UnLock
. - account
Name string - Account name.
- account
Status string - Cluster address type.
Cluster
: the default address of the Cluster.Primary
: Primary address.Custom
: Custom cluster addresses. - account
Type string - Account type, Valid values are
Normal
,Super
. - database
Privileges GetAccounts Account Database Privilege[] - A list of database privilege. Each element contains the following attributes.
- account_
description str - Account description.
- account_
lock_ strstate - Account lock state, Valid values are
Lock
,UnLock
. - account_
name str - Account name.
- account_
status str - Cluster address type.
Cluster
: the default address of the Cluster.Primary
: Primary address.Custom
: Custom cluster addresses. - account_
type str - Account type, Valid values are
Normal
,Super
. - database_
privileges Sequence[GetAccounts Account Database Privilege] - A list of database privilege. Each element contains the following attributes.
- account
Description String - Account description.
- account
Lock StringState - Account lock state, Valid values are
Lock
,UnLock
. - account
Name String - Account name.
- account
Status String - Cluster address type.
Cluster
: the default address of the Cluster.Primary
: Primary address.Custom
: Custom cluster addresses. - account
Type String - Account type, Valid values are
Normal
,Super
. - database
Privileges List<Property Map> - A list of database privilege. Each element contains the following attributes.
GetAccountsAccountDatabasePrivilege
- Account
Privilege string - Account privilege of database
- Db
Name string - The account owned database name
- Account
Privilege string - Account privilege of database
- Db
Name string - The account owned database name
- account
Privilege String - Account privilege of database
- db
Name String - The account owned database name
- account
Privilege string - Account privilege of database
- db
Name string - The account owned database name
- account_
privilege str - Account privilege of database
- db_
name str - The account owned database name
- account
Privilege String - Account privilege of database
- db
Name String - The account owned database name
Package Details
- Repository
- Alibaba Cloud pulumi/pulumi-alicloud
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
alicloud
Terraform Provider.