alicloud.adb.Connection
Explore with Pulumi AI
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 default = alicloud.adb.getZones({});
const defaultGetNetworks = alicloud.vpc.getNetworks({
nameRegex: "^default-NODELETING$",
});
const defaultGetSwitches = Promise.all([defaultGetNetworks, _default]).then(([defaultGetNetworks, _default]) => alicloud.vpc.getSwitches({
vpcId: defaultGetNetworks.ids?.[0],
zoneId: _default.ids?.[0],
}));
const vswitchId = defaultGetSwitches.then(defaultGetSwitches => defaultGetSwitches.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("default", {
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 = alicloud.adb.get_zones()
default_get_networks = alicloud.vpc.get_networks(name_regex="^default-NODELETING$")
default_get_switches = alicloud.vpc.get_switches(vpc_id=default_get_networks.ids[0],
zone_id=default.ids[0])
vswitch_id = default_get_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("default",
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
}
_default, err := adb.GetZones(ctx, &adb.GetZonesArgs{}, nil)
if err != nil {
return err
}
defaultGetNetworks, err := vpc.GetNetworks(ctx, &vpc.GetNetworksArgs{
NameRegex: pulumi.StringRef("^default-NODELETING$"),
}, nil)
if err != nil {
return err
}
defaultGetSwitches, err := vpc.GetSwitches(ctx, &vpc.GetSwitchesArgs{
VpcId: pulumi.StringRef(defaultGetNetworks.Ids[0]),
ZoneId: pulumi.StringRef(_default.Ids[0]),
}, nil)
if err != nil {
return err
}
vswitchId := defaultGetSwitches.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, "default", &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 @default = AliCloud.Adb.GetZones.Invoke();
var defaultGetNetworks = AliCloud.Vpc.GetNetworks.Invoke(new()
{
NameRegex = "^default-NODELETING$",
});
var defaultGetSwitches = AliCloud.Vpc.GetSwitches.Invoke(new()
{
VpcId = defaultGetNetworks.Apply(getNetworksResult => getNetworksResult.Ids[0]),
ZoneId = @default.Apply(getZonesResult => getZonesResult.Ids[0]),
});
var vswitchId = defaultGetSwitches.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("default", 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 default = AdbFunctions.getZones();
final var defaultGetNetworks = VpcFunctions.getNetworks(GetNetworksArgs.builder()
.nameRegex("^default-NODELETING$")
.build());
final var defaultGetSwitches = VpcFunctions.getSwitches(GetSwitchesArgs.builder()
.vpcId(defaultGetNetworks.applyValue(getNetworksResult -> getNetworksResult.ids()[0]))
.zoneId(default_.ids()[0])
.build());
final var vswitchId = defaultGetSwitches.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
name: default
properties:
dbClusterId: ${cluster.id}
connectionPrefix: example
variables:
default:
fn::invoke:
Function: alicloud:adb:getZones
Arguments: {}
defaultGetNetworks:
fn::invoke:
Function: alicloud:vpc:getNetworks
Arguments:
nameRegex: ^default-NODELETING$
defaultGetSwitches:
fn::invoke:
Function: alicloud:vpc:getSwitches
Arguments:
vpcId: ${defaultGetNetworks.ids[0]}
zoneId: ${default.ids[0]}
vswitchId: ${defaultGetSwitches.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.
Constructor 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
In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.
The Connection resource accepts the following input properties:
- Db
Cluster stringId - The Id of cluster that can run database.
- Connection
Prefix 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 stringId - The Id of cluster that can run database.
- Connection
Prefix 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 StringId - The Id of cluster that can run database.
- connection
Prefix 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 stringId - The Id of cluster that can run database.
- connection
Prefix 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_ strid - 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
.
- db
Cluster StringId - The Id of cluster that can run database.
- connection
Prefix 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:
- Connection
String string - Connection cluster string.
- Id string
- The provider-assigned unique ID for this managed resource.
- Ip
Address string - The ip address of connection string.
- Port string
- Connection cluster port.
- Connection
String string - Connection cluster string.
- Id string
- The provider-assigned unique ID for this managed resource.
- Ip
Address string - The ip address of connection string.
- Port string
- Connection cluster port.
- connection
String String - Connection cluster string.
- id String
- The provider-assigned unique ID for this managed resource.
- ip
Address String - The ip address of connection string.
- port String
- Connection cluster port.
- connection
String string - Connection cluster string.
- id string
- The provider-assigned unique ID for this managed resource.
- ip
Address 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.
- connection
String String - Connection cluster string.
- id String
- The provider-assigned unique ID for this managed resource.
- ip
Address 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.
- Connection
Prefix 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
. - Connection
String string - Connection cluster string.
- Db
Cluster stringId - The Id of cluster that can run database.
- Ip
Address string - The ip address of connection string.
- Port string
- Connection cluster port.
- Connection
Prefix 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
. - Connection
String string - Connection cluster string.
- Db
Cluster stringId - The Id of cluster that can run database.
- Ip
Address string - The ip address of connection string.
- Port string
- Connection cluster port.
- connection
Prefix 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
. - connection
String String - Connection cluster string.
- db
Cluster StringId - The Id of cluster that can run database.
- ip
Address String - The ip address of connection string.
- port String
- Connection cluster port.
- connection
Prefix 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
. - connection
String string - Connection cluster string.
- db
Cluster stringId - The Id of cluster that can run database.
- ip
Address 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_ strid - The Id of cluster that can run database.
- ip_
address str - The ip address of connection string.
- port str
- Connection cluster port.
- connection
Prefix 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
. - connection
String String - Connection cluster string.
- db
Cluster StringId - The Id of cluster that can run database.
- ip
Address 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.