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
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 defaultResourceGroups = AliCloud.ResourceManager.GetResourceGroups.Invoke(new()
{
Status = "OK",
});
var defaultNetwork = new AliCloud.Vpc.Network("defaultNetwork", new()
{
VpcName = name,
CidrBlock = "10.4.0.0/16",
});
var defaultSwitch = new AliCloud.Vpc.Switch("defaultSwitch", new()
{
VpcId = defaultNetwork.Id,
CidrBlock = "10.4.0.0/24",
ZoneId = defaultZones.Apply(getZonesResult => getZonesResult.Zones[0]?.Id),
VswitchName = name,
});
var defaultDBCluster = new AliCloud.Adb.DBCluster("defaultDBCluster", new()
{
DbClusterCategory = "Cluster",
DbNodeClass = "C8",
DbNodeCount = 4,
DbNodeStorage = 400,
Mode = "reserver",
DbClusterVersion = "3.0",
PaymentType = "PayAsYouGo",
VswitchId = defaultSwitch.Id,
Description = name,
MaintainTime = "23:00Z-00:00Z",
ResourceGroupId = defaultResourceGroups.Apply(getResourceGroupsResult => getResourceGroupsResult.Ids[0]),
SecurityIps = new[]
{
"10.168.1.12",
"10.168.1.11",
},
Tags =
{
{ "Created", "TF" },
{ "For", "example" },
},
});
var defaultConnection = new AliCloud.Adb.Connection("defaultConnection", new()
{
DbClusterId = defaultDBCluster.Id,
ConnectionPrefix = "example",
});
});
package main
import (
"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/adb"
"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/resourcemanager"
"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
}
defaultResourceGroups, err := resourcemanager.GetResourceGroups(ctx, &resourcemanager.GetResourceGroupsArgs{
Status: pulumi.StringRef("OK"),
}, nil)
if err != nil {
return err
}
defaultNetwork, err := vpc.NewNetwork(ctx, "defaultNetwork", &vpc.NetworkArgs{
VpcName: pulumi.String(name),
CidrBlock: pulumi.String("10.4.0.0/16"),
})
if err != nil {
return err
}
defaultSwitch, err := vpc.NewSwitch(ctx, "defaultSwitch", &vpc.SwitchArgs{
VpcId: defaultNetwork.ID(),
CidrBlock: pulumi.String("10.4.0.0/24"),
ZoneId: *pulumi.String(defaultZones.Zones[0].Id),
VswitchName: pulumi.String(name),
})
if err != nil {
return err
}
defaultDBCluster, err := adb.NewDBCluster(ctx, "defaultDBCluster", &adb.DBClusterArgs{
DbClusterCategory: pulumi.String("Cluster"),
DbNodeClass: pulumi.String("C8"),
DbNodeCount: pulumi.Int(4),
DbNodeStorage: pulumi.Int(400),
Mode: pulumi.String("reserver"),
DbClusterVersion: pulumi.String("3.0"),
PaymentType: pulumi.String("PayAsYouGo"),
VswitchId: defaultSwitch.ID(),
Description: pulumi.String(name),
MaintainTime: pulumi.String("23:00Z-00:00Z"),
ResourceGroupId: *pulumi.String(defaultResourceGroups.Ids[0]),
SecurityIps: pulumi.StringArray{
pulumi.String("10.168.1.12"),
pulumi.String("10.168.1.11"),
},
Tags: pulumi.AnyMap{
"Created": pulumi.Any("TF"),
"For": pulumi.Any("example"),
},
})
if err != nil {
return err
}
_, err = adb.NewConnection(ctx, "defaultConnection", &adb.ConnectionArgs{
DbClusterId: defaultDBCluster.ID(),
ConnectionPrefix: pulumi.String("example"),
})
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.adb.AdbFunctions;
import com.pulumi.alicloud.adb.inputs.GetZonesArgs;
import com.pulumi.alicloud.resourcemanager.ResourcemanagerFunctions;
import com.pulumi.alicloud.resourcemanager.inputs.GetResourceGroupsArgs;
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.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 defaultResourceGroups = ResourcemanagerFunctions.getResourceGroups(GetResourceGroupsArgs.builder()
.status("OK")
.build());
var defaultNetwork = new Network("defaultNetwork", NetworkArgs.builder()
.vpcName(name)
.cidrBlock("10.4.0.0/16")
.build());
var defaultSwitch = new Switch("defaultSwitch", SwitchArgs.builder()
.vpcId(defaultNetwork.id())
.cidrBlock("10.4.0.0/24")
.zoneId(defaultZones.applyValue(getZonesResult -> getZonesResult.zones()[0].id()))
.vswitchName(name)
.build());
var defaultDBCluster = new DBCluster("defaultDBCluster", DBClusterArgs.builder()
.dbClusterCategory("Cluster")
.dbNodeClass("C8")
.dbNodeCount("4")
.dbNodeStorage("400")
.mode("reserver")
.dbClusterVersion("3.0")
.paymentType("PayAsYouGo")
.vswitchId(defaultSwitch.id())
.description(name)
.maintainTime("23:00Z-00:00Z")
.resourceGroupId(defaultResourceGroups.applyValue(getResourceGroupsResult -> getResourceGroupsResult.ids()[0]))
.securityIps(
"10.168.1.12",
"10.168.1.11")
.tags(Map.ofEntries(
Map.entry("Created", "TF"),
Map.entry("For", "example")
))
.build());
var defaultConnection = new Connection("defaultConnection", ConnectionArgs.builder()
.dbClusterId(defaultDBCluster.id())
.connectionPrefix("example")
.build());
}
}
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_resource_groups = alicloud.resourcemanager.get_resource_groups(status="OK")
default_network = alicloud.vpc.Network("defaultNetwork",
vpc_name=name,
cidr_block="10.4.0.0/16")
default_switch = alicloud.vpc.Switch("defaultSwitch",
vpc_id=default_network.id,
cidr_block="10.4.0.0/24",
zone_id=default_zones.zones[0].id,
vswitch_name=name)
default_db_cluster = alicloud.adb.DBCluster("defaultDBCluster",
db_cluster_category="Cluster",
db_node_class="C8",
db_node_count=4,
db_node_storage=400,
mode="reserver",
db_cluster_version="3.0",
payment_type="PayAsYouGo",
vswitch_id=default_switch.id,
description=name,
maintain_time="23:00Z-00:00Z",
resource_group_id=default_resource_groups.ids[0],
security_ips=[
"10.168.1.12",
"10.168.1.11",
],
tags={
"Created": "TF",
"For": "example",
})
default_connection = alicloud.adb.Connection("defaultConnection",
db_cluster_id=default_db_cluster.id,
connection_prefix="example")
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 defaultResourceGroups = alicloud.resourcemanager.getResourceGroups({
status: "OK",
});
const defaultNetwork = new alicloud.vpc.Network("defaultNetwork", {
vpcName: name,
cidrBlock: "10.4.0.0/16",
});
const defaultSwitch = new alicloud.vpc.Switch("defaultSwitch", {
vpcId: defaultNetwork.id,
cidrBlock: "10.4.0.0/24",
zoneId: defaultZones.then(defaultZones => defaultZones.zones?.[0]?.id),
vswitchName: name,
});
const defaultDBCluster = new alicloud.adb.DBCluster("defaultDBCluster", {
dbClusterCategory: "Cluster",
dbNodeClass: "C8",
dbNodeCount: 4,
dbNodeStorage: 400,
mode: "reserver",
dbClusterVersion: "3.0",
paymentType: "PayAsYouGo",
vswitchId: defaultSwitch.id,
description: name,
maintainTime: "23:00Z-00:00Z",
resourceGroupId: defaultResourceGroups.then(defaultResourceGroups => defaultResourceGroups.ids?.[0]),
securityIps: [
"10.168.1.12",
"10.168.1.11",
],
tags: {
Created: "TF",
For: "example",
},
});
const defaultConnection = new alicloud.adb.Connection("defaultConnection", {
dbClusterId: defaultDBCluster.id,
connectionPrefix: "example",
});
configuration:
name:
type: string
default: terraform-example
resources:
defaultNetwork:
type: alicloud:vpc:Network
properties:
vpcName: ${name}
cidrBlock: 10.4.0.0/16
defaultSwitch:
type: alicloud:vpc:Switch
properties:
vpcId: ${defaultNetwork.id}
cidrBlock: 10.4.0.0/24
zoneId: ${defaultZones.zones[0].id}
vswitchName: ${name}
defaultDBCluster:
type: alicloud:adb:DBCluster
properties:
dbClusterCategory: Cluster
dbNodeClass: C8
dbNodeCount: '4'
dbNodeStorage: '400'
mode: reserver
dbClusterVersion: '3.0'
paymentType: PayAsYouGo
vswitchId: ${defaultSwitch.id}
description: ${name}
maintainTime: 23:00Z-00:00Z
resourceGroupId: ${defaultResourceGroups.ids[0]}
securityIps:
- 10.168.1.12
- 10.168.1.11
tags:
Created: TF
For: example
defaultConnection:
type: alicloud:adb:Connection
properties:
dbClusterId: ${defaultDBCluster.id}
connectionPrefix: example
variables:
defaultZones:
fn::invoke:
Function: alicloud:adb:getZones
Arguments: {}
defaultResourceGroups:
fn::invoke:
Function: alicloud:resourcemanager:getResourceGroups
Arguments:
status: OK
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:
- 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
Package Details
- Repository
- Alibaba Cloud pulumi/pulumi-alicloud
- License
- Apache-2.0
- Notes
This Pulumi package is based on the
alicloud
Terraform Provider.