1. Packages
  2. Alibaba Cloud
  3. API Docs
  4. polardb
  5. getEndpoints
Alibaba Cloud v3.57.1 published on Wednesday, Jun 26, 2024 by Pulumi

alicloud.polardb.getEndpoints

Explore with Pulumi AI

alicloud logo
Alibaba Cloud v3.57.1 published on Wednesday, Jun 26, 2024 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);
    
    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)
    
    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.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
    })
    }
    
    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)),
        };
    });
    
    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()));
        }
    }
    
    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}
    

    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>
    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]
    func GetEndpoints(ctx *Context, args *GetEndpointsArgs, opts ...InvokeOption) (*GetEndpointsResult, error)
    func GetEndpointsOutput(ctx *Context, args *GetEndpointsOutputArgs, opts ...InvokeOption) GetEndpointsResultOutput

    > 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)
    }
    public static CompletableFuture<GetEndpointsResult> getEndpoints(GetEndpointsArgs args, InvokeOptions options)
    // Output-based functions aren't available in Java yet
    
    fn::invoke:
      function: alicloud:polardb/getEndpoints:getEndpoints
      arguments:
        # arguments dictionary

    The following arguments are supported:

    DbClusterId string
    PolarDB cluster ID.
    DbEndpointId string
    endpoint of the cluster.
    DbClusterId string
    PolarDB cluster ID.
    DbEndpointId string
    endpoint of the cluster.
    dbClusterId String
    PolarDB cluster ID.
    dbEndpointId String
    endpoint of the cluster.
    dbClusterId string
    PolarDB cluster ID.
    dbEndpointId string
    endpoint of the cluster.
    db_cluster_id str
    PolarDB cluster ID.
    db_endpoint_id str
    endpoint of the cluster.
    dbClusterId 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 List<Pulumi.AliCloud.PolarDB.Inputs.GetEndpointsEndpointAddressItem>
    A list of endpoint addresses. Each element contains the following attributes.
    AutoAddNewNodes string
    Whether the new node is automatically added to the default cluster address.Options are Enable and Disable.
    DbEndpointId string
    endpoint of the cluster.
    EndpointConfig 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 string
    Cluster address type.Cluster: the default address of the Cluster.Primary: Primary address.Custom: Custom cluster addresses.
    Nodes string
    A list of nodes that connect to the address configuration.
    ReadWriteMode string
    Read-write mode:ReadWrite: readable and writable (automatic read-write separation).ReadOnly: ReadOnly.
    AddressItems []GetEndpointsEndpointAddressItem
    A list of endpoint addresses. Each element contains the following attributes.
    AutoAddNewNodes string
    Whether the new node is automatically added to the default cluster address.Options are Enable and Disable.
    DbEndpointId string
    endpoint of the cluster.
    EndpointConfig 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 string
    Cluster address type.Cluster: the default address of the Cluster.Primary: Primary address.Custom: Custom cluster addresses.
    Nodes string
    A list of nodes that connect to the address configuration.
    ReadWriteMode string
    Read-write mode:ReadWrite: readable and writable (automatic read-write separation).ReadOnly: ReadOnly.
    addressItems List<GetEndpointsEndpointAddressItem>
    A list of endpoint addresses. Each element contains the following attributes.
    autoAddNewNodes String
    Whether the new node is automatically added to the default cluster address.Options are Enable and Disable.
    dbEndpointId String
    endpoint of the cluster.
    endpointConfig 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 String
    Cluster address type.Cluster: the default address of the Cluster.Primary: Primary address.Custom: Custom cluster addresses.
    nodes String
    A list of nodes that connect to the address configuration.
    readWriteMode String
    Read-write mode:ReadWrite: readable and writable (automatic read-write separation).ReadOnly: ReadOnly.
    addressItems GetEndpointsEndpointAddressItem[]
    A list of endpoint addresses. Each element contains the following attributes.
    autoAddNewNodes string
    Whether the new node is automatically added to the default cluster address.Options are Enable and Disable.
    dbEndpointId string
    endpoint of the cluster.
    endpointConfig 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 string
    Cluster address type.Cluster: the default address of the Cluster.Primary: Primary address.Custom: Custom cluster addresses.
    nodes string
    A list of nodes that connect to the address configuration.
    readWriteMode string
    Read-write mode:ReadWrite: readable and writable (automatic read-write separation).ReadOnly: ReadOnly.
    address_items Sequence[GetEndpointsEndpointAddressItem]
    A list of endpoint addresses. Each element contains the following attributes.
    auto_add_new_nodes str
    Whether the new node is automatically added to the default cluster address.Options are Enable and Disable.
    db_endpoint_id str
    endpoint of the cluster.
    endpoint_config 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 str
    Cluster address type.Cluster: the default address of the Cluster.Primary: Primary address.Custom: Custom cluster addresses.
    nodes str
    A list of nodes that connect to the address configuration.
    read_write_mode str
    Read-write mode:ReadWrite: readable and writable (automatic read-write separation).ReadOnly: ReadOnly.
    addressItems List<Property Map>
    A list of endpoint addresses. Each element contains the following attributes.
    autoAddNewNodes String
    Whether the new node is automatically added to the default cluster address.Options are Enable and Disable.
    dbEndpointId String
    endpoint of the cluster.
    endpointConfig 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 String
    Cluster address type.Cluster: the default address of the Cluster.Primary: Primary address.Custom: Custom cluster addresses.
    nodes String
    A list of nodes that connect to the address configuration.
    readWriteMode String
    Read-write mode:ReadWrite: readable and writable (automatic read-write separation).ReadOnly: ReadOnly.

    GetEndpointsEndpointAddressItem

    ConnectionString string
    Connection instance string.
    IpAddress string
    The ip address of connection string.
    NetType string
    IP network type:Public or Private.
    Port string
    Intranet connection port.
    VpcId string
    ID of the VPC the instance belongs to.
    VswitchId string
    ID of the VSwitch the cluster belongs to.
    ConnectionString string
    Connection instance string.
    IpAddress string
    The ip address of connection string.
    NetType string
    IP network type:Public or Private.
    Port string
    Intranet connection port.
    VpcId string
    ID of the VPC the instance belongs to.
    VswitchId string
    ID of the VSwitch the cluster belongs to.
    connectionString String
    Connection instance string.
    ipAddress String
    The ip address of connection string.
    netType String
    IP network type:Public or Private.
    port String
    Intranet connection port.
    vpcId String
    ID of the VPC the instance belongs to.
    vswitchId String
    ID of the VSwitch the cluster belongs to.
    connectionString string
    Connection instance string.
    ipAddress string
    The ip address of connection string.
    netType string
    IP network type:Public or Private.
    port string
    Intranet connection port.
    vpcId string
    ID of the VPC the instance belongs to.
    vswitchId string
    ID of the VSwitch the cluster belongs to.
    connection_string str
    Connection instance string.
    ip_address str
    The ip address of connection string.
    net_type str
    IP network type:Public or Private.
    port str
    Intranet connection port.
    vpc_id str
    ID of the VPC the instance belongs to.
    vswitch_id str
    ID of the VSwitch the cluster belongs to.
    connectionString String
    Connection instance string.
    ipAddress String
    The ip address of connection string.
    netType String
    IP network type:Public or Private.
    port String
    Intranet connection port.
    vpcId String
    ID of the VPC the instance belongs to.
    vswitchId 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.
    alicloud logo
    Alibaba Cloud v3.57.1 published on Wednesday, Jun 26, 2024 by Pulumi