1. Packages
  2. Alibaba Cloud
  3. API Docs
  4. adb
  5. Connection
Alibaba Cloud v3.52.1 published on Thursday, Apr 4, 2024 by Pulumi

alicloud.adb.Connection

Explore with Pulumi AI

alicloud logo
Alibaba Cloud v3.52.1 published on Thursday, Apr 4, 2024 by Pulumi

    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 since v1.81.0.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as alicloud from "@pulumi/alicloud";
    
    const config = new pulumi.Config();
    const name = config.get("name") || "terraform-example";
    const defaultZones = alicloud.adb.getZones({});
    const defaultNetworks = alicloud.vpc.getNetworks({
        nameRegex: "^default-NODELETING$",
    });
    const defaultSwitches = Promise.all([defaultNetworks, defaultZones]).then(([defaultNetworks, defaultZones]) => alicloud.vpc.getSwitches({
        vpcId: defaultNetworks.ids?.[0],
        zoneId: defaultZones.ids?.[0],
    }));
    const vswitchId = defaultSwitches.then(defaultSwitches => defaultSwitches.ids?.[0]);
    const cluster = new alicloud.adb.DBCluster("cluster", {
        dbClusterCategory: "MixedStorage",
        mode: "flexible",
        computeResource: "8Core32GB",
        vswitchId: vswitchId,
        description: name,
    });
    const defaultConnection = new alicloud.adb.Connection("defaultConnection", {
        dbClusterId: cluster.id,
        connectionPrefix: "example",
    });
    
    import pulumi
    import pulumi_alicloud as alicloud
    
    config = pulumi.Config()
    name = config.get("name")
    if name is None:
        name = "terraform-example"
    default_zones = alicloud.adb.get_zones()
    default_networks = alicloud.vpc.get_networks(name_regex="^default-NODELETING$")
    default_switches = alicloud.vpc.get_switches(vpc_id=default_networks.ids[0],
        zone_id=default_zones.ids[0])
    vswitch_id = default_switches.ids[0]
    cluster = alicloud.adb.DBCluster("cluster",
        db_cluster_category="MixedStorage",
        mode="flexible",
        compute_resource="8Core32GB",
        vswitch_id=vswitch_id,
        description=name)
    default_connection = alicloud.adb.Connection("defaultConnection",
        db_cluster_id=cluster.id,
        connection_prefix="example")
    
    package main
    
    import (
    	"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, "")
    		name := "terraform-example"
    		if param := cfg.Get("name"); param != "" {
    			name = param
    		}
    		defaultZones, err := adb.GetZones(ctx, nil, nil)
    		if err != nil {
    			return err
    		}
    		defaultNetworks, err := vpc.GetNetworks(ctx, &vpc.GetNetworksArgs{
    			NameRegex: pulumi.StringRef("^default-NODELETING$"),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		defaultSwitches, err := vpc.GetSwitches(ctx, &vpc.GetSwitchesArgs{
    			VpcId:  pulumi.StringRef(defaultNetworks.Ids[0]),
    			ZoneId: pulumi.StringRef(defaultZones.Ids[0]),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		vswitchId := defaultSwitches.Ids[0]
    		cluster, err := adb.NewDBCluster(ctx, "cluster", &adb.DBClusterArgs{
    			DbClusterCategory: pulumi.String("MixedStorage"),
    			Mode:              pulumi.String("flexible"),
    			ComputeResource:   pulumi.String("8Core32GB"),
    			VswitchId:         pulumi.String(vswitchId),
    			Description:       pulumi.String(name),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = adb.NewConnection(ctx, "defaultConnection", &adb.ConnectionArgs{
    			DbClusterId:      cluster.ID(),
    			ConnectionPrefix: pulumi.String("example"),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using AliCloud = Pulumi.AliCloud;
    
    return await Deployment.RunAsync(() => 
    {
        var config = new Config();
        var name = config.Get("name") ?? "terraform-example";
        var defaultZones = AliCloud.Adb.GetZones.Invoke();
    
        var defaultNetworks = AliCloud.Vpc.GetNetworks.Invoke(new()
        {
            NameRegex = "^default-NODELETING$",
        });
    
        var defaultSwitches = AliCloud.Vpc.GetSwitches.Invoke(new()
        {
            VpcId = defaultNetworks.Apply(getNetworksResult => getNetworksResult.Ids[0]),
            ZoneId = defaultZones.Apply(getZonesResult => getZonesResult.Ids[0]),
        });
    
        var vswitchId = defaultSwitches.Apply(getSwitchesResult => getSwitchesResult.Ids[0]);
    
        var cluster = new AliCloud.Adb.DBCluster("cluster", new()
        {
            DbClusterCategory = "MixedStorage",
            Mode = "flexible",
            ComputeResource = "8Core32GB",
            VswitchId = vswitchId,
            Description = name,
        });
    
        var defaultConnection = new AliCloud.Adb.Connection("defaultConnection", new()
        {
            DbClusterId = cluster.Id,
            ConnectionPrefix = "example",
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.alicloud.adb.AdbFunctions;
    import com.pulumi.alicloud.adb.inputs.GetZonesArgs;
    import com.pulumi.alicloud.vpc.VpcFunctions;
    import com.pulumi.alicloud.vpc.inputs.GetNetworksArgs;
    import com.pulumi.alicloud.vpc.inputs.GetSwitchesArgs;
    import com.pulumi.alicloud.adb.DBCluster;
    import com.pulumi.alicloud.adb.DBClusterArgs;
    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 name = config.get("name").orElse("terraform-example");
            final var defaultZones = AdbFunctions.getZones();
    
            final var defaultNetworks = VpcFunctions.getNetworks(GetNetworksArgs.builder()
                .nameRegex("^default-NODELETING$")
                .build());
    
            final var defaultSwitches = VpcFunctions.getSwitches(GetSwitchesArgs.builder()
                .vpcId(defaultNetworks.applyValue(getNetworksResult -> getNetworksResult.ids()[0]))
                .zoneId(defaultZones.applyValue(getZonesResult -> getZonesResult.ids()[0]))
                .build());
    
            final var vswitchId = defaultSwitches.applyValue(getSwitchesResult -> getSwitchesResult.ids()[0]);
    
            var cluster = new DBCluster("cluster", DBClusterArgs.builder()        
                .dbClusterCategory("MixedStorage")
                .mode("flexible")
                .computeResource("8Core32GB")
                .vswitchId(vswitchId)
                .description(name)
                .build());
    
            var defaultConnection = new Connection("defaultConnection", ConnectionArgs.builder()        
                .dbClusterId(cluster.id())
                .connectionPrefix("example")
                .build());
    
        }
    }
    
    configuration:
      name:
        type: string
        default: terraform-example
    resources:
      cluster:
        type: alicloud:adb:DBCluster
        properties:
          dbClusterCategory: MixedStorage
          mode: flexible
          computeResource: 8Core32GB
          vswitchId: ${vswitchId}
          description: ${name}
      defaultConnection:
        type: alicloud:adb:Connection
        properties:
          dbClusterId: ${cluster.id}
          connectionPrefix: example
    variables:
      defaultZones:
        fn::invoke:
          Function: alicloud:adb:getZones
          Arguments: {}
      defaultNetworks:
        fn::invoke:
          Function: alicloud:vpc:getNetworks
          Arguments:
            nameRegex: ^default-NODELETING$
      defaultSwitches:
        fn::invoke:
          Function: alicloud:vpc:getSwitches
          Arguments:
            vpcId: ${defaultNetworks.ids[0]}
            zoneId: ${defaultZones.ids[0]}
      vswitchId: ${defaultSwitches.ids[0]}
    

    Create Connection Resource

    Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

    Constructor syntax

    new Connection(name: string, args: ConnectionArgs, opts?: CustomResourceOptions);
    @overload
    def Connection(resource_name: str,
                   args: ConnectionArgs,
                   opts: Optional[ResourceOptions] = None)
    
    @overload
    def Connection(resource_name: str,
                   opts: Optional[ResourceOptions] = None,
                   db_cluster_id: Optional[str] = None,
                   connection_prefix: Optional[str] = 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.
    
    

    Parameters

    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.

    Example

    The following reference example uses placeholder values for all input properties.

    var connectionResource = new AliCloud.Adb.Connection("connectionResource", new()
    {
        DbClusterId = "string",
        ConnectionPrefix = "string",
    });
    
    example, err := adb.NewConnection(ctx, "connectionResource", &adb.ConnectionArgs{
    	DbClusterId:      pulumi.String("string"),
    	ConnectionPrefix: pulumi.String("string"),
    })
    
    var connectionResource = new Connection("connectionResource", ConnectionArgs.builder()        
        .dbClusterId("string")
        .connectionPrefix("string")
        .build());
    
    connection_resource = alicloud.adb.Connection("connectionResource",
        db_cluster_id="string",
        connection_prefix="string")
    
    const connectionResource = new alicloud.adb.Connection("connectionResource", {
        dbClusterId: "string",
        connectionPrefix: "string",
    });
    
    type: alicloud:adb:Connection
    properties:
        connectionPrefix: string
        dbClusterId: string
    

    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
    

    To learn more about importing existing cloud resources, see Importing resources.

    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.52.1 published on Thursday, Apr 4, 2024 by Pulumi