Show / Hide Table of Contents

Class MasterSlaveServerGroup

A master slave server group contains two ECS instances. The master slave server group can help you to define multiple listening dimension.

NOTE: One ECS instance can be added into multiple master slave server groups.

NOTE: One master slave server group can only add two ECS instances, which are master server and slave server.

NOTE: One master slave server group can be attached with tcp/udp listeners in one load balancer.

NOTE: One Classic and Internet load balancer, its master slave server group can add Classic and VPC ECS instances.

NOTE: One Classic and Intranet load balancer, its master slave server group can only add Classic ECS instances.

NOTE: One VPC load balancer, its master slave server group can only add the same VPC ECS instances.

NOTE: Available in 1.54.0+

Example Usage

using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AliCloud = Pulumi.AliCloud;

class MyStack : Stack
{
public MyStack()
{
    var defaultZones = Output.Create(AliCloud.GetZones.InvokeAsync(new AliCloud.GetZonesArgs
    {
        AvailableDiskCategory = "cloud_efficiency",
        AvailableResourceCreation = "VSwitch",
    }));
    var defaultInstanceTypes = defaultZones.Apply(defaultZones => Output.Create(AliCloud.Ecs.GetInstanceTypes.InvokeAsync(new AliCloud.Ecs.GetInstanceTypesArgs
    {
        AvailabilityZone = defaultZones.Zones[0].Id,
        EniAmount = 2,
    })));
    var image = Output.Create(AliCloud.Ecs.GetImages.InvokeAsync(new AliCloud.Ecs.GetImagesArgs
    {
        MostRecent = true,
        NameRegex = "^ubuntu_18.*64",
        Owners = "system",
    }));
    var config = new Config();
    var name = config.Get("name") ?? "tf-testAccSlbMasterSlaveServerGroupVpc";
    var number = config.Get("number") ?? "1";
    var mainNetwork = new AliCloud.Vpc.Network("mainNetwork", new AliCloud.Vpc.NetworkArgs
    {
        CidrBlock = "172.16.0.0/16",
    });
    var mainSwitch = new AliCloud.Vpc.Switch("mainSwitch", new AliCloud.Vpc.SwitchArgs
    {
        AvailabilityZone = defaultZones.Apply(defaultZones => defaultZones.Zones[0].Id),
        CidrBlock = "172.16.0.0/16",
        VpcId = mainNetwork.Id,
    });
    var groupSecurityGroup = new AliCloud.Ecs.SecurityGroup("groupSecurityGroup", new AliCloud.Ecs.SecurityGroupArgs
    {
        VpcId = mainNetwork.Id,
    });
    var instanceInstance = new List<AliCloud.Ecs.Instance>();
    for (var rangeIndex = 0; rangeIndex < 2; rangeIndex++)
    {
        var range = new { Value = rangeIndex };
        instanceInstance.Add(new AliCloud.Ecs.Instance($"instanceInstance-{range.Value}", new AliCloud.Ecs.InstanceArgs
        {
            AvailabilityZone = defaultZones.Apply(defaultZones => defaultZones.Zones[0].Id),
            ImageId = image.Apply(image => image.Images[0].Id),
            InstanceChargeType = "PostPaid",
            InstanceName = name,
            InstanceType = defaultInstanceTypes.Apply(defaultInstanceTypes => defaultInstanceTypes.InstanceTypes[0].Id),
            InternetChargeType = "PayByTraffic",
            InternetMaxBandwidthOut = "10",
            SecurityGroups = 
            {
                groupSecurityGroup.Id,
            },
            SystemDiskCategory = "cloud_efficiency",
            VswitchId = mainSwitch.Id,
        }));
    }
    var instanceLoadBalancer = new AliCloud.Slb.LoadBalancer("instanceLoadBalancer", new AliCloud.Slb.LoadBalancerArgs
    {
        Specification = "slb.s2.small",
        VswitchId = mainSwitch.Id,
    });
    var defaultNetworkInterface = new List<AliCloud.Vpc.NetworkInterface>();
    for (var rangeIndex = 0; rangeIndex < number; rangeIndex++)
    {
        var range = new { Value = rangeIndex };
        defaultNetworkInterface.Add(new AliCloud.Vpc.NetworkInterface($"defaultNetworkInterface-{range.Value}", new AliCloud.Vpc.NetworkInterfaceArgs
        {
            SecurityGroups = 
            {
                groupSecurityGroup.Id,
            },
            VswitchId = mainSwitch.Id,
        }));
    }
    var defaultNetworkInterfaceAttachment = new List<AliCloud.Vpc.NetworkInterfaceAttachment>();
    for (var rangeIndex = 0; rangeIndex < number; rangeIndex++)
    {
        var range = new { Value = rangeIndex };
        defaultNetworkInterfaceAttachment.Add(new AliCloud.Vpc.NetworkInterfaceAttachment($"defaultNetworkInterfaceAttachment-{range.Value}", new AliCloud.Vpc.NetworkInterfaceAttachmentArgs
        {
            InstanceId = instanceInstance[0].Id,
            NetworkInterfaceId = defaultNetworkInterface.Select(__item => __item.Id).ToList()[range.Index],
        }));
    }
    var groupMasterSlaveServerGroup = new AliCloud.Slb.MasterSlaveServerGroup("groupMasterSlaveServerGroup", new AliCloud.Slb.MasterSlaveServerGroupArgs
    {
        LoadBalancerId = instanceLoadBalancer.Id,
        Servers = 
        {
            new AliCloud.Slb.Inputs.MasterSlaveServerGroupServerArgs
            {
                Port = 100,
                ServerId = instanceInstance[0].Id,
                ServerType = "Master",
                Weight = 100,
            },
            new AliCloud.Slb.Inputs.MasterSlaveServerGroupServerArgs
            {
                Port = 100,
                ServerId = instanceInstance[1].Id,
                ServerType = "Slave",
                Weight = 100,
            },
        },
    });
    var tcp = new AliCloud.Slb.Listener("tcp", new AliCloud.Slb.ListenerArgs
    {
        Bandwidth = "10",
        EstablishedTimeout = 600,
        FrontendPort = "22",
        HealthCheckConnectPort = 20,
        HealthCheckHttpCode = "http_2xx",
        HealthCheckInterval = 5,
        HealthCheckTimeout = 8,
        HealthCheckType = "tcp",
        HealthCheckUri = "/console",
        HealthyThreshold = 8,
        LoadBalancerId = instanceLoadBalancer.Id,
        MasterSlaveServerGroupId = groupMasterSlaveServerGroup.Id,
        PersistenceTimeout = 3600,
        Protocol = "tcp",
        UnhealthyThreshold = 8,
    });
}

}

Block servers

The servers mapping supports the following:

  • server_ids - (Required) A list backend server ID (ECS instance ID).
  • port - (Required) The port used by the backend server. Valid value range: [1-65535].
  • weight - (Optional) Weight of the backend server. Valid value range: [0-100]. Default to 100.
  • type - (Optional, Available in 1.51.0+) Type of the backend server. Valid value ecs, eni. Default to eni.
  • server_type - (Optional) The server type of the backend server. Valid value Master, Slave.
  • is_backup - (Removed from v1.63.0) Determine if the server is executing. Valid value 0, 1.
Inheritance
System.Object
Resource
CustomResource
MasterSlaveServerGroup
Inherited Members
CustomResource.Id
Resource.GetResourceType()
Resource.GetResourceName()
Resource.Urn
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Pulumi.AliCloud.Slb
Assembly: Pulumi.AliCloud.dll
Syntax
public class MasterSlaveServerGroup : CustomResource

Constructors

View Source

MasterSlaveServerGroup(String, MasterSlaveServerGroupArgs, CustomResourceOptions)

Create a MasterSlaveServerGroup resource with the given unique name, arguments, and options.

Declaration
public MasterSlaveServerGroup(string name, MasterSlaveServerGroupArgs args, CustomResourceOptions options = null)
Parameters
Type Name Description
System.String name

The unique name of the resource

MasterSlaveServerGroupArgs args

The arguments used to populate this resource's properties

CustomResourceOptions options

A bag of options that control this resource's behavior

Properties

View Source

DeleteProtectionValidation

Checking DeleteProtection of SLB instance before deleting. If true, this resource will not be deleted when its SLB instance enabled DeleteProtection. Default to false.

Declaration
public Output<bool?> DeleteProtectionValidation { get; }
Property Value
Type Description
Output<System.Nullable<System.Boolean>>
View Source

LoadBalancerId

The Load Balancer ID which is used to launch a new master slave server group.

Declaration
public Output<string> LoadBalancerId { get; }
Property Value
Type Description
Output<System.String>
View Source

Name

Name of the master slave server group.

Declaration
public Output<string> Name { get; }
Property Value
Type Description
Output<System.String>
View Source

Servers

A list of ECS instances to be added. Only two ECS instances can be supported in one resource. It contains six sub-fields as Block server follows.

Declaration
public Output<ImmutableArray<MasterSlaveServerGroupServer>> Servers { get; }
Property Value
Type Description
Output<System.Collections.Immutable.ImmutableArray<MasterSlaveServerGroupServer>>

Methods

View Source

Get(String, Input<String>, MasterSlaveServerGroupState, CustomResourceOptions)

Get an existing MasterSlaveServerGroup resource's state with the given name, ID, and optional extra properties used to qualify the lookup.

Declaration
public static MasterSlaveServerGroup Get(string name, Input<string> id, MasterSlaveServerGroupState state = null, CustomResourceOptions options = null)
Parameters
Type Name Description
System.String name

The unique name of the resulting resource.

Input<System.String> id

The unique provider ID of the resource to lookup.

MasterSlaveServerGroupState state

Any extra arguments used during the lookup.

CustomResourceOptions options

A bag of options that control this resource's behavior

Returns
Type Description
MasterSlaveServerGroup
  • View Source
Back to top Copyright 2016-2020, Pulumi Corporation.