alicloud.rds.Connection
Explore with Pulumi AI
Provides an RDS connection resource to allocate an Internet connection string for RDS instance, see What is DB Connection.
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.
NOTE: Available since v1.5.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") || "tf_example";
const default = alicloud.rds.getZones({
engine: "MySQL",
engineVersion: "5.6",
});
const defaultNetwork = new alicloud.vpc.Network("default", {
vpcName: name,
cidrBlock: "172.16.0.0/16",
});
const defaultSwitch = new alicloud.vpc.Switch("default", {
vpcId: defaultNetwork.id,
cidrBlock: "172.16.0.0/24",
zoneId: _default.then(_default => _default.zones?.[0]?.id),
vswitchName: name,
});
const defaultInstance = new alicloud.rds.Instance("default", {
engine: "MySQL",
engineVersion: "5.6",
instanceType: "rds.mysql.t1.small",
instanceStorage: 10,
vswitchId: defaultSwitch.id,
instanceName: name,
});
const defaultConnection = new alicloud.rds.Connection("default", {
instanceId: defaultInstance.id,
connectionPrefix: "testabc",
});
import pulumi
import pulumi_alicloud as alicloud
config = pulumi.Config()
name = config.get("name")
if name is None:
name = "tf_example"
default = alicloud.rds.get_zones(engine="MySQL",
engine_version="5.6")
default_network = alicloud.vpc.Network("default",
vpc_name=name,
cidr_block="172.16.0.0/16")
default_switch = alicloud.vpc.Switch("default",
vpc_id=default_network.id,
cidr_block="172.16.0.0/24",
zone_id=default.zones[0].id,
vswitch_name=name)
default_instance = alicloud.rds.Instance("default",
engine="MySQL",
engine_version="5.6",
instance_type="rds.mysql.t1.small",
instance_storage=10,
vswitch_id=default_switch.id,
instance_name=name)
default_connection = alicloud.rds.Connection("default",
instance_id=default_instance.id,
connection_prefix="testabc")
package main
import (
"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, "")
name := "tf_example"
if param := cfg.Get("name"); param != "" {
name = param
}
_default, err := rds.GetZones(ctx, &rds.GetZonesArgs{
Engine: pulumi.StringRef("MySQL"),
EngineVersion: pulumi.StringRef("5.6"),
}, nil)
if err != nil {
return err
}
defaultNetwork, err := vpc.NewNetwork(ctx, "default", &vpc.NetworkArgs{
VpcName: pulumi.String(name),
CidrBlock: pulumi.String("172.16.0.0/16"),
})
if err != nil {
return err
}
defaultSwitch, err := vpc.NewSwitch(ctx, "default", &vpc.SwitchArgs{
VpcId: defaultNetwork.ID(),
CidrBlock: pulumi.String("172.16.0.0/24"),
ZoneId: pulumi.String(_default.Zones[0].Id),
VswitchName: pulumi.String(name),
})
if err != nil {
return err
}
defaultInstance, err := rds.NewInstance(ctx, "default", &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, "default", &rds.ConnectionArgs{
InstanceId: defaultInstance.ID(),
ConnectionPrefix: pulumi.String("testabc"),
})
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") ?? "tf_example";
var @default = AliCloud.Rds.GetZones.Invoke(new()
{
Engine = "MySQL",
EngineVersion = "5.6",
});
var defaultNetwork = new AliCloud.Vpc.Network("default", new()
{
VpcName = name,
CidrBlock = "172.16.0.0/16",
});
var defaultSwitch = new AliCloud.Vpc.Switch("default", new()
{
VpcId = defaultNetwork.Id,
CidrBlock = "172.16.0.0/24",
ZoneId = @default.Apply(@default => @default.Apply(getZonesResult => getZonesResult.Zones[0]?.Id)),
VswitchName = name,
});
var defaultInstance = new AliCloud.Rds.Instance("default", new()
{
Engine = "MySQL",
EngineVersion = "5.6",
InstanceType = "rds.mysql.t1.small",
InstanceStorage = 10,
VswitchId = defaultSwitch.Id,
InstanceName = name,
});
var defaultConnection = new AliCloud.Rds.Connection("default", new()
{
InstanceId = defaultInstance.Id,
ConnectionPrefix = "testabc",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.alicloud.rds.RdsFunctions;
import com.pulumi.alicloud.rds.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 name = config.get("name").orElse("tf_example");
final var default = RdsFunctions.getZones(GetZonesArgs.builder()
.engine("MySQL")
.engineVersion("5.6")
.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(default_.zones()[0].id())
.vswitchName(name)
.build());
var defaultInstance = new Instance("defaultInstance", InstanceArgs.builder()
.engine("MySQL")
.engineVersion("5.6")
.instanceType("rds.mysql.t1.small")
.instanceStorage("10")
.vswitchId(defaultSwitch.id())
.instanceName(name)
.build());
var defaultConnection = new Connection("defaultConnection", ConnectionArgs.builder()
.instanceId(defaultInstance.id())
.connectionPrefix("testabc")
.build());
}
}
configuration:
name:
type: string
default: tf_example
resources:
defaultNetwork:
type: alicloud:vpc:Network
name: default
properties:
vpcName: ${name}
cidrBlock: 172.16.0.0/16
defaultSwitch:
type: alicloud:vpc:Switch
name: default
properties:
vpcId: ${defaultNetwork.id}
cidrBlock: 172.16.0.0/24
zoneId: ${default.zones[0].id}
vswitchName: ${name}
defaultInstance:
type: alicloud:rds:Instance
name: default
properties:
engine: MySQL
engineVersion: '5.6'
instanceType: rds.mysql.t1.small
instanceStorage: '10'
vswitchId: ${defaultSwitch.id}
instanceName: ${name}
defaultConnection:
type: alicloud:rds:Connection
name: default
properties:
instanceId: ${defaultInstance.id}
connectionPrefix: testabc
variables:
default:
fn::invoke:
Function: alicloud:rds:getZones
Arguments:
engine: MySQL
engineVersion: '5.6'
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,
instance_id: Optional[str] = None,
babelfish_port: Optional[str] = None,
connection_prefix: Optional[str] = None,
port: 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:rds: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 exampleconnectionResourceResourceFromRdsconnection = new AliCloud.Rds.Connection("exampleconnectionResourceResourceFromRdsconnection", new()
{
InstanceId = "string",
BabelfishPort = "string",
ConnectionPrefix = "string",
Port = "string",
});
example, err := rds.NewConnection(ctx, "exampleconnectionResourceResourceFromRdsconnection", &rds.ConnectionArgs{
InstanceId: pulumi.String("string"),
BabelfishPort: pulumi.String("string"),
ConnectionPrefix: pulumi.String("string"),
Port: pulumi.String("string"),
})
var exampleconnectionResourceResourceFromRdsconnection = new Connection("exampleconnectionResourceResourceFromRdsconnection", ConnectionArgs.builder()
.instanceId("string")
.babelfishPort("string")
.connectionPrefix("string")
.port("string")
.build());
exampleconnection_resource_resource_from_rdsconnection = alicloud.rds.Connection("exampleconnectionResourceResourceFromRdsconnection",
instance_id="string",
babelfish_port="string",
connection_prefix="string",
port="string")
const exampleconnectionResourceResourceFromRdsconnection = new alicloud.rds.Connection("exampleconnectionResourceResourceFromRdsconnection", {
instanceId: "string",
babelfishPort: "string",
connectionPrefix: "string",
port: "string",
});
type: alicloud:rds:Connection
properties:
babelfishPort: string
connectionPrefix: string
instanceId: string
port: 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:
- Instance
Id string - The Id of instance that can run database.
- Babelfish
Port string The Tabular Data Stream (TDS) port of the instance for which Babelfish is enabled.
NOTE: This parameter applies only to ApsaraDB RDS for PostgreSQL instances. For more information about Babelfish for ApsaraDB RDS for PostgreSQL, see Introduction to Babelfish.
- Connection
Prefix 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 string - The Id of instance that can run database.
- Babelfish
Port string The Tabular Data Stream (TDS) port of the instance for which Babelfish is enabled.
NOTE: This parameter applies only to ApsaraDB RDS for PostgreSQL instances. For more information about Babelfish for ApsaraDB RDS for PostgreSQL, see Introduction to Babelfish.
- Connection
Prefix 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 String - The Id of instance that can run database.
- babelfish
Port String The Tabular Data Stream (TDS) port of the instance for which Babelfish is enabled.
NOTE: This parameter applies only to ApsaraDB RDS for PostgreSQL instances. For more information about Babelfish for ApsaraDB RDS for PostgreSQL, see Introduction to Babelfish.
- connection
Prefix 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 string - The Id of instance that can run database.
- babelfish
Port string The Tabular Data Stream (TDS) port of the instance for which Babelfish is enabled.
NOTE: This parameter applies only to ApsaraDB RDS for PostgreSQL instances. For more information about Babelfish for ApsaraDB RDS for PostgreSQL, see Introduction to Babelfish.
- connection
Prefix 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.
NOTE: This parameter applies only to ApsaraDB RDS for PostgreSQL instances. For more information about Babelfish for ApsaraDB RDS for PostgreSQL, see Introduction to Babelfish.
- 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.
- instance
Id String - The Id of instance that can run database.
- babelfish
Port String The Tabular Data Stream (TDS) port of the instance for which Babelfish is enabled.
NOTE: This parameter applies only to ApsaraDB RDS for PostgreSQL instances. For more information about Babelfish for ApsaraDB RDS for PostgreSQL, see Introduction to Babelfish.
- connection
Prefix 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:
- Connection
String string - Connection instance string.
- Id string
- The provider-assigned unique ID for this managed resource.
- Ip
Address string - The ip address of connection string.
- Connection
String string - Connection instance string.
- Id string
- The provider-assigned unique ID for this managed resource.
- Ip
Address string - The ip address of connection string.
- connection
String String - Connection instance string.
- id String
- The provider-assigned unique ID for this managed resource.
- ip
Address String - The ip address of connection string.
- connection
String string - Connection instance string.
- id string
- The provider-assigned unique ID for this managed resource.
- ip
Address 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.
- connection
String String - Connection instance string.
- id String
- The provider-assigned unique ID for this managed resource.
- ip
Address 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.
- Babelfish
Port string The Tabular Data Stream (TDS) port of the instance for which Babelfish is enabled.
NOTE: This parameter applies only to ApsaraDB RDS for PostgreSQL instances. For more information about Babelfish for ApsaraDB RDS for PostgreSQL, see Introduction to Babelfish.
- Connection
Prefix 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'.
- Connection
String string - Connection instance string.
- Instance
Id string - The Id of instance that can run database.
- Ip
Address string - The ip address of connection string.
- Port string
- Internet connection port. Valid value: [1000-5999]. Default to 3306.
- Babelfish
Port string The Tabular Data Stream (TDS) port of the instance for which Babelfish is enabled.
NOTE: This parameter applies only to ApsaraDB RDS for PostgreSQL instances. For more information about Babelfish for ApsaraDB RDS for PostgreSQL, see Introduction to Babelfish.
- Connection
Prefix 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'.
- Connection
String string - Connection instance string.
- Instance
Id string - The Id of instance that can run database.
- Ip
Address string - The ip address of connection string.
- Port string
- Internet connection port. Valid value: [1000-5999]. Default to 3306.
- babelfish
Port String The Tabular Data Stream (TDS) port of the instance for which Babelfish is enabled.
NOTE: This parameter applies only to ApsaraDB RDS for PostgreSQL instances. For more information about Babelfish for ApsaraDB RDS for PostgreSQL, see Introduction to Babelfish.
- connection
Prefix 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'.
- connection
String String - Connection instance string.
- instance
Id String - The Id of instance that can run database.
- ip
Address String - The ip address of connection string.
- port String
- Internet connection port. Valid value: [1000-5999]. Default to 3306.
- babelfish
Port string The Tabular Data Stream (TDS) port of the instance for which Babelfish is enabled.
NOTE: This parameter applies only to ApsaraDB RDS for PostgreSQL instances. For more information about Babelfish for ApsaraDB RDS for PostgreSQL, see Introduction to Babelfish.
- connection
Prefix 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'.
- connection
String string - Connection instance string.
- instance
Id string - The Id of instance that can run database.
- ip
Address 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.
NOTE: This parameter applies only to ApsaraDB RDS for PostgreSQL instances. For more information about Babelfish for ApsaraDB RDS for PostgreSQL, see Introduction to Babelfish.
- 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.
- babelfish
Port String The Tabular Data Stream (TDS) port of the instance for which Babelfish is enabled.
NOTE: This parameter applies only to ApsaraDB RDS for PostgreSQL instances. For more information about Babelfish for ApsaraDB RDS for PostgreSQL, see Introduction to Babelfish.
- connection
Prefix 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'.
- connection
String String - Connection instance string.
- instance
Id String - The Id of instance that can run database.
- ip
Address 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
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.