get Clusters
The alicloud.polardb.getClusters
data source provides a collection of PolarDB clusters available in Alibaba Cloud account. Filters support regular expression for the cluster description, searches by tags, and other filters which are listed below.
NOTE: Available since v1.66.0+.
Example Usage
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 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.id())
.status("Running")
.build());
ctx.export("firstPolardbClusterId", polardbClustersDs.applyValue(getClustersResult -> getClustersResult).applyValue(polardbClustersDs -> polardbClustersDs.applyValue(getClustersResult -> getClustersResult.clusters()[0].id())));
}
}
Return
A collection of values returned by getClusters.
Parameters
A collection of arguments for invoking getClusters.
Return
A collection of values returned by getClusters.
See also
Parameters
Database type. Options are MySQL
, Oracle
and PostgreSQL
. If no value is specified, all types are returned.
A regex string to filter results by cluster description.
A list of PolarDB cluster IDs.
File name where to save data source results (after running pulumi preview
).
status of the cluster.
A mapping of tags to assign to the resource.
Key: It can be up to 64 characters in length. It cannot begin with "aliyun", "acs:", "http://", or "https://". It cannot be a null string.
Value: It can be up to 128 characters in length. It cannot begin with "aliyun", "acs:", "http://", or "https://". It can be a null string.
Return
A collection of values returned by getClusters.
See also
Parameters
Builder for com.pulumi.alicloud.polardb.kotlin.inputs.GetClustersPlainArgs.