alicloud logo
Alibaba Cloud v3.34.0, Mar 17 23

alicloud.polardb.EndpointAddress

Provides a PolarDB endpoint address resource to allocate an Internet endpoint address string for PolarDB instance.

NOTE: Available in v1.68.0+. Each PolarDB instance will allocate a intranet connection string automatically and its prefix is Cluster ID. To avoid unnecessary conflict, please specified a internet connection prefix before applying the resource.

Example Usage

using System.Collections.Generic;
using Pulumi;
using AliCloud = Pulumi.AliCloud;

return await Deployment.RunAsync(() => 
{
    var config = new Config();
    var creation = config.Get("creation") ?? "PolarDB";
    var name = config.Get("name") ?? "polardbconnectionbasic";
    var defaultZones = AliCloud.GetZones.Invoke(new()
    {
        AvailableResourceCreation = creation,
    });

    var defaultNetwork = new AliCloud.Vpc.Network("defaultNetwork", new()
    {
        CidrBlock = "172.16.0.0/16",
    });

    var defaultSwitch = new AliCloud.Vpc.Switch("defaultSwitch", new()
    {
        VpcId = defaultNetwork.Id,
        CidrBlock = "172.16.0.0/24",
        ZoneId = defaultZones.Apply(getZonesResult => getZonesResult.Zones[0]?.Id),
        VswitchName = name,
    });

    var defaultCluster = new AliCloud.PolarDB.Cluster("defaultCluster", new()
    {
        DbType = "MySQL",
        DbVersion = "8.0",
        PayType = "PostPaid",
        DbNodeClass = "polar.mysql.x4.large",
        VswitchId = defaultSwitch.Id,
        Description = name,
    });

    var defaultEndpoints = AliCloud.PolarDB.GetEndpoints.Invoke(new()
    {
        DbClusterId = defaultCluster.Id,
    });

    var endpoint = new AliCloud.PolarDB.EndpointAddress("endpoint", new()
    {
        DbClusterId = defaultCluster.Id,
        DbEndpointId = defaultEndpoints.Apply(getEndpointsResult => getEndpointsResult.Endpoints[0]?.DbEndpointId),
        ConnectionPrefix = "testpolardbconn",
        NetType = "Public",
    });

});
package main

import (
	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud"
	"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"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi/config"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		cfg := config.New(ctx, "")
		creation := "PolarDB"
		if param := cfg.Get("creation"); param != "" {
			creation = param
		}
		name := "polardbconnectionbasic"
		if param := cfg.Get("name"); param != "" {
			name = param
		}
		defaultZones, err := alicloud.GetZones(ctx, &alicloud.GetZonesArgs{
			AvailableResourceCreation: pulumi.StringRef(creation),
		}, nil)
		if err != nil {
			return err
		}
		defaultNetwork, err := vpc.NewNetwork(ctx, "defaultNetwork", &vpc.NetworkArgs{
			CidrBlock: pulumi.String("172.16.0.0/16"),
		})
		if err != nil {
			return err
		}
		defaultSwitch, err := vpc.NewSwitch(ctx, "defaultSwitch", &vpc.SwitchArgs{
			VpcId:       defaultNetwork.ID(),
			CidrBlock:   pulumi.String("172.16.0.0/24"),
			ZoneId:      *pulumi.String(defaultZones.Zones[0].Id),
			VswitchName: pulumi.String(name),
		})
		if err != nil {
			return err
		}
		defaultCluster, err := polardb.NewCluster(ctx, "defaultCluster", &polardb.ClusterArgs{
			DbType:      pulumi.String("MySQL"),
			DbVersion:   pulumi.String("8.0"),
			PayType:     pulumi.String("PostPaid"),
			DbNodeClass: pulumi.String("polar.mysql.x4.large"),
			VswitchId:   defaultSwitch.ID(),
			Description: pulumi.String(name),
		})
		if err != nil {
			return err
		}
		defaultEndpoints := polardb.GetEndpointsOutput(ctx, polardb.GetEndpointsOutputArgs{
			DbClusterId: defaultCluster.ID(),
		}, nil)
		_, err = polardb.NewEndpointAddress(ctx, "endpoint", &polardb.EndpointAddressArgs{
			DbClusterId: defaultCluster.ID(),
			DbEndpointId: defaultEndpoints.ApplyT(func(defaultEndpoints polardb.GetEndpointsResult) (*string, error) {
				return &defaultEndpoints.Endpoints[0].DbEndpointId, nil
			}).(pulumi.StringPtrOutput),
			ConnectionPrefix: pulumi.String("testpolardbconn"),
			NetType:          pulumi.String("Public"),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.alicloud.AlicloudFunctions;
import com.pulumi.alicloud.inputs.GetZonesArgs;
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.PolardbFunctions;
import com.pulumi.alicloud.polardb.inputs.GetEndpointsArgs;
import com.pulumi.alicloud.polardb.EndpointAddress;
import com.pulumi.alicloud.polardb.EndpointAddressArgs;
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 config = ctx.config();
        final var creation = config.get("creation").orElse("PolarDB");
        final var name = config.get("name").orElse("polardbconnectionbasic");
        final var defaultZones = AlicloudFunctions.getZones(GetZonesArgs.builder()
            .availableResourceCreation(creation)
            .build());

        var defaultNetwork = new Network("defaultNetwork", NetworkArgs.builder()        
            .cidrBlock("172.16.0.0/16")
            .build());

        var defaultSwitch = new Switch("defaultSwitch", SwitchArgs.builder()        
            .vpcId(defaultNetwork.id())
            .cidrBlock("172.16.0.0/24")
            .zoneId(defaultZones.applyValue(getZonesResult -> getZonesResult.zones()[0].id()))
            .vswitchName(name)
            .build());

        var defaultCluster = new Cluster("defaultCluster", ClusterArgs.builder()        
            .dbType("MySQL")
            .dbVersion("8.0")
            .payType("PostPaid")
            .dbNodeClass("polar.mysql.x4.large")
            .vswitchId(defaultSwitch.id())
            .description(name)
            .build());

        final var defaultEndpoints = PolardbFunctions.getEndpoints(GetEndpointsArgs.builder()
            .dbClusterId(defaultCluster.id())
            .build());

        var endpoint = new EndpointAddress("endpoint", EndpointAddressArgs.builder()        
            .dbClusterId(defaultCluster.id())
            .dbEndpointId(defaultEndpoints.applyValue(getEndpointsResult -> getEndpointsResult).applyValue(defaultEndpoints -> defaultEndpoints.applyValue(getEndpointsResult -> getEndpointsResult.endpoints()[0].dbEndpointId())))
            .connectionPrefix("testpolardbconn")
            .netType("Public")
            .build());

    }
}
import pulumi
import pulumi_alicloud as alicloud

config = pulumi.Config()
creation = config.get("creation")
if creation is None:
    creation = "PolarDB"
name = config.get("name")
if name is None:
    name = "polardbconnectionbasic"
default_zones = alicloud.get_zones(available_resource_creation=creation)
default_network = alicloud.vpc.Network("defaultNetwork", cidr_block="172.16.0.0/16")
default_switch = alicloud.vpc.Switch("defaultSwitch",
    vpc_id=default_network.id,
    cidr_block="172.16.0.0/24",
    zone_id=default_zones.zones[0].id,
    vswitch_name=name)
default_cluster = alicloud.polardb.Cluster("defaultCluster",
    db_type="MySQL",
    db_version="8.0",
    pay_type="PostPaid",
    db_node_class="polar.mysql.x4.large",
    vswitch_id=default_switch.id,
    description=name)
default_endpoints = alicloud.polardb.get_endpoints_output(db_cluster_id=default_cluster.id)
endpoint = alicloud.polardb.EndpointAddress("endpoint",
    db_cluster_id=default_cluster.id,
    db_endpoint_id=default_endpoints.endpoints[0].db_endpoint_id,
    connection_prefix="testpolardbconn",
    net_type="Public")
import * as pulumi from "@pulumi/pulumi";
import * as alicloud from "@pulumi/alicloud";

const config = new pulumi.Config();
const creation = config.get("creation") || "PolarDB";
const name = config.get("name") || "polardbconnectionbasic";
const defaultZones = alicloud.getZones({
    availableResourceCreation: creation,
});
const defaultNetwork = new alicloud.vpc.Network("defaultNetwork", {cidrBlock: "172.16.0.0/16"});
const defaultSwitch = new alicloud.vpc.Switch("defaultSwitch", {
    vpcId: defaultNetwork.id,
    cidrBlock: "172.16.0.0/24",
    zoneId: defaultZones.then(defaultZones => defaultZones.zones?.[0]?.id),
    vswitchName: name,
});
const defaultCluster = new alicloud.polardb.Cluster("defaultCluster", {
    dbType: "MySQL",
    dbVersion: "8.0",
    payType: "PostPaid",
    dbNodeClass: "polar.mysql.x4.large",
    vswitchId: defaultSwitch.id,
    description: name,
});
const defaultEndpoints = alicloud.polardb.getEndpointsOutput({
    dbClusterId: defaultCluster.id,
});
const endpoint = new alicloud.polardb.EndpointAddress("endpoint", {
    dbClusterId: defaultCluster.id,
    dbEndpointId: defaultEndpoints.apply(defaultEndpoints => defaultEndpoints.endpoints?.[0]?.dbEndpointId),
    connectionPrefix: "testpolardbconn",
    netType: "Public",
});
configuration:
  creation:
    type: string
    default: PolarDB
  name:
    type: string
    default: polardbconnectionbasic
resources:
  defaultNetwork:
    type: alicloud:vpc:Network
    properties:
      cidrBlock: 172.16.0.0/16
  defaultSwitch:
    type: alicloud:vpc:Switch
    properties:
      vpcId: ${defaultNetwork.id}
      cidrBlock: 172.16.0.0/24
      zoneId: ${defaultZones.zones[0].id}
      vswitchName: ${name}
  defaultCluster:
    type: alicloud:polardb:Cluster
    properties:
      dbType: MySQL
      dbVersion: '8.0'
      payType: PostPaid
      dbNodeClass: polar.mysql.x4.large
      vswitchId: ${defaultSwitch.id}
      description: ${name}
  endpoint:
    type: alicloud:polardb:EndpointAddress
    properties:
      dbClusterId: ${defaultCluster.id}
      dbEndpointId: ${defaultEndpoints.endpoints[0].dbEndpointId}
      connectionPrefix: testpolardbconn
      netType: Public
variables:
  defaultZones:
    fn::invoke:
      Function: alicloud:getZones
      Arguments:
        availableResourceCreation: ${creation}
  defaultEndpoints:
    fn::invoke:
      Function: alicloud:polardb:getEndpoints
      Arguments:
        dbClusterId: ${defaultCluster.id}

Create EndpointAddress Resource

new EndpointAddress(name: string, args: EndpointAddressArgs, opts?: CustomResourceOptions);
@overload
def EndpointAddress(resource_name: str,
                    opts: Optional[ResourceOptions] = None,
                    connection_prefix: Optional[str] = None,
                    db_cluster_id: Optional[str] = None,
                    db_endpoint_id: Optional[str] = None,
                    net_type: Optional[str] = None)
@overload
def EndpointAddress(resource_name: str,
                    args: EndpointAddressArgs,
                    opts: Optional[ResourceOptions] = None)
func NewEndpointAddress(ctx *Context, name string, args EndpointAddressArgs, opts ...ResourceOption) (*EndpointAddress, error)
public EndpointAddress(string name, EndpointAddressArgs args, CustomResourceOptions? opts = null)
public EndpointAddress(String name, EndpointAddressArgs args)
public EndpointAddress(String name, EndpointAddressArgs args, CustomResourceOptions options)
type: alicloud:polardb:EndpointAddress
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

name string
The unique name of the resource.
args EndpointAddressArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name str
The unique name of the resource.
args EndpointAddressArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name string
The unique name of the resource.
args EndpointAddressArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args EndpointAddressArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name String
The unique name of the resource.
args EndpointAddressArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

EndpointAddress Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

The EndpointAddress resource accepts the following input properties:

DbClusterId string

The Id of cluster that can run database.

DbEndpointId string

The Id of endpoint that can run database.

ConnectionPrefix string

Prefix of the specified endpoint. The prefix must be 6 to 30 characters in length, and can contain lowercase letters, digits, and hyphens (-), must start with a letter and end with a digit or letter.

NetType string

Internet connection net type. Valid value: Public. Default to Public. Currently supported only Public.

DbClusterId string

The Id of cluster that can run database.

DbEndpointId string

The Id of endpoint that can run database.

ConnectionPrefix string

Prefix of the specified endpoint. The prefix must be 6 to 30 characters in length, and can contain lowercase letters, digits, and hyphens (-), must start with a letter and end with a digit or letter.

NetType string

Internet connection net type. Valid value: Public. Default to Public. Currently supported only Public.

dbClusterId String

The Id of cluster that can run database.

dbEndpointId String

The Id of endpoint that can run database.

connectionPrefix String

Prefix of the specified endpoint. The prefix must be 6 to 30 characters in length, and can contain lowercase letters, digits, and hyphens (-), must start with a letter and end with a digit or letter.

netType String

Internet connection net type. Valid value: Public. Default to Public. Currently supported only Public.

dbClusterId string

The Id of cluster that can run database.

dbEndpointId string

The Id of endpoint that can run database.

connectionPrefix string

Prefix of the specified endpoint. The prefix must be 6 to 30 characters in length, and can contain lowercase letters, digits, and hyphens (-), must start with a letter and end with a digit or letter.

netType string

Internet connection net type. Valid value: Public. Default to Public. Currently supported only Public.

db_cluster_id str

The Id of cluster that can run database.

db_endpoint_id str

The Id of endpoint that can run database.

connection_prefix str

Prefix of the specified endpoint. The prefix must be 6 to 30 characters in length, and can contain lowercase letters, digits, and hyphens (-), must start with a letter and end with a digit or letter.

net_type str

Internet connection net type. Valid value: Public. Default to Public. Currently supported only Public.

dbClusterId String

The Id of cluster that can run database.

dbEndpointId String

The Id of endpoint that can run database.

connectionPrefix String

Prefix of the specified endpoint. The prefix must be 6 to 30 characters in length, and can contain lowercase letters, digits, and hyphens (-), must start with a letter and end with a digit or letter.

netType String

Internet connection net type. Valid value: Public. Default to Public. Currently supported only Public.

Outputs

All input properties are implicitly available as output properties. Additionally, the EndpointAddress resource produces the following output properties:

ConnectionString string

Connection cluster or endpoint string.

Id string

The provider-assigned unique ID for this managed resource.

IpAddress string

The ip address of connection string.

Port string

Connection cluster or endpoint port.

ConnectionString string

Connection cluster or endpoint string.

Id string

The provider-assigned unique ID for this managed resource.

IpAddress string

The ip address of connection string.

Port string

Connection cluster or endpoint port.

connectionString String

Connection cluster or endpoint string.

id String

The provider-assigned unique ID for this managed resource.

ipAddress String

The ip address of connection string.

port String

Connection cluster or endpoint port.

connectionString string

Connection cluster or endpoint string.

id string

The provider-assigned unique ID for this managed resource.

ipAddress string

The ip address of connection string.

port string

Connection cluster or endpoint port.

connection_string str

Connection cluster or endpoint string.

id str

The provider-assigned unique ID for this managed resource.

ip_address str

The ip address of connection string.

port str

Connection cluster or endpoint port.

connectionString String

Connection cluster or endpoint string.

id String

The provider-assigned unique ID for this managed resource.

ipAddress String

The ip address of connection string.

port String

Connection cluster or endpoint port.

Look up Existing EndpointAddress Resource

Get an existing EndpointAddress resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: EndpointAddressState, opts?: CustomResourceOptions): EndpointAddress
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        connection_prefix: Optional[str] = None,
        connection_string: Optional[str] = None,
        db_cluster_id: Optional[str] = None,
        db_endpoint_id: Optional[str] = None,
        ip_address: Optional[str] = None,
        net_type: Optional[str] = None,
        port: Optional[str] = None) -> EndpointAddress
func GetEndpointAddress(ctx *Context, name string, id IDInput, state *EndpointAddressState, opts ...ResourceOption) (*EndpointAddress, error)
public static EndpointAddress Get(string name, Input<string> id, EndpointAddressState? state, CustomResourceOptions? opts = null)
public static EndpointAddress get(String name, Output<String> id, EndpointAddressState state, CustomResourceOptions options)
Resource lookup is not supported in YAML
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
The following state arguments are supported:
ConnectionPrefix string

Prefix of the specified endpoint. The prefix must be 6 to 30 characters in length, and can contain lowercase letters, digits, and hyphens (-), must start with a letter and end with a digit or letter.

ConnectionString string

Connection cluster or endpoint string.

DbClusterId string

The Id of cluster that can run database.

DbEndpointId string

The Id of endpoint that can run database.

IpAddress string

The ip address of connection string.

NetType string

Internet connection net type. Valid value: Public. Default to Public. Currently supported only Public.

Port string

Connection cluster or endpoint port.

ConnectionPrefix string

Prefix of the specified endpoint. The prefix must be 6 to 30 characters in length, and can contain lowercase letters, digits, and hyphens (-), must start with a letter and end with a digit or letter.

ConnectionString string

Connection cluster or endpoint string.

DbClusterId string

The Id of cluster that can run database.

DbEndpointId string

The Id of endpoint that can run database.

IpAddress string

The ip address of connection string.

NetType string

Internet connection net type. Valid value: Public. Default to Public. Currently supported only Public.

Port string

Connection cluster or endpoint port.

connectionPrefix String

Prefix of the specified endpoint. The prefix must be 6 to 30 characters in length, and can contain lowercase letters, digits, and hyphens (-), must start with a letter and end with a digit or letter.

connectionString String

Connection cluster or endpoint string.

dbClusterId String

The Id of cluster that can run database.

dbEndpointId String

The Id of endpoint that can run database.

ipAddress String

The ip address of connection string.

netType String

Internet connection net type. Valid value: Public. Default to Public. Currently supported only Public.

port String

Connection cluster or endpoint port.

connectionPrefix string

Prefix of the specified endpoint. The prefix must be 6 to 30 characters in length, and can contain lowercase letters, digits, and hyphens (-), must start with a letter and end with a digit or letter.

connectionString string

Connection cluster or endpoint string.

dbClusterId string

The Id of cluster that can run database.

dbEndpointId string

The Id of endpoint that can run database.

ipAddress string

The ip address of connection string.

netType string

Internet connection net type. Valid value: Public. Default to Public. Currently supported only Public.

port string

Connection cluster or endpoint port.

connection_prefix str

Prefix of the specified endpoint. The prefix must be 6 to 30 characters in length, and can contain lowercase letters, digits, and hyphens (-), must start with a letter and end with a digit or letter.

connection_string str

Connection cluster or endpoint string.

db_cluster_id str

The Id of cluster that can run database.

db_endpoint_id str

The Id of endpoint that can run database.

ip_address str

The ip address of connection string.

net_type str

Internet connection net type. Valid value: Public. Default to Public. Currently supported only Public.

port str

Connection cluster or endpoint port.

connectionPrefix String

Prefix of the specified endpoint. The prefix must be 6 to 30 characters in length, and can contain lowercase letters, digits, and hyphens (-), must start with a letter and end with a digit or letter.

connectionString String

Connection cluster or endpoint string.

dbClusterId String

The Id of cluster that can run database.

dbEndpointId String

The Id of endpoint that can run database.

ipAddress String

The ip address of connection string.

netType String

Internet connection net type. Valid value: Public. Default to Public. Currently supported only Public.

port String

Connection cluster or endpoint port.

Import

PolarDB endpoint address can be imported using the id, e.g.

 $ pulumi import alicloud:polardb/endpointAddress:EndpointAddress example pc-abc123456:pe-abc123456

Package Details

Repository
Alibaba Cloud pulumi/pulumi-alicloud
License
Apache-2.0
Notes

This Pulumi package is based on the alicloud Terraform Provider.