Alibaba Cloud

v3.28.0 published on Tuesday, Aug 16, 2022 by Pulumi

Connection

Provides an ADB connection resource to allocate an Internet connection string for ADB cluster.

NOTE: Each ADB instance will allocate a intranet connnection string automatically and its prifix is ADB instance ID. To avoid unnecessary conflict, please specified a internet connection prefix before applying the resource.

NOTE: Available in v1.81.0+.

Example Usage

using Pulumi;
using AliCloud = Pulumi.AliCloud;

class MyStack : Stack
{
    public MyStack()
    {
        var config = new Config();
        var creation = config.Get("creation") ?? "ADB";
        var name = config.Get("name") ?? "adbaccountmysql";
        var defaultZones = Output.Create(AliCloud.GetZones.InvokeAsync(new AliCloud.GetZonesArgs
        {
            AvailableResourceCreation = creation,
        }));
        var defaultNetwork = new AliCloud.Vpc.Network("defaultNetwork", new AliCloud.Vpc.NetworkArgs
        {
            VpcName = name,
            CidrBlock = "172.16.0.0/16",
        });
        var defaultSwitch = new AliCloud.Vpc.Switch("defaultSwitch", new AliCloud.Vpc.SwitchArgs
        {
            VpcId = defaultNetwork.Id,
            CidrBlock = "172.16.0.0/24",
            ZoneId = defaultZones.Apply(defaultZones => defaultZones.Zones?[0]?.Id),
            VswitchName = name,
        });
        var cluster = new AliCloud.Adb.Cluster("cluster", new AliCloud.Adb.ClusterArgs
        {
            DbClusterVersion = "3.0",
            DbClusterCategory = "Cluster",
            DbNodeClass = "C8",
            DbNodeCount = 2,
            DbNodeStorage = 200,
            PayType = "PostPaid",
            VswitchId = defaultSwitch.Id,
            Description = name,
        });
        var connection = new AliCloud.Adb.Connection("connection", new AliCloud.Adb.ConnectionArgs
        {
            DbClusterId = cluster.Id,
            ConnectionPrefix = "testabc",
        });
    }

}
package main

import (
	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud"
	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/adb"
	"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 := "ADB"
		if param := cfg.Get("creation"); param != "" {
			creation = param
		}
		name := "adbaccountmysql"
		if param := cfg.Get("name"); param != "" {
			name = param
		}
		defaultZones, err := alicloud.GetZones(ctx, &GetZonesArgs{
			AvailableResourceCreation: pulumi.StringRef(creation),
		}, nil)
		if err != nil {
			return err
		}
		defaultNetwork, err := vpc.NewNetwork(ctx, "defaultNetwork", &vpc.NetworkArgs{
			VpcName:   pulumi.String(name),
			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
		}
		cluster, err := adb.NewCluster(ctx, "cluster", &adb.ClusterArgs{
			DbClusterVersion:  pulumi.String("3.0"),
			DbClusterCategory: pulumi.String("Cluster"),
			DbNodeClass:       pulumi.String("C8"),
			DbNodeCount:       pulumi.Int(2),
			DbNodeStorage:     pulumi.Int(200),
			PayType:           pulumi.String("PostPaid"),
			VswitchId:         defaultSwitch.ID(),
			Description:       pulumi.String(name),
		})
		if err != nil {
			return err
		}
		_, err = adb.NewConnection(ctx, "connection", &adb.ConnectionArgs{
			DbClusterId:      cluster.ID(),
			ConnectionPrefix: pulumi.String("testabc"),
		})
		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.adb.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.adb.Cluster;
import com.pulumi.alicloud.adb.ClusterArgs;
import com.pulumi.alicloud.adb.Connection;
import com.pulumi.alicloud.adb.ConnectionArgs;
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("ADB");
        final var name = config.get("name").orElse("adbaccountmysql");
        final var defaultZones = AlicloudFunctions.getZones(GetZonesArgs.builder()
            .availableResourceCreation(creation)
            .build());

        var defaultNetwork = new Network("defaultNetwork", NetworkArgs.builder()        
            .vpcName(name)
            .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 cluster = new Cluster("cluster", ClusterArgs.builder()        
            .dbClusterVersion("3.0")
            .dbClusterCategory("Cluster")
            .dbNodeClass("C8")
            .dbNodeCount(2)
            .dbNodeStorage(200)
            .payType("PostPaid")
            .vswitchId(defaultSwitch.id())
            .description(name)
            .build());

        var connection = new Connection("connection", ConnectionArgs.builder()        
            .dbClusterId(cluster.id())
            .connectionPrefix("testabc")
            .build());

    }
}
import pulumi
import pulumi_alicloud as alicloud

config = pulumi.Config()
creation = config.get("creation")
if creation is None:
    creation = "ADB"
name = config.get("name")
if name is None:
    name = "adbaccountmysql"
default_zones = alicloud.get_zones(available_resource_creation=creation)
default_network = alicloud.vpc.Network("defaultNetwork",
    vpc_name=name,
    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)
cluster = alicloud.adb.Cluster("cluster",
    db_cluster_version="3.0",
    db_cluster_category="Cluster",
    db_node_class="C8",
    db_node_count=2,
    db_node_storage=200,
    pay_type="PostPaid",
    vswitch_id=default_switch.id,
    description=name)
connection = alicloud.adb.Connection("connection",
    db_cluster_id=cluster.id,
    connection_prefix="testabc")
import * as pulumi from "@pulumi/pulumi";
import * as alicloud from "@pulumi/alicloud";

const config = new pulumi.Config();
const creation = config.get("creation") || "ADB";
const name = config.get("name") || "adbaccountmysql";
const defaultZones = alicloud.getZones({
    availableResourceCreation: creation,
});
const defaultNetwork = new alicloud.vpc.Network("defaultNetwork", {
    vpcName: name,
    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 cluster = new alicloud.adb.Cluster("cluster", {
    dbClusterVersion: "3.0",
    dbClusterCategory: "Cluster",
    dbNodeClass: "C8",
    dbNodeCount: 2,
    dbNodeStorage: 200,
    payType: "PostPaid",
    vswitchId: defaultSwitch.id,
    description: name,
});
const connection = new alicloud.adb.Connection("connection", {
    dbClusterId: cluster.id,
    connectionPrefix: "testabc",
});
configuration:
  creation:
    type: string
    default: ADB
  name:
    type: string
    default: adbaccountmysql
resources:
  defaultNetwork:
    type: alicloud:vpc:Network
    properties:
      vpcName: ${name}
      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}
  cluster:
    type: alicloud:adb:Cluster
    properties:
      dbClusterVersion: 3.0
      dbClusterCategory: Cluster
      dbNodeClass: C8
      dbNodeCount: 2
      dbNodeStorage: 200
      payType: PostPaid
      vswitchId: ${defaultSwitch.id}
      description: ${name}
  connection:
    type: alicloud:adb:Connection
    properties:
      dbClusterId: ${cluster.id}
      connectionPrefix: testabc
variables:
  defaultZones:
    Fn::Invoke:
      Function: alicloud:getZones
      Arguments:
        availableResourceCreation: ${creation}

Create Connection Resource

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

name string
The unique name of the resource.
args ConnectionArgs
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 ConnectionArgs
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 ConnectionArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args ConnectionArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name String
The unique name of the resource.
args ConnectionArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

Connection 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 Connection resource accepts the following input properties:

DbClusterId string

The Id of cluster that can run database.

ConnectionPrefix string

Prefix of the cluster public 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. Default to <db_cluster_id> + tf.

DbClusterId string

The Id of cluster that can run database.

ConnectionPrefix string

Prefix of the cluster public 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. Default to <db_cluster_id> + tf.

dbClusterId String

The Id of cluster that can run database.

connectionPrefix String

Prefix of the cluster public 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. Default to <db_cluster_id> + tf.

dbClusterId string

The Id of cluster that can run database.

connectionPrefix string

Prefix of the cluster public 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. Default to <db_cluster_id> + tf.

db_cluster_id str

The Id of cluster that can run database.

connection_prefix str

Prefix of the cluster public 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. Default to <db_cluster_id> + tf.

dbClusterId String

The Id of cluster that can run database.

connectionPrefix String

Prefix of the cluster public 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. Default to <db_cluster_id> + tf.

Outputs

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

ConnectionString string

Connection cluster string.

Id string

The provider-assigned unique ID for this managed resource.

IpAddress string

The ip address of connection string.

Port string

Connection cluster port.

ConnectionString string

Connection cluster string.

Id string

The provider-assigned unique ID for this managed resource.

IpAddress string

The ip address of connection string.

Port string

Connection cluster port.

connectionString String

Connection cluster string.

id String

The provider-assigned unique ID for this managed resource.

ipAddress String

The ip address of connection string.

port String

Connection cluster port.

connectionString string

Connection cluster string.

id string

The provider-assigned unique ID for this managed resource.

ipAddress string

The ip address of connection string.

port string

Connection cluster port.

connection_string str

Connection cluster 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 port.

connectionString String

Connection cluster string.

id String

The provider-assigned unique ID for this managed resource.

ipAddress String

The ip address of connection string.

port String

Connection cluster port.

Look up Existing Connection Resource

Get an existing Connection 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?: ConnectionState, opts?: CustomResourceOptions): Connection
@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,
        ip_address: Optional[str] = None,
        port: Optional[str] = None) -> Connection
func GetConnection(ctx *Context, name string, id IDInput, state *ConnectionState, opts ...ResourceOption) (*Connection, error)
public static Connection Get(string name, Input<string> id, ConnectionState? state, CustomResourceOptions? opts = null)
public static Connection get(String name, Output<String> id, ConnectionState 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 cluster public 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. Default to <db_cluster_id> + tf.

ConnectionString string

Connection cluster string.

DbClusterId string

The Id of cluster that can run database.

IpAddress string

The ip address of connection string.

Port string

Connection cluster port.

ConnectionPrefix string

Prefix of the cluster public 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. Default to <db_cluster_id> + tf.

ConnectionString string

Connection cluster string.

DbClusterId string

The Id of cluster that can run database.

IpAddress string

The ip address of connection string.

Port string

Connection cluster port.

connectionPrefix String

Prefix of the cluster public 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. Default to <db_cluster_id> + tf.

connectionString String

Connection cluster string.

dbClusterId String

The Id of cluster that can run database.

ipAddress String

The ip address of connection string.

port String

Connection cluster port.

connectionPrefix string

Prefix of the cluster public 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. Default to <db_cluster_id> + tf.

connectionString string

Connection cluster string.

dbClusterId string

The Id of cluster that can run database.

ipAddress string

The ip address of connection string.

port string

Connection cluster port.

connection_prefix str

Prefix of the cluster public 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. Default to <db_cluster_id> + tf.

connection_string str

Connection cluster string.

db_cluster_id str

The Id of cluster that can run database.

ip_address str

The ip address of connection string.

port str

Connection cluster port.

connectionPrefix String

Prefix of the cluster public 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. Default to <db_cluster_id> + tf.

connectionString String

Connection cluster string.

dbClusterId String

The Id of cluster that can run database.

ipAddress String

The ip address of connection string.

port String

Connection cluster port.

Import

ADB connection can be imported using the id, e.g.

 $ pulumi import alicloud:adb/connection:Connection example am-12345678

Package Details

Repository
https://github.com/pulumi/pulumi-alicloud
License
Apache-2.0
Notes

This Pulumi package is based on the alicloud Terraform Provider.