1. Packages
  2. Alibaba Cloud Provider
  3. API Docs
  4. polardb
  5. getEndpoints
Alibaba Cloud v3.76.0 published on Tuesday, Apr 8, 2025 by Pulumi

alicloud.polardb.getEndpoints

Explore with Pulumi AI

Alibaba Cloud v3.76.0 published on Tuesday, Apr 8, 2025 by Pulumi

The alicloud.polardb.getEndpoints data source provides a collection of PolarDB endpoints available in Alibaba Cloud account. Filters support regular expression for the cluster name, searches by clusterId, and other filters which are listed below.

NOTE: Available since v1.68.0+.

Example Usage

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

const _this = 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.then(_this => _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.then(_this => _this.classes?.[0]?.supportedEngines?.[0]?.availableResources?.[0]?.dbNodeClass),
    vswitchId: defaultSwitch.id,
});
const polardbClustersDs = alicloud.polardb.getClustersOutput({
    descriptionRegex: cluster.description,
    status: "Running",
});
const _default = polardbClustersDs.apply(polardbClustersDs => alicloud.polardb.getEndpointsOutput({
    dbClusterId: polardbClustersDs.clusters?.[0]?.id,
}));
export const endpoint = _default.apply(_default => _default.endpoints?.[0]?.dbEndpointId);
Copy
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")
default = polardb_clusters_ds.apply(lambda polardb_clusters_ds: alicloud.polardb.get_endpoints_output(db_cluster_id=polardb_clusters_ds.clusters[0].id))
pulumi.export("endpoint", default.endpoints[0].db_endpoint_id)
Copy
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);
_default := polardbClustersDs.ApplyT(func(polardbClustersDs polardb.GetClustersResult) (polardb.GetEndpointsResult, error) {
return polardb.GetEndpointsResult(interface{}(polardb.GetEndpointsOutput(ctx, polardb.GetEndpointsOutputArgs{
DbClusterId: polardbClustersDs.Clusters[0].Id,
}, nil))), nil
}).(polardb.GetEndpointsResultOutput)
ctx.Export("endpoint", _default.ApplyT(func(_default polardb.GetEndpointsResult) (*string, error) {
return &default.Endpoints[0].DbEndpointId, nil
}).(pulumi.StringPtrOutput))
return nil
})
}
Copy
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 @default = AliCloud.PolarDB.GetEndpoints.Invoke(new()
    {
        DbClusterId = polardbClustersDs.Apply(getClustersResult => getClustersResult.Clusters[0]?.Id),
    });

    return new Dictionary<string, object?>
    {
        ["endpoint"] = @default.Apply(@default => @default.Apply(getEndpointsResult => getEndpointsResult.Endpoints[0]?.DbEndpointId)),
    };
});
Copy
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.inputs.GetEndpointsArgs;
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());

        final var default = PolardbFunctions.getEndpoints(GetEndpointsArgs.builder()
            .dbClusterId(polardbClustersDs.applyValue(getClustersResult -> getClustersResult).applyValue(polardbClustersDs -> polardbClustersDs.applyValue(getClustersResult -> getClustersResult.clusters()[0].id())))
            .build());

        ctx.export("endpoint", default_.applyValue(default_ -> default_.endpoints()[0].dbEndpointId()));
    }
}
Copy
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}
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:getEndpoints
      arguments:
        dbClusterId: ${polardbClustersDs.clusters[0].id}
outputs:
  endpoint: ${default.endpoints[0].dbEndpointId}
Copy

Using getEndpoints

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 getEndpoints(args: GetEndpointsArgs, opts?: InvokeOptions): Promise<GetEndpointsResult>
function getEndpointsOutput(args: GetEndpointsOutputArgs, opts?: InvokeOptions): Output<GetEndpointsResult>
Copy
def get_endpoints(db_cluster_id: Optional[str] = None,
                  db_endpoint_id: Optional[str] = None,
                  opts: Optional[InvokeOptions] = None) -> GetEndpointsResult
def get_endpoints_output(db_cluster_id: Optional[pulumi.Input[str]] = None,
                  db_endpoint_id: Optional[pulumi.Input[str]] = None,
                  opts: Optional[InvokeOptions] = None) -> Output[GetEndpointsResult]
Copy
func GetEndpoints(ctx *Context, args *GetEndpointsArgs, opts ...InvokeOption) (*GetEndpointsResult, error)
func GetEndpointsOutput(ctx *Context, args *GetEndpointsOutputArgs, opts ...InvokeOption) GetEndpointsResultOutput
Copy

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

public static class GetEndpoints 
{
    public static Task<GetEndpointsResult> InvokeAsync(GetEndpointsArgs args, InvokeOptions? opts = null)
    public static Output<GetEndpointsResult> Invoke(GetEndpointsInvokeArgs args, InvokeOptions? opts = null)
}
Copy
public static CompletableFuture<GetEndpointsResult> getEndpoints(GetEndpointsArgs args, InvokeOptions options)
public static Output<GetEndpointsResult> getEndpoints(GetEndpointsArgs args, InvokeOptions options)
Copy
fn::invoke:
  function: alicloud:polardb/getEndpoints:getEndpoints
  arguments:
    # arguments dictionary
Copy

The following arguments are supported:

DbClusterId
This property is required.
Changes to this property will trigger replacement.
string
PolarDB cluster ID.
DbEndpointId string
endpoint of the cluster.
DbClusterId
This property is required.
Changes to this property will trigger replacement.
string
PolarDB cluster ID.
DbEndpointId string
endpoint of the cluster.
dbClusterId
This property is required.
Changes to this property will trigger replacement.
String
PolarDB cluster ID.
dbEndpointId String
endpoint of the cluster.
dbClusterId
This property is required.
Changes to this property will trigger replacement.
string
PolarDB cluster ID.
dbEndpointId string
endpoint of the cluster.
db_cluster_id
This property is required.
Changes to this property will trigger replacement.
str
PolarDB cluster ID.
db_endpoint_id str
endpoint of the cluster.
dbClusterId
This property is required.
Changes to this property will trigger replacement.
String
PolarDB cluster ID.
dbEndpointId String
endpoint of the cluster.

getEndpoints Result

The following output properties are available:

DbClusterId string
Endpoints List<Pulumi.AliCloud.PolarDB.Outputs.GetEndpointsEndpoint>
A list of PolarDB cluster endpoints. Each element contains the following attributes:
Id string
The provider-assigned unique ID for this managed resource.
DbEndpointId string
The endpoint ID.
DbClusterId string
Endpoints []GetEndpointsEndpoint
A list of PolarDB cluster endpoints. Each element contains the following attributes:
Id string
The provider-assigned unique ID for this managed resource.
DbEndpointId string
The endpoint ID.
dbClusterId String
endpoints List<GetEndpointsEndpoint>
A list of PolarDB cluster endpoints. Each element contains the following attributes:
id String
The provider-assigned unique ID for this managed resource.
dbEndpointId String
The endpoint ID.
dbClusterId string
endpoints GetEndpointsEndpoint[]
A list of PolarDB cluster endpoints. Each element contains the following attributes:
id string
The provider-assigned unique ID for this managed resource.
dbEndpointId string
The endpoint ID.
db_cluster_id str
endpoints Sequence[GetEndpointsEndpoint]
A list of PolarDB cluster endpoints. Each element contains the following attributes:
id str
The provider-assigned unique ID for this managed resource.
db_endpoint_id str
The endpoint ID.
dbClusterId String
endpoints List<Property Map>
A list of PolarDB cluster endpoints. Each element contains the following attributes:
id String
The provider-assigned unique ID for this managed resource.
dbEndpointId String
The endpoint ID.

Supporting Types

GetEndpointsEndpoint

AddressItems This property is required. List<Pulumi.AliCloud.PolarDB.Inputs.GetEndpointsEndpointAddressItem>
A list of endpoint addresses. Each element contains the following attributes.
AutoAddNewNodes This property is required. string
Whether the new node is automatically added to the default cluster address.Options are Enable and Disable.
DbEndpointId This property is required. string
endpoint of the cluster.
EndpointConfig This property is required. string
The Endpoint configuration. ConsistLevel: session consistency level, value:0: final consistency,1: session consistency;LoadBalanceStrategy: load balancing strategy. Based on the automatic scheduling of load, the value is: load.
EndpointType This property is required. string
Cluster address type.Cluster: the default address of the Cluster.Primary: Primary address.Custom: Custom cluster addresses.
Nodes This property is required. string
A list of nodes that connect to the address configuration.
ReadWriteMode This property is required. string
Read-write mode:ReadWrite: readable and writable (automatic read-write separation).ReadOnly: ReadOnly.
AddressItems This property is required. []GetEndpointsEndpointAddressItem
A list of endpoint addresses. Each element contains the following attributes.
AutoAddNewNodes This property is required. string
Whether the new node is automatically added to the default cluster address.Options are Enable and Disable.
DbEndpointId This property is required. string
endpoint of the cluster.
EndpointConfig This property is required. string
The Endpoint configuration. ConsistLevel: session consistency level, value:0: final consistency,1: session consistency;LoadBalanceStrategy: load balancing strategy. Based on the automatic scheduling of load, the value is: load.
EndpointType This property is required. string
Cluster address type.Cluster: the default address of the Cluster.Primary: Primary address.Custom: Custom cluster addresses.
Nodes This property is required. string
A list of nodes that connect to the address configuration.
ReadWriteMode This property is required. string
Read-write mode:ReadWrite: readable and writable (automatic read-write separation).ReadOnly: ReadOnly.
addressItems This property is required. List<GetEndpointsEndpointAddressItem>
A list of endpoint addresses. Each element contains the following attributes.
autoAddNewNodes This property is required. String
Whether the new node is automatically added to the default cluster address.Options are Enable and Disable.
dbEndpointId This property is required. String
endpoint of the cluster.
endpointConfig This property is required. String
The Endpoint configuration. ConsistLevel: session consistency level, value:0: final consistency,1: session consistency;LoadBalanceStrategy: load balancing strategy. Based on the automatic scheduling of load, the value is: load.
endpointType This property is required. String
Cluster address type.Cluster: the default address of the Cluster.Primary: Primary address.Custom: Custom cluster addresses.
nodes This property is required. String
A list of nodes that connect to the address configuration.
readWriteMode This property is required. String
Read-write mode:ReadWrite: readable and writable (automatic read-write separation).ReadOnly: ReadOnly.
addressItems This property is required. GetEndpointsEndpointAddressItem[]
A list of endpoint addresses. Each element contains the following attributes.
autoAddNewNodes This property is required. string
Whether the new node is automatically added to the default cluster address.Options are Enable and Disable.
dbEndpointId This property is required. string
endpoint of the cluster.
endpointConfig This property is required. string
The Endpoint configuration. ConsistLevel: session consistency level, value:0: final consistency,1: session consistency;LoadBalanceStrategy: load balancing strategy. Based on the automatic scheduling of load, the value is: load.
endpointType This property is required. string
Cluster address type.Cluster: the default address of the Cluster.Primary: Primary address.Custom: Custom cluster addresses.
nodes This property is required. string
A list of nodes that connect to the address configuration.
readWriteMode This property is required. string
Read-write mode:ReadWrite: readable and writable (automatic read-write separation).ReadOnly: ReadOnly.
address_items This property is required. Sequence[GetEndpointsEndpointAddressItem]
A list of endpoint addresses. Each element contains the following attributes.
auto_add_new_nodes This property is required. str
Whether the new node is automatically added to the default cluster address.Options are Enable and Disable.
db_endpoint_id This property is required. str
endpoint of the cluster.
endpoint_config This property is required. str
The Endpoint configuration. ConsistLevel: session consistency level, value:0: final consistency,1: session consistency;LoadBalanceStrategy: load balancing strategy. Based on the automatic scheduling of load, the value is: load.
endpoint_type This property is required. str
Cluster address type.Cluster: the default address of the Cluster.Primary: Primary address.Custom: Custom cluster addresses.
nodes This property is required. str
A list of nodes that connect to the address configuration.
read_write_mode This property is required. str
Read-write mode:ReadWrite: readable and writable (automatic read-write separation).ReadOnly: ReadOnly.
addressItems This property is required. List<Property Map>
A list of endpoint addresses. Each element contains the following attributes.
autoAddNewNodes This property is required. String
Whether the new node is automatically added to the default cluster address.Options are Enable and Disable.
dbEndpointId This property is required. String
endpoint of the cluster.
endpointConfig This property is required. String
The Endpoint configuration. ConsistLevel: session consistency level, value:0: final consistency,1: session consistency;LoadBalanceStrategy: load balancing strategy. Based on the automatic scheduling of load, the value is: load.
endpointType This property is required. String
Cluster address type.Cluster: the default address of the Cluster.Primary: Primary address.Custom: Custom cluster addresses.
nodes This property is required. String
A list of nodes that connect to the address configuration.
readWriteMode This property is required. String
Read-write mode:ReadWrite: readable and writable (automatic read-write separation).ReadOnly: ReadOnly.

GetEndpointsEndpointAddressItem

ConnectionString This property is required. string
Connection instance string.
IpAddress This property is required. string
The ip address of connection string.
NetType This property is required. string
IP network type:Public or Private.
Port This property is required. string
Intranet connection port.
VpcId This property is required. string
ID of the VPC the instance belongs to.
VswitchId This property is required. string
ID of the vSwitch the cluster belongs to.
ConnectionString This property is required. string
Connection instance string.
IpAddress This property is required. string
The ip address of connection string.
NetType This property is required. string
IP network type:Public or Private.
Port This property is required. string
Intranet connection port.
VpcId This property is required. string
ID of the VPC the instance belongs to.
VswitchId This property is required. string
ID of the vSwitch the cluster belongs to.
connectionString This property is required. String
Connection instance string.
ipAddress This property is required. String
The ip address of connection string.
netType This property is required. String
IP network type:Public or Private.
port This property is required. String
Intranet connection port.
vpcId This property is required. String
ID of the VPC the instance belongs to.
vswitchId This property is required. String
ID of the vSwitch the cluster belongs to.
connectionString This property is required. string
Connection instance string.
ipAddress This property is required. string
The ip address of connection string.
netType This property is required. string
IP network type:Public or Private.
port This property is required. string
Intranet connection port.
vpcId This property is required. string
ID of the VPC the instance belongs to.
vswitchId This property is required. string
ID of the vSwitch the cluster belongs to.
connection_string This property is required. str
Connection instance string.
ip_address This property is required. str
The ip address of connection string.
net_type This property is required. str
IP network type:Public or Private.
port This property is required. str
Intranet connection port.
vpc_id This property is required. str
ID of the VPC the instance belongs to.
vswitch_id This property is required. str
ID of the vSwitch the cluster belongs to.
connectionString This property is required. String
Connection instance string.
ipAddress This property is required. String
The ip address of connection string.
netType This property is required. String
IP network type:Public or Private.
port This property is required. String
Intranet connection port.
vpcId This property is required. String
ID of the VPC the instance belongs to.
vswitchId This property is required. String
ID of the vSwitch the cluster belongs to.

Package Details

Repository
Alibaba Cloud pulumi/pulumi-alicloud
License
Apache-2.0
Notes
This Pulumi package is based on the alicloud Terraform Provider.
Alibaba Cloud v3.76.0 published on Tuesday, Apr 8, 2025 by Pulumi