alicloud logo
Alibaba Cloud v3.34.0, Mar 17 23

alicloud.rds.Connection

Provides an RDS connection resource to allocate an Internet connection string for RDS instance.

NOTE: Each RDS instance will allocate a intranet connnection string automatically and its prifix is RDS instance 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") ?? "Rds";
    var name = config.Get("name") ?? "dbconnectionbasic";
    var defaultZones = AliCloud.GetZones.Invoke(new()
    {
        AvailableResourceCreation = creation,
    });

    var defaultNetwork = new AliCloud.Vpc.Network("defaultNetwork", new()
    {
        VpcName = name,
        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 instance = new AliCloud.Rds.Instance("instance", new()
    {
        Engine = "MySQL",
        EngineVersion = "5.6",
        InstanceType = "rds.mysql.t1.small",
        InstanceStorage = 10,
        VswitchId = defaultSwitch.Id,
        InstanceName = name,
    });

    var foo = new AliCloud.Rds.Connection("foo", new()
    {
        InstanceId = instance.Id,
        ConnectionPrefix = "testabc",
    });

});
package main

import (
	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud"
	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/rds"
	"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 := "Rds"
		if param := cfg.Get("creation"); param != "" {
			creation = param
		}
		name := "dbconnectionbasic"
		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{
			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
		}
		instance, err := rds.NewInstance(ctx, "instance", &rds.InstanceArgs{
			Engine:          pulumi.String("MySQL"),
			EngineVersion:   pulumi.String("5.6"),
			InstanceType:    pulumi.String("rds.mysql.t1.small"),
			InstanceStorage: pulumi.Int(10),
			VswitchId:       defaultSwitch.ID(),
			InstanceName:    pulumi.String(name),
		})
		if err != nil {
			return err
		}
		_, err = rds.NewConnection(ctx, "foo", &rds.ConnectionArgs{
			InstanceId:       instance.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.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.rds.Instance;
import com.pulumi.alicloud.rds.InstanceArgs;
import com.pulumi.alicloud.rds.Connection;
import com.pulumi.alicloud.rds.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("Rds");
        final var name = config.get("name").orElse("dbconnectionbasic");
        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 instance = new Instance("instance", InstanceArgs.builder()        
            .engine("MySQL")
            .engineVersion("5.6")
            .instanceType("rds.mysql.t1.small")
            .instanceStorage("10")
            .vswitchId(defaultSwitch.id())
            .instanceName(name)
            .build());

        var foo = new Connection("foo", ConnectionArgs.builder()        
            .instanceId(instance.id())
            .connectionPrefix("testabc")
            .build());

    }
}
import pulumi
import pulumi_alicloud as alicloud

config = pulumi.Config()
creation = config.get("creation")
if creation is None:
    creation = "Rds"
name = config.get("name")
if name is None:
    name = "dbconnectionbasic"
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)
instance = alicloud.rds.Instance("instance",
    engine="MySQL",
    engine_version="5.6",
    instance_type="rds.mysql.t1.small",
    instance_storage=10,
    vswitch_id=default_switch.id,
    instance_name=name)
foo = alicloud.rds.Connection("foo",
    instance_id=instance.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") || "Rds";
const name = config.get("name") || "dbconnectionbasic";
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 instance = new alicloud.rds.Instance("instance", {
    engine: "MySQL",
    engineVersion: "5.6",
    instanceType: "rds.mysql.t1.small",
    instanceStorage: 10,
    vswitchId: defaultSwitch.id,
    instanceName: name,
});
const foo = new alicloud.rds.Connection("foo", {
    instanceId: instance.id,
    connectionPrefix: "testabc",
});
configuration:
  creation:
    type: string
    default: Rds
  name:
    type: string
    default: dbconnectionbasic
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}
  instance:
    type: alicloud:rds:Instance
    properties:
      engine: MySQL
      engineVersion: '5.6'
      instanceType: rds.mysql.t1.small
      instanceStorage: '10'
      vswitchId: ${defaultSwitch.id}
      instanceName: ${name}
  foo:
    type: alicloud:rds:Connection
    properties:
      instanceId: ${instance.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,
               babelfish_port: Optional[str] = None,
               connection_prefix: Optional[str] = None,
               instance_id: Optional[str] = None,
               port: 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:rds: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:

InstanceId string

The Id of instance that can run database.

BabelfishPort string

The Tabular Data Stream (TDS) port of the instance for which Babelfish is enabled.

ConnectionPrefix string

Prefix of an Internet connection string. It must be checked for uniqueness. It may consist of lowercase letters, numbers, and underlines, and must start with a letter and have no more than 40 characters. Default to <instance_id> + 'tf'.

Port string

Internet connection port. Valid value: [1000-5999]. Default to 3306.

InstanceId string

The Id of instance that can run database.

BabelfishPort string

The Tabular Data Stream (TDS) port of the instance for which Babelfish is enabled.

ConnectionPrefix string

Prefix of an Internet connection string. It must be checked for uniqueness. It may consist of lowercase letters, numbers, and underlines, and must start with a letter and have no more than 40 characters. Default to <instance_id> + 'tf'.

Port string

Internet connection port. Valid value: [1000-5999]. Default to 3306.

instanceId String

The Id of instance that can run database.

babelfishPort String

The Tabular Data Stream (TDS) port of the instance for which Babelfish is enabled.

connectionPrefix String

Prefix of an Internet connection string. It must be checked for uniqueness. It may consist of lowercase letters, numbers, and underlines, and must start with a letter and have no more than 40 characters. Default to <instance_id> + 'tf'.

port String

Internet connection port. Valid value: [1000-5999]. Default to 3306.

instanceId string

The Id of instance that can run database.

babelfishPort string

The Tabular Data Stream (TDS) port of the instance for which Babelfish is enabled.

connectionPrefix string

Prefix of an Internet connection string. It must be checked for uniqueness. It may consist of lowercase letters, numbers, and underlines, and must start with a letter and have no more than 40 characters. Default to <instance_id> + 'tf'.

port string

Internet connection port. Valid value: [1000-5999]. Default to 3306.

instance_id str

The Id of instance that can run database.

babelfish_port str

The Tabular Data Stream (TDS) port of the instance for which Babelfish is enabled.

connection_prefix str

Prefix of an Internet connection string. It must be checked for uniqueness. It may consist of lowercase letters, numbers, and underlines, and must start with a letter and have no more than 40 characters. Default to <instance_id> + 'tf'.

port str

Internet connection port. Valid value: [1000-5999]. Default to 3306.

instanceId String

The Id of instance that can run database.

babelfishPort String

The Tabular Data Stream (TDS) port of the instance for which Babelfish is enabled.

connectionPrefix String

Prefix of an Internet connection string. It must be checked for uniqueness. It may consist of lowercase letters, numbers, and underlines, and must start with a letter and have no more than 40 characters. Default to <instance_id> + 'tf'.

port String

Internet connection port. Valid value: [1000-5999]. Default to 3306.

Outputs

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

ConnectionString string

Connection instance string.

Id string

The provider-assigned unique ID for this managed resource.

IpAddress string

The ip address of connection string.

ConnectionString string

Connection instance string.

Id string

The provider-assigned unique ID for this managed resource.

IpAddress string

The ip address of connection string.

connectionString String

Connection instance string.

id String

The provider-assigned unique ID for this managed resource.

ipAddress String

The ip address of connection string.

connectionString string

Connection instance string.

id string

The provider-assigned unique ID for this managed resource.

ipAddress string

The ip address of connection string.

connection_string str

Connection instance string.

id str

The provider-assigned unique ID for this managed resource.

ip_address str

The ip address of connection string.

connectionString String

Connection instance string.

id String

The provider-assigned unique ID for this managed resource.

ipAddress String

The ip address of connection string.

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,
        babelfish_port: Optional[str] = None,
        connection_prefix: Optional[str] = None,
        connection_string: Optional[str] = None,
        instance_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:
BabelfishPort string

The Tabular Data Stream (TDS) port of the instance for which Babelfish is enabled.

ConnectionPrefix string

Prefix of an Internet connection string. It must be checked for uniqueness. It may consist of lowercase letters, numbers, and underlines, and must start with a letter and have no more than 40 characters. Default to <instance_id> + 'tf'.

ConnectionString string

Connection instance string.

InstanceId string

The Id of instance that can run database.

IpAddress string

The ip address of connection string.

Port string

Internet connection port. Valid value: [1000-5999]. Default to 3306.

BabelfishPort string

The Tabular Data Stream (TDS) port of the instance for which Babelfish is enabled.

ConnectionPrefix string

Prefix of an Internet connection string. It must be checked for uniqueness. It may consist of lowercase letters, numbers, and underlines, and must start with a letter and have no more than 40 characters. Default to <instance_id> + 'tf'.

ConnectionString string

Connection instance string.

InstanceId string

The Id of instance that can run database.

IpAddress string

The ip address of connection string.

Port string

Internet connection port. Valid value: [1000-5999]. Default to 3306.

babelfishPort String

The Tabular Data Stream (TDS) port of the instance for which Babelfish is enabled.

connectionPrefix String

Prefix of an Internet connection string. It must be checked for uniqueness. It may consist of lowercase letters, numbers, and underlines, and must start with a letter and have no more than 40 characters. Default to <instance_id> + 'tf'.

connectionString String

Connection instance string.

instanceId String

The Id of instance that can run database.

ipAddress String

The ip address of connection string.

port String

Internet connection port. Valid value: [1000-5999]. Default to 3306.

babelfishPort string

The Tabular Data Stream (TDS) port of the instance for which Babelfish is enabled.

connectionPrefix string

Prefix of an Internet connection string. It must be checked for uniqueness. It may consist of lowercase letters, numbers, and underlines, and must start with a letter and have no more than 40 characters. Default to <instance_id> + 'tf'.

connectionString string

Connection instance string.

instanceId string

The Id of instance that can run database.

ipAddress string

The ip address of connection string.

port string

Internet connection port. Valid value: [1000-5999]. Default to 3306.

babelfish_port str

The Tabular Data Stream (TDS) port of the instance for which Babelfish is enabled.

connection_prefix str

Prefix of an Internet connection string. It must be checked for uniqueness. It may consist of lowercase letters, numbers, and underlines, and must start with a letter and have no more than 40 characters. Default to <instance_id> + 'tf'.

connection_string str

Connection instance string.

instance_id str

The Id of instance that can run database.

ip_address str

The ip address of connection string.

port str

Internet connection port. Valid value: [1000-5999]. Default to 3306.

babelfishPort String

The Tabular Data Stream (TDS) port of the instance for which Babelfish is enabled.

connectionPrefix String

Prefix of an Internet connection string. It must be checked for uniqueness. It may consist of lowercase letters, numbers, and underlines, and must start with a letter and have no more than 40 characters. Default to <instance_id> + 'tf'.

connectionString String

Connection instance string.

instanceId String

The Id of instance that can run database.

ipAddress String

The ip address of connection string.

port String

Internet connection port. Valid value: [1000-5999]. Default to 3306.

Import

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

 $ pulumi import alicloud:rds/connection:Connection example abc12345678

Package Details

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

This Pulumi package is based on the alicloud Terraform Provider.