ReadWriteSplittingConnection
Provides an RDS read write splitting connection resource to allocate an Intranet connection string for RDS instance.
Example Usage
using Pulumi;
using AliCloud = Pulumi.AliCloud;
class MyStack : Stack
{
public MyStack()
{
var config = new Config();
var creation = config.Get("creation") ?? "Rds";
var name = config.Get("name") ?? "dbInstancevpc";
var defaultZones = Output.Create(AliCloud.GetZones.InvokeAsync(new AliCloud.GetZonesArgs
{
AvailableResourceCreation = creation,
}));
var defaultNetwork = new AliCloud.Vpc.Network("defaultNetwork", new AliCloud.Vpc.NetworkArgs
{
CidrBlock = "172.16.0.0/16",
});
var defaultSwitch = new AliCloud.Vpc.Switch("defaultSwitch", new AliCloud.Vpc.SwitchArgs
{
AvailabilityZone = defaultZones.Apply(defaultZones => defaultZones.Zones[0].Id),
CidrBlock = "172.16.0.0/24",
VpcId = defaultNetwork.Id,
});
var defaultInstance = new AliCloud.Rds.Instance("defaultInstance", new AliCloud.Rds.InstanceArgs
{
Engine = "MySQL",
EngineVersion = "5.6",
InstanceChargeType = "Postpaid",
InstanceName = name,
InstanceStorage = 20,
InstanceType = "rds.mysql.t1.small",
SecurityIps =
{
"10.168.1.12",
"100.69.7.112",
},
VswitchId = defaultSwitch.Id,
});
var defaultReadOnlyInstance = new AliCloud.Rds.ReadOnlyInstance("defaultReadOnlyInstance", new AliCloud.Rds.ReadOnlyInstanceArgs
{
EngineVersion = defaultInstance.EngineVersion,
InstanceName = $"{name}ro",
InstanceStorage = 30,
InstanceType = defaultInstance.InstanceType,
MasterDbInstanceId = defaultInstance.Id,
VswitchId = defaultSwitch.Id,
ZoneId = defaultInstance.ZoneId,
});
var defaultReadWriteSplittingConnection = new AliCloud.Rds.ReadWriteSplittingConnection("defaultReadWriteSplittingConnection", new AliCloud.Rds.ReadWriteSplittingConnectionArgs
{
ConnectionPrefix = "t-con-123",
DistributionType = "Standard",
InstanceId = defaultInstance.Id,
});
}
}
Coming soon!
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 = "dbInstancevpc"
default_zones = alicloud.get_zones(available_resource_creation=creation)
default_network = alicloud.vpc.Network("defaultNetwork", cidr_block="172.16.0.0/16")
default_switch = alicloud.vpc.Switch("defaultSwitch",
availability_zone=default_zones.zones[0]["id"],
cidr_block="172.16.0.0/24",
vpc_id=default_network.id)
default_instance = alicloud.rds.Instance("defaultInstance",
engine="MySQL",
engine_version="5.6",
instance_charge_type="Postpaid",
instance_name=name,
instance_storage="20",
instance_type="rds.mysql.t1.small",
security_ips=[
"10.168.1.12",
"100.69.7.112",
],
vswitch_id=default_switch.id)
default_read_only_instance = alicloud.rds.ReadOnlyInstance("defaultReadOnlyInstance",
engine_version=default_instance.engine_version,
instance_name=f"{name}ro",
instance_storage="30",
instance_type=default_instance.instance_type,
master_db_instance_id=default_instance.id,
vswitch_id=default_switch.id,
zone_id=default_instance.zone_id)
default_read_write_splitting_connection = alicloud.rds.ReadWriteSplittingConnection("defaultReadWriteSplittingConnection",
connection_prefix="t-con-123",
distribution_type="Standard",
instance_id=default_instance.id)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") || "dbInstancevpc";
const defaultZones = pulumi.output(alicloud.getZones({
availableResourceCreation: creation,
}, { async: true }));
const defaultNetwork = new alicloud.vpc.Network("default", {
cidrBlock: "172.16.0.0/16",
});
const defaultSwitch = new alicloud.vpc.Switch("default", {
availabilityZone: defaultZones.zones[0].id,
cidrBlock: "172.16.0.0/24",
vpcId: defaultNetwork.id,
});
const defaultInstance = new alicloud.rds.Instance("default", {
engine: "MySQL",
engineVersion: "5.6",
instanceChargeType: "Postpaid",
instanceName: name,
instanceStorage: 20,
instanceType: "rds.mysql.t1.small",
securityIps: [
"10.168.1.12",
"100.69.7.112",
],
vswitchId: defaultSwitch.id,
});
const defaultReadOnlyInstance = new alicloud.rds.ReadOnlyInstance("default", {
engineVersion: defaultInstance.engineVersion,
instanceName: `${name}ro`,
instanceStorage: 30,
instanceType: defaultInstance.instanceType,
masterDbInstanceId: defaultInstance.id,
vswitchId: defaultSwitch.id,
zoneId: defaultInstance.zoneId,
});
const defaultReadWriteSplittingConnection = new alicloud.rds.ReadWriteSplittingConnection("default", {
connectionPrefix: "t-con-123",
distributionType: "Standard",
instanceId: defaultInstance.id,
}, { dependsOn: [defaultReadOnlyInstance] });Create a ReadWriteSplittingConnection Resource
new ReadWriteSplittingConnection(name: string, args: ReadWriteSplittingConnectionArgs, opts?: CustomResourceOptions);def ReadWriteSplittingConnection(resource_name, opts=None, connection_prefix=None, distribution_type=None, instance_id=None, max_delay_time=None, port=None, weight=None, __props__=None);func NewReadWriteSplittingConnection(ctx *Context, name string, args ReadWriteSplittingConnectionArgs, opts ...ResourceOption) (*ReadWriteSplittingConnection, error)public ReadWriteSplittingConnection(string name, ReadWriteSplittingConnectionArgs args, CustomResourceOptions? opts = null)- name string
- The unique name of the resource.
- args ReadWriteSplittingConnectionArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- opts ResourceOptions
- A bag of options that control this resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args ReadWriteSplittingConnectionArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args ReadWriteSplittingConnectionArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
ReadWriteSplittingConnection Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Programming Model docs.
Inputs
The ReadWriteSplittingConnection resource accepts the following input properties:
- Distribution
Type string Read weight distribution mode. Values are as follows:
Standardindicates automatic weight distribution based on types,Customindicates custom weight distribution.- Instance
Id string The Id of instance that can run database.
- 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 30 characters. Default to
+ ‘rw’. - Max
Delay intTime Delay threshold, in seconds. The value range is 0 to 7200. Default to 30. Read requests are not routed to the read-only instances with a delay greater than the threshold.
- Port int
Intranet connection port. Valid value: [3001-3999]. Default to 3306.
- Weight Dictionary<string, object>
Read weight distribution. Read weights increase at a step of 100 up to 10,000. Enter weights in the following format: {“Instanceid”:“Weight”,“Instanceid”:“Weight”}. This parameter must be set when distribution_type is set to Custom.
- Distribution
Type string Read weight distribution mode. Values are as follows:
Standardindicates automatic weight distribution based on types,Customindicates custom weight distribution.- Instance
Id string The Id of instance that can run database.
- 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 30 characters. Default to
+ ‘rw’. - Max
Delay intTime Delay threshold, in seconds. The value range is 0 to 7200. Default to 30. Read requests are not routed to the read-only instances with a delay greater than the threshold.
- Port int
Intranet connection port. Valid value: [3001-3999]. Default to 3306.
- Weight map[string]interface{}
Read weight distribution. Read weights increase at a step of 100 up to 10,000. Enter weights in the following format: {“Instanceid”:“Weight”,“Instanceid”:“Weight”}. This parameter must be set when distribution_type is set to Custom.
- distribution
Type string Read weight distribution mode. Values are as follows:
Standardindicates automatic weight distribution based on types,Customindicates custom weight distribution.- instance
Id string The Id of instance that can run database.
- 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 30 characters. Default to
+ ‘rw’. - max
Delay numberTime Delay threshold, in seconds. The value range is 0 to 7200. Default to 30. Read requests are not routed to the read-only instances with a delay greater than the threshold.
- port number
Intranet connection port. Valid value: [3001-3999]. Default to 3306.
- weight {[key: string]: any}
Read weight distribution. Read weights increase at a step of 100 up to 10,000. Enter weights in the following format: {“Instanceid”:“Weight”,“Instanceid”:“Weight”}. This parameter must be set when distribution_type is set to Custom.
- distribution_
type str Read weight distribution mode. Values are as follows:
Standardindicates automatic weight distribution based on types,Customindicates custom weight distribution.- instance_
id str The Id of instance that can run database.
- 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 30 characters. Default to
+ ‘rw’. - max_
delay_ floattime Delay threshold, in seconds. The value range is 0 to 7200. Default to 30. Read requests are not routed to the read-only instances with a delay greater than the threshold.
- port float
Intranet connection port. Valid value: [3001-3999]. Default to 3306.
- weight Dict[str, Any]
Read weight distribution. Read weights increase at a step of 100 up to 10,000. Enter weights in the following format: {“Instanceid”:“Weight”,“Instanceid”:“Weight”}. This parameter must be set when distribution_type is set to Custom.
Outputs
All input properties are implicitly available as output properties. Additionally, the ReadWriteSplittingConnection resource produces the following output properties:
- Connection
String string Connection instance string.
- Id string
- The provider-assigned unique ID for this managed resource.
- Connection
String string Connection instance string.
- Id string
- The provider-assigned unique ID for this managed resource.
- connection
String string Connection instance string.
- id string
- The provider-assigned unique ID for this managed resource.
- connection_
string str Connection instance string.
- id str
- The provider-assigned unique ID for this managed resource.
Look up an Existing ReadWriteSplittingConnection Resource
Get an existing ReadWriteSplittingConnection 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?: ReadWriteSplittingConnectionState, opts?: CustomResourceOptions): ReadWriteSplittingConnectionstatic get(resource_name, id, opts=None, connection_prefix=None, connection_string=None, distribution_type=None, instance_id=None, max_delay_time=None, port=None, weight=None, __props__=None);func GetReadWriteSplittingConnection(ctx *Context, name string, id IDInput, state *ReadWriteSplittingConnectionState, opts ...ResourceOption) (*ReadWriteSplittingConnection, error)public static ReadWriteSplittingConnection Get(string name, Input<string> id, ReadWriteSplittingConnectionState? state, CustomResourceOptions? opts = null)- 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.
The following state arguments are supported:
- 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 30 characters. Default to
+ ‘rw’. - Connection
String string Connection instance string.
- Distribution
Type string Read weight distribution mode. Values are as follows:
Standardindicates automatic weight distribution based on types,Customindicates custom weight distribution.- Instance
Id string The Id of instance that can run database.
- Max
Delay intTime Delay threshold, in seconds. The value range is 0 to 7200. Default to 30. Read requests are not routed to the read-only instances with a delay greater than the threshold.
- Port int
Intranet connection port. Valid value: [3001-3999]. Default to 3306.
- Weight Dictionary<string, object>
Read weight distribution. Read weights increase at a step of 100 up to 10,000. Enter weights in the following format: {“Instanceid”:“Weight”,“Instanceid”:“Weight”}. This parameter must be set when distribution_type is set to Custom.
- 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 30 characters. Default to
+ ‘rw’. - Connection
String string Connection instance string.
- Distribution
Type string Read weight distribution mode. Values are as follows:
Standardindicates automatic weight distribution based on types,Customindicates custom weight distribution.- Instance
Id string The Id of instance that can run database.
- Max
Delay intTime Delay threshold, in seconds. The value range is 0 to 7200. Default to 30. Read requests are not routed to the read-only instances with a delay greater than the threshold.
- Port int
Intranet connection port. Valid value: [3001-3999]. Default to 3306.
- Weight map[string]interface{}
Read weight distribution. Read weights increase at a step of 100 up to 10,000. Enter weights in the following format: {“Instanceid”:“Weight”,“Instanceid”:“Weight”}. This parameter must be set when distribution_type is set to Custom.
- 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 30 characters. Default to
+ ‘rw’. - connection
String string Connection instance string.
- distribution
Type string Read weight distribution mode. Values are as follows:
Standardindicates automatic weight distribution based on types,Customindicates custom weight distribution.- instance
Id string The Id of instance that can run database.
- max
Delay numberTime Delay threshold, in seconds. The value range is 0 to 7200. Default to 30. Read requests are not routed to the read-only instances with a delay greater than the threshold.
- port number
Intranet connection port. Valid value: [3001-3999]. Default to 3306.
- weight {[key: string]: any}
Read weight distribution. Read weights increase at a step of 100 up to 10,000. Enter weights in the following format: {“Instanceid”:“Weight”,“Instanceid”:“Weight”}. This parameter must be set when distribution_type is set to Custom.
- 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 30 characters. Default to
+ ‘rw’. - connection_
string str Connection instance string.
- distribution_
type str Read weight distribution mode. Values are as follows:
Standardindicates automatic weight distribution based on types,Customindicates custom weight distribution.- instance_
id str The Id of instance that can run database.
- max_
delay_ floattime Delay threshold, in seconds. The value range is 0 to 7200. Default to 30. Read requests are not routed to the read-only instances with a delay greater than the threshold.
- port float
Intranet connection port. Valid value: [3001-3999]. Default to 3306.
- weight Dict[str, Any]
Read weight distribution. Read weights increase at a step of 100 up to 10,000. Enter weights in the following format: {“Instanceid”:“Weight”,“Instanceid”:“Weight”}. This parameter must be set when distribution_type is set to Custom.
Package Details
- Repository
- https://github.com/pulumi/pulumi-alicloud
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
alicloudTerraform Provider.