<reponame>rhysmdnz/pulumi-alicloud-rhys-hacks// *** 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.Slb
{
    /// <summary>
    /// &gt; **NOTE:** Available in v1.163.0+.
    /// 
    /// For information about server group server attachment and how to use it, see [Configure a server group server attachment](https://www.alibabacloud.com/help/en/doc-detail/35218.html).
    /// 
    /// &gt; **NOTE:** Applying this resource may conflict with applying `alicloud.slb.Listener`,
    /// and the `alicloud.slb.Listener` block should use `depends_on = [alicloud_slb_server_group_server_attachment.xxx]` to avoid it.
    /// 
    /// ## Example Usage
    /// 
    /// ```csharp
    /// using System.Collections.Generic;
    /// using System.Linq;
    /// using Pulumi;
    /// using AliCloud = Pulumi.AliCloud;
    /// 
    /// return await Deployment.RunAsync(() =&gt; 
    /// {
    ///     var config = new Config();
    ///     var slbServerGroupServerAttachment = config.Get("slbServerGroupServerAttachment") ?? "forSlbServerGroupServerAttachment";
    ///     var slbServerGroupServerAttachmentCount = config.GetNumber("slbServerGroupServerAttachmentCount") ?? 5;
    ///     var serverAttachmentZones = AliCloud.GetZones.Invoke(new()
    ///     {
    ///         AvailableDiskCategory = "cloud_efficiency",
    ///         AvailableResourceCreation = "VSwitch",
    ///     });
    /// 
    ///     var serverAttachmentInstanceTypes = AliCloud.Ecs.GetInstanceTypes.Invoke(new()
    ///     {
    ///         AvailabilityZone = serverAttachmentZones.Apply(getZonesResult =&gt; getZonesResult.Zones[0]?.Id),
    ///         CpuCoreCount = 1,
    ///         MemorySize = 2,
    ///     });
    /// 
    ///     var serverAttachmentImages = AliCloud.Ecs.GetImages.Invoke(new()
    ///     {
    ///         NameRegex = "^ubuntu_[0-9]+_[0-9]+_x64*",
    ///         MostRecent = true,
    ///         Owners = "system",
    ///     });
    /// 
    ///     var serverAttachmentNetworks = AliCloud.Vpc.GetNetworks.Invoke(new()
    ///     {
    ///         NameRegex = "default-NODELETING",
    ///     });
    /// 
    ///     var serverAttachmentSwitches = AliCloud.Vpc.GetSwitches.Invoke(new()
    ///     {
    ///         VpcId = serverAttachmentNetworks.Apply(getNetworksResult =&gt; getNetworksResult.Ids[0]),
    ///         ZoneId = serverAttachmentZones.Apply(getZonesResult =&gt; getZonesResult.Zones[0]?.Id),
    ///     });
    /// 
    ///     var serverAttachmentSecurityGroup = new AliCloud.Ecs.SecurityGroup("serverAttachmentSecurityGroup", new()
    ///     {
    ///         VpcId = serverAttachmentNetworks.Apply(getNetworksResult =&gt; getNetworksResult.Ids[0]),
    ///     });
    /// 
    ///     var serverAttachmentInstance = new List&lt;AliCloud.Ecs.Instance&gt;();
    ///     for (var rangeIndex = 0; rangeIndex &lt; slbServerGroupServerAttachmentCount; rangeIndex++)
    ///     {
    ///         var range = new { Value = rangeIndex };
    ///         serverAttachmentInstance.Add(new AliCloud.Ecs.Instance($"serverAttachmentInstance-{range.Value}", new()
    ///         {
    ///             ImageId = serverAttachmentImages.Apply(getImagesResult =&gt; getImagesResult.Images[0]?.Id),
    ///             InstanceType = serverAttachmentInstanceTypes.Apply(getInstanceTypesResult =&gt; getInstanceTypesResult.InstanceTypes[0]?.Id),
    ///             InstanceName = slbServerGroupServerAttachment,
    ///             SecurityGroups = new[]
    ///             {
    ///                 serverAttachmentSecurityGroup,
    ///             }.Select(__item =&gt; __item.Id).ToList(),
    ///             InternetChargeType = "PayByTraffic",
    ///             InternetMaxBandwidthOut = 10,
    ///             AvailabilityZone = serverAttachmentZones.Apply(getZonesResult =&gt; getZonesResult.Zones[0]?.Id),
    ///             InstanceChargeType = "PostPaid",
    ///             SystemDiskCategory = "cloud_efficiency",
    ///             VswitchId = serverAttachmentSwitches.Apply(getSwitchesResult =&gt; getSwitchesResult.Ids[0]),
    ///         }));
    ///     }
    ///     var serverAttachmentApplicationLoadBalancer = new AliCloud.Slb.ApplicationLoadBalancer("serverAttachmentApplicationLoadBalancer", new()
    ///     {
    ///         LoadBalancerName = slbServerGroupServerAttachment,
    ///         VswitchId = serverAttachmentSwitches.Apply(getSwitchesResult =&gt; getSwitchesResult.Vswitches[0]?.Id),
    ///         LoadBalancerSpec = "slb.s2.small",
    ///         AddressType = "intranet",
    ///     });
    /// 
    ///     var serverAttachmentServerGroup = new AliCloud.Slb.ServerGroup("serverAttachmentServerGroup", new()
    ///     {
    ///         LoadBalancerId = serverAttachmentApplicationLoadBalancer.Id,
    ///     });
    /// 
    ///     var serverAttachmentServerGroupServerAttachment = new List&lt;AliCloud.Slb.ServerGroupServerAttachment&gt;();
    ///     for (var rangeIndex = 0; rangeIndex &lt; slbServerGroupServerAttachmentCount; rangeIndex++)
    ///     {
    ///         var range = new { Value = rangeIndex };
    ///         serverAttachmentServerGroupServerAttachment.Add(new AliCloud.Slb.ServerGroupServerAttachment($"serverAttachmentServerGroupServerAttachment-{range.Value}", new()
    ///         {
    ///             ServerGroupId = serverAttachmentServerGroup.Id,
    ///             ServerId = serverAttachmentInstance[range.Index].Id,
    ///             Port = 8080,
    ///             Weight = 0,
    ///         }));
    ///     }
    ///     var serverAttachmentListener = new AliCloud.Slb.Listener("serverAttachmentListener", new()
    ///     {
    ///         LoadBalancerId = serverAttachmentApplicationLoadBalancer.Id,
    ///         BackendPort = 80,
    ///         FrontendPort = 80,
    ///         Protocol = "tcp",
    ///         Bandwidth = 10,
    ///         Scheduler = "rr",
    ///         ServerGroupId = serverAttachmentServerGroup.Id,
    ///     }, new CustomResourceOptions
    ///     {
    ///         DependsOn = new[]
    ///         {
    ///             serverAttachmentServerGroupServerAttachment,
    ///         },
    ///     });
    /// 
    /// });
    /// ```
    /// 
    /// ## Import
    /// 
    /// Load balancer backend server group server attachment can be imported using the id, e.g.
    /// 
    /// ```sh
    ///  $ pulumi import alicloud:slb/serverGroupServerAttachment:ServerGroupServerAttachment example &lt;server_group_id&gt;:&lt;server_id&gt;:&lt;port&gt;
    /// ```
    /// </summary>
    [AliCloudResourceType("alicloud:slb/serverGroupServerAttachment:ServerGroupServerAttachment")]
    public partial class ServerGroupServerAttachment : global::Pulumi.CustomResource
    {
        /// <summary>
        /// The description of the backend server.
        /// </summary>
        [Output("description")]
        public Output<string> Description { get; private set; } = null!;

        /// <summary>
        /// The port that is used by the backend server. Valid values: `1` to `65535`.
        /// </summary>
        [Output("port")]
        public Output<int> Port { get; private set; } = null!;

        /// <summary>
        /// The ID of the server group.
        /// </summary>
        [Output("serverGroupId")]
        public Output<string> ServerGroupId { get; private set; } = null!;

        /// <summary>
        /// The ID of the backend server. You can specify the ID of an Elastic Compute Service (ECS) instance or an elastic network interface (ENI).
        /// </summary>
        [Output("serverId")]
        public Output<string> ServerId { get; private set; } = null!;

        /// <summary>
        /// The type of backend server. Valid values: `ecs`, `eni`.
        /// </summary>
        [Output("type")]
        public Output<string> Type { get; private set; } = null!;

        /// <summary>
        /// The weight of the backend server. Valid values: `0` to `100`. Default value: `100`. If the value is set to `0`, no requests are forwarded to the backend server.
        /// </summary>
        [Output("weight")]
        public Output<int> Weight { get; private set; } = null!;


        /// <summary>
        /// Create a ServerGroupServerAttachment 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 ServerGroupServerAttachment(string name, ServerGroupServerAttachmentArgs args, CustomResourceOptions? options = null)
            : base("alicloud:slb/serverGroupServerAttachment:ServerGroupServerAttachment", name, args ?? new ServerGroupServerAttachmentArgs(), MakeResourceOptions(options, ""))
        {
        }

        private ServerGroupServerAttachment(string name, Input<string> id, ServerGroupServerAttachmentState? state = null, CustomResourceOptions? options = null)
            : base("alicloud:slb/serverGroupServerAttachment:ServerGroupServerAttachment", 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 ServerGroupServerAttachment 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 ServerGroupServerAttachment Get(string name, Input<string> id, ServerGroupServerAttachmentState? state = null, CustomResourceOptions? options = null)
        {
            return new ServerGroupServerAttachment(name, id, state, options);
        }
    }

    public sealed class ServerGroupServerAttachmentArgs : global::Pulumi.ResourceArgs
    {
        /// <summary>
        /// The description of the backend server.
        /// </summary>
        [Input("description")]
        public Input<string>? Description { get; set; }

        /// <summary>
        /// The port that is used by the backend server. Valid values: `1` to `65535`.
        /// </summary>
        [Input("port", required: true)]
        public Input<int> Port { get; set; } = null!;

        /// <summary>
        /// The ID of the server group.
        /// </summary>
        [Input("serverGroupId", required: true)]
        public Input<string> ServerGroupId { get; set; } = null!;

        /// <summary>
        /// The ID of the backend server. You can specify the ID of an Elastic Compute Service (ECS) instance or an elastic network interface (ENI).
        /// </summary>
        [Input("serverId", required: true)]
        public Input<string> ServerId { get; set; } = null!;

        /// <summary>
        /// The type of backend server. Valid values: `ecs`, `eni`.
        /// </summary>
        [Input("type")]
        public Input<string>? Type { get; set; }

        /// <summary>
        /// The weight of the backend server. Valid values: `0` to `100`. Default value: `100`. If the value is set to `0`, no requests are forwarded to the backend server.
        /// </summary>
        [Input("weight")]
        public Input<int>? Weight { get; set; }

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

    public sealed class ServerGroupServerAttachmentState : global::Pulumi.ResourceArgs
    {
        /// <summary>
        /// The description of the backend server.
        /// </summary>
        [Input("description")]
        public Input<string>? Description { get; set; }

        /// <summary>
        /// The port that is used by the backend server. Valid values: `1` to `65535`.
        /// </summary>
        [Input("port")]
        public Input<int>? Port { get; set; }

        /// <summary>
        /// The ID of the server group.
        /// </summary>
        [Input("serverGroupId")]
        public Input<string>? ServerGroupId { get; set; }

        /// <summary>
        /// The ID of the backend server. You can specify the ID of an Elastic Compute Service (ECS) instance or an elastic network interface (ENI).
        /// </summary>
        [Input("serverId")]
        public Input<string>? ServerId { get; set; }

        /// <summary>
        /// The type of backend server. Valid values: `ecs`, `eni`.
        /// </summary>
        [Input("type")]
        public Input<string>? Type { get; set; }

        /// <summary>
        /// The weight of the backend server. Valid values: `0` to `100`. Default value: `100`. If the value is set to `0`, no requests are forwarded to the backend server.
        /// </summary>
        [Input("weight")]
        public Input<int>? Weight { get; set; }

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