// *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***

using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Threading.Tasks;
using Pulumi.Serialization;

namespace Pulumi.AliCloud.Rds
{
    /// <summary>
    /// Provides an RDS read write splitting connection resource to allocate an Intranet connection string for RDS instance.
    /// 
    /// ## Example Usage
    /// 
    /// ```csharp
    /// using System.Collections.Generic;
    /// using Pulumi;
    /// using AliCloud = Pulumi.AliCloud;
    /// 
    /// return await Deployment.RunAsync(() =&gt; 
    /// {
    ///     var config = new Config();
    ///     var creation = config.Get("creation") ?? "Rds";
    ///     var name = config.Get("name") ?? "dbInstancevpc";
    ///     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 =&gt; getZonesResult.Zones[0]?.Id),
    ///         VswitchName = name,
    ///     });
    /// 
    ///     var defaultInstance = new AliCloud.Rds.Instance("defaultInstance", new()
    ///     {
    ///         Engine = "MySQL",
    ///         EngineVersion = "5.6",
    ///         InstanceType = "rds.mysql.t1.small",
    ///         InstanceStorage = 20,
    ///         InstanceChargeType = "Postpaid",
    ///         InstanceName = name,
    ///         VswitchId = defaultSwitch.Id,
    ///         SecurityIps = new[]
    ///         {
    ///             "10.168.1.12",
    ///             "192.168.127.12",
    ///         },
    ///     });
    /// 
    ///     var defaultReadOnlyInstance = new AliCloud.Rds.ReadOnlyInstance("defaultReadOnlyInstance", new()
    ///     {
    ///         MasterDbInstanceId = defaultInstance.Id,
    ///         ZoneId = defaultInstance.ZoneId,
    ///         EngineVersion = defaultInstance.EngineVersion,
    ///         InstanceType = defaultInstance.InstanceType,
    ///         InstanceStorage = 30,
    ///         InstanceName = $"{name}ro",
    ///         VswitchId = defaultSwitch.Id,
    ///     });
    /// 
    ///     var defaultReadWriteSplittingConnection = new AliCloud.Rds.ReadWriteSplittingConnection("defaultReadWriteSplittingConnection", new()
    ///     {
    ///         InstanceId = defaultInstance.Id,
    ///         ConnectionPrefix = "t-con-123",
    ///         DistributionType = "Standard",
    ///     }, new CustomResourceOptions
    ///     {
    ///         DependsOn = new[]
    ///         {
    ///             defaultReadOnlyInstance,
    ///         },
    ///     });
    /// 
    /// });
    /// ```
    /// 
    /// &gt; **NOTE:** Resource `alicloud.rds.ReadWriteSplittingConnection` should be created after `alicloud.rds.ReadOnlyInstance`, so the `depends_on` statement is necessary.
    /// 
    /// ## Import
    /// 
    /// RDS read write splitting connection can be imported using the id, e.g.
    /// 
    /// ```sh
    ///  $ pulumi import alicloud:rds/readWriteSplittingConnection:ReadWriteSplittingConnection example abc12345678
    /// ```
    /// </summary>
    [AliCloudResourceType("alicloud:rds/readWriteSplittingConnection:ReadWriteSplittingConnection")]
    public partial class ReadWriteSplittingConnection : global::Pulumi.CustomResource
    {
        /// <summary>
        /// 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 &lt;instance_id&gt; + 'rw'.
        /// </summary>
        [Output("connectionPrefix")]
        public Output<string?> ConnectionPrefix { get; private set; } = null!;

        /// <summary>
        /// Connection instance string.
        /// </summary>
        [Output("connectionString")]
        public Output<string> ConnectionString { get; private set; } = null!;

        /// <summary>
        /// Read weight distribution mode. Values are as follows: `Standard` indicates automatic weight distribution based on types, `Custom` indicates custom weight distribution.
        /// </summary>
        [Output("distributionType")]
        public Output<string> DistributionType { get; private set; } = null!;

        /// <summary>
        /// The Id of instance that can run database.
        /// </summary>
        [Output("instanceId")]
        public Output<string> InstanceId { get; private set; } = null!;

        /// <summary>
        /// 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.
        /// </summary>
        [Output("maxDelayTime")]
        public Output<int> MaxDelayTime { get; private set; } = null!;

        /// <summary>
        /// Intranet connection port. Valid value: [3001-3999]. Default to 3306.
        /// </summary>
        [Output("port")]
        public Output<int> Port { get; private set; } = null!;

        /// <summary>
        /// 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.
        /// </summary>
        [Output("weight")]
        public Output<ImmutableDictionary<string, object>?> Weight { get; private set; } = null!;


        /// <summary>
        /// Create a ReadWriteSplittingConnection resource with the given unique name, arguments, and options.
        /// </summary>
        ///
        /// <param name="name">The unique name of the resource</param>
        /// <param name="args">The arguments used to populate this resource's properties</param>
        /// <param name="options">A bag of options that control this resource's behavior</param>
        public ReadWriteSplittingConnection(string name, ReadWriteSplittingConnectionArgs args, CustomResourceOptions? options = null)
            : base("alicloud:rds/readWriteSplittingConnection:ReadWriteSplittingConnection", name, args ?? new ReadWriteSplittingConnectionArgs(), MakeResourceOptions(options, ""))
        {
        }

        private ReadWriteSplittingConnection(string name, Input<string> id, ReadWriteSplittingConnectionState? state = null, CustomResourceOptions? options = null)
            : base("alicloud:rds/readWriteSplittingConnection:ReadWriteSplittingConnection", name, state, MakeResourceOptions(options, id))
        {
        }

        private static CustomResourceOptions MakeResourceOptions(CustomResourceOptions? options, Input<string>? id)
        {
            var defaultOptions = new CustomResourceOptions
            {
                Version = Utilities.Version,
                PluginDownloadURL = "github://api.github.com/rhysmdnz/pulumi-alicloud",
            };
            var merged = CustomResourceOptions.Merge(defaultOptions, options);
            // Override the ID if one was specified for consistency with other language SDKs.
            merged.Id = id ?? merged.Id;
            return merged;
        }
        /// <summary>
        /// Get an existing ReadWriteSplittingConnection resource's state with the given name, ID, and optional extra
        /// properties used to qualify the lookup.
        /// </summary>
        ///
        /// <param name="name">The unique name of the resulting resource.</param>
        /// <param name="id">The unique provider ID of the resource to lookup.</param>
        /// <param name="state">Any extra arguments used during the lookup.</param>
        /// <param name="options">A bag of options that control this resource's behavior</param>
        public static ReadWriteSplittingConnection Get(string name, Input<string> id, ReadWriteSplittingConnectionState? state = null, CustomResourceOptions? options = null)
        {
            return new ReadWriteSplittingConnection(name, id, state, options);
        }
    }

    public sealed class ReadWriteSplittingConnectionArgs : global::Pulumi.ResourceArgs
    {
        /// <summary>
        /// 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 &lt;instance_id&gt; + 'rw'.
        /// </summary>
        [Input("connectionPrefix")]
        public Input<string>? ConnectionPrefix { get; set; }

        /// <summary>
        /// Read weight distribution mode. Values are as follows: `Standard` indicates automatic weight distribution based on types, `Custom` indicates custom weight distribution.
        /// </summary>
        [Input("distributionType", required: true)]
        public Input<string> DistributionType { get; set; } = null!;

        /// <summary>
        /// The Id of instance that can run database.
        /// </summary>
        [Input("instanceId", required: true)]
        public Input<string> InstanceId { get; set; } = null!;

        /// <summary>
        /// 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.
        /// </summary>
        [Input("maxDelayTime")]
        public Input<int>? MaxDelayTime { get; set; }

        /// <summary>
        /// Intranet connection port. Valid value: [3001-3999]. Default to 3306.
        /// </summary>
        [Input("port")]
        public Input<int>? Port { get; set; }

        [Input("weight")]
        private InputMap<object>? _weight;

        /// <summary>
        /// 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.
        /// </summary>
        public InputMap<object> Weight
        {
            get => _weight ?? (_weight = new InputMap<object>());
            set => _weight = value;
        }

        public ReadWriteSplittingConnectionArgs()
        {
        }
        public static new ReadWriteSplittingConnectionArgs Empty => new ReadWriteSplittingConnectionArgs();
    }

    public sealed class ReadWriteSplittingConnectionState : global::Pulumi.ResourceArgs
    {
        /// <summary>
        /// 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 &lt;instance_id&gt; + 'rw'.
        /// </summary>
        [Input("connectionPrefix")]
        public Input<string>? ConnectionPrefix { get; set; }

        /// <summary>
        /// Connection instance string.
        /// </summary>
        [Input("connectionString")]
        public Input<string>? ConnectionString { get; set; }

        /// <summary>
        /// Read weight distribution mode. Values are as follows: `Standard` indicates automatic weight distribution based on types, `Custom` indicates custom weight distribution.
        /// </summary>
        [Input("distributionType")]
        public Input<string>? DistributionType { get; set; }

        /// <summary>
        /// The Id of instance that can run database.
        /// </summary>
        [Input("instanceId")]
        public Input<string>? InstanceId { get; set; }

        /// <summary>
        /// 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.
        /// </summary>
        [Input("maxDelayTime")]
        public Input<int>? MaxDelayTime { get; set; }

        /// <summary>
        /// Intranet connection port. Valid value: [3001-3999]. Default to 3306.
        /// </summary>
        [Input("port")]
        public Input<int>? Port { get; set; }

        [Input("weight")]
        private InputMap<object>? _weight;

        /// <summary>
        /// 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.
        /// </summary>
        public InputMap<object> Weight
        {
            get => _weight ?? (_weight = new InputMap<object>());
            set => _weight = value;
        }

        public ReadWriteSplittingConnectionState()
        {
        }
        public static new ReadWriteSplittingConnectionState Empty => new ReadWriteSplittingConnectionState();
    }
}
