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+
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.
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,
});
}
}
Coming soon!
import pulumi
import pulumi_alicloud as alicloud
default_zones = alicloud.get_zones(available_disk_category="cloud_efficiency",
available_resource_creation="VSwitch")
default_instance_types = alicloud.ecs.get_instance_types(availability_zone=default_zones.zones[0]["id"],
eni_amount=2)
image = alicloud.ecs.get_images(most_recent=True,
name_regex="^ubuntu_18.*64",
owners="system")
config = pulumi.Config()
name = config.get("name")
if name is None:
name = "tf-testAccSlbMasterSlaveServerGroupVpc"
number = config.get("number")
if number is None:
number = "1"
main_network = alicloud.vpc.Network("mainNetwork", cidr_block="172.16.0.0/16")
main_switch = alicloud.vpc.Switch("mainSwitch",
availability_zone=default_zones.zones[0]["id"],
cidr_block="172.16.0.0/16",
vpc_id=main_network.id)
group_security_group = alicloud.ecs.SecurityGroup("groupSecurityGroup", vpc_id=main_network.id)
instance_instance = []
for range in [{"value": i} for i in range(0, 2)]:
instance_instance.append(alicloud.ecs.Instance(f"instanceInstance-{range['value']}",
availability_zone=default_zones.zones[0]["id"],
image_id=image.images[0]["id"],
instance_charge_type="PostPaid",
instance_name=name,
instance_type=default_instance_types.instance_types[0]["id"],
internet_charge_type="PayByTraffic",
internet_max_bandwidth_out="10",
security_groups=[group_security_group.id],
system_disk_category="cloud_efficiency",
vswitch_id=main_switch.id))
instance_load_balancer = alicloud.slb.LoadBalancer("instanceLoadBalancer",
specification="slb.s2.small",
vswitch_id=main_switch.id)
default_network_interface = []
for range in [{"value": i} for i in range(0, number)]:
default_network_interface.append(alicloud.vpc.NetworkInterface(f"defaultNetworkInterface-{range['value']}",
security_groups=[group_security_group.id],
vswitch_id=main_switch.id))
default_network_interface_attachment = []
for range in [{"value": i} for i in range(0, number)]:
default_network_interface_attachment.append(alicloud.vpc.NetworkInterfaceAttachment(f"defaultNetworkInterfaceAttachment-{range['value']}",
instance_id=instance_instance[0].id,
network_interface_id=[__item.id for __item in default_network_interface][range["index"]]))
group_master_slave_server_group = alicloud.slb.MasterSlaveServerGroup("groupMasterSlaveServerGroup",
load_balancer_id=instance_load_balancer.id,
servers=[
{
"port": 100,
"serverId": instance_instance[0].id,
"server_type": "Master",
"weight": 100,
},
{
"port": 100,
"serverId": instance_instance[1].id,
"server_type": "Slave",
"weight": 100,
},
])
tcp = alicloud.slb.Listener("tcp",
bandwidth="10",
established_timeout=600,
frontend_port="22",
health_check_connect_port=20,
health_check_http_code="http_2xx",
health_check_interval=5,
health_check_timeout=8,
health_check_type="tcp",
health_check_uri="/console",
healthy_threshold=8,
load_balancer_id=instance_load_balancer.id,
master_slave_server_group_id=group_master_slave_server_group.id,
persistence_timeout=3600,
protocol="tcp",
unhealthy_threshold=8)import * as pulumi from "@pulumi/pulumi";
import * as alicloud from "@pulumi/alicloud";
const config = new pulumi.Config();
const name = config.get("name") || "tf-testAccSlbMasterSlaveServerGroupVpc";
const number = config.get("number") || "1";
const defaultZones = pulumi.output(alicloud.getZones({
availableDiskCategory: "cloud_efficiency",
availableResourceCreation: "VSwitch",
}, { async: true }));
const defaultInstanceTypes = defaultZones.apply(defaultZones => alicloud.ecs.getInstanceTypes({
availabilityZone: defaultZones.zones[0].id,
eniAmount: 2,
}, { async: true }));
const image = pulumi.output(alicloud.ecs.getImages({
mostRecent: true,
nameRegex: "^ubuntu_18.*64",
owners: "system",
}, { async: true }));
const mainNetwork = new alicloud.vpc.Network("main", {
cidrBlock: "172.16.0.0/16",
});
const mainSwitch = new alicloud.vpc.Switch("main", {
availabilityZone: defaultZones.zones[0].id,
cidrBlock: "172.16.0.0/16",
vpcId: mainNetwork.id,
});
const groupSecurityGroup = new alicloud.ecs.SecurityGroup("group", {
vpcId: mainNetwork.id,
});
const instanceInstance: alicloud.ecs.Instance[] = [];
for (let i = 0; i < 2; i++) {
instanceInstance.push(new alicloud.ecs.Instance(`instance-${i}`, {
availabilityZone: defaultZones.zones[0].id,
imageId: image.images[0].id,
instanceChargeType: "PostPaid",
instanceName: name,
instanceType: defaultInstanceTypes.instanceTypes[0].id,
internetChargeType: "PayByTraffic",
internetMaxBandwidthOut: 10,
securityGroups: [groupSecurityGroup.id],
systemDiskCategory: "cloud_efficiency",
vswitchId: mainSwitch.id,
}));
}
const instanceLoadBalancer = new alicloud.slb.LoadBalancer("instance", {
specification: "slb.s2.small",
vswitchId: mainSwitch.id,
});
const defaultNetworkInterface: alicloud.vpc.NetworkInterface[] = [];
for (let i = 0; i < number; i++) {
defaultNetworkInterface.push(new alicloud.vpc.NetworkInterface(`default-${i}`, {
securityGroups: [groupSecurityGroup.id],
vswitchId: mainSwitch.id,
}));
}
const defaultNetworkInterfaceAttachment: alicloud.vpc.NetworkInterfaceAttachment[] = [];
for (let i = 0; i < number; i++) {
defaultNetworkInterfaceAttachment.push(new alicloud.vpc.NetworkInterfaceAttachment(`default-${i}`, {
instanceId: instanceInstance[0].id,
networkInterfaceId: pulumi.all(defaultNetworkInterface.map(v => v.id)).apply(id => id.map(v => v)[i]),
}));
}
const groupMasterSlaveServerGroup = new alicloud.slb.MasterSlaveServerGroup("group", {
loadBalancerId: instanceLoadBalancer.id,
servers: [
{
port: 100,
serverId: instanceInstance[0].id,
serverType: "Master",
weight: 100,
},
{
port: 100,
serverId: instanceInstance[1].id,
serverType: "Slave",
weight: 100,
},
],
});
const tcp = new alicloud.slb.Listener("tcp", {
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,
});Create a MasterSlaveServerGroup Resource
new MasterSlaveServerGroup(name: string, args: MasterSlaveServerGroupArgs, opts?: CustomResourceOptions);def MasterSlaveServerGroup(resource_name, opts=None, delete_protection_validation=None, load_balancer_id=None, name=None, servers=None, __props__=None);func NewMasterSlaveServerGroup(ctx *Context, name string, args MasterSlaveServerGroupArgs, opts ...ResourceOption) (*MasterSlaveServerGroup, error)public MasterSlaveServerGroup(string name, MasterSlaveServerGroupArgs args, CustomResourceOptions? opts = null)- name string
- The unique name of the resource.
- args MasterSlaveServerGroupArgs
- 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 MasterSlaveServerGroupArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args MasterSlaveServerGroupArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
MasterSlaveServerGroup Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Programming Model docs.
Inputs
The MasterSlaveServerGroup resource accepts the following input properties:
- Load
Balancer stringId The Load Balancer ID which is used to launch a new master slave server group.
- Delete
Protection boolValidation Checking DeleteProtection of SLB instance before deleting. If true, this resource will not be deleted when its SLB instance enabled DeleteProtection. Default to false.
- Name string
Name of the master slave server group.
- Servers
List<Pulumi.
Ali Cloud. Slb. Inputs. Master Slave Server Group Server Args> 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 serverfollows.
- Load
Balancer stringId The Load Balancer ID which is used to launch a new master slave server group.
- Delete
Protection boolValidation Checking DeleteProtection of SLB instance before deleting. If true, this resource will not be deleted when its SLB instance enabled DeleteProtection. Default to false.
- Name string
Name of the master slave server group.
- Servers
[]Master
Slave Server Group Server 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 serverfollows.
- load
Balancer stringId The Load Balancer ID which is used to launch a new master slave server group.
- delete
Protection booleanValidation Checking DeleteProtection of SLB instance before deleting. If true, this resource will not be deleted when its SLB instance enabled DeleteProtection. Default to false.
- name string
Name of the master slave server group.
- servers
Master
Slave Server Group Server[] 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 serverfollows.
- load_
balancer_ strid The Load Balancer ID which is used to launch a new master slave server group.
- delete_
protection_ boolvalidation Checking DeleteProtection of SLB instance before deleting. If true, this resource will not be deleted when its SLB instance enabled DeleteProtection. Default to false.
- name str
Name of the master slave server group.
- servers
List[Master
Slave Server Group Server] 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 serverfollows.
Outputs
All input properties are implicitly available as output properties. Additionally, the MasterSlaveServerGroup resource produces the following output properties:
Look up an Existing MasterSlaveServerGroup Resource
Get an existing MasterSlaveServerGroup 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?: MasterSlaveServerGroupState, opts?: CustomResourceOptions): MasterSlaveServerGroupstatic get(resource_name, id, opts=None, delete_protection_validation=None, load_balancer_id=None, name=None, servers=None, __props__=None);func GetMasterSlaveServerGroup(ctx *Context, name string, id IDInput, state *MasterSlaveServerGroupState, opts ...ResourceOption) (*MasterSlaveServerGroup, error)public static MasterSlaveServerGroup Get(string name, Input<string> id, MasterSlaveServerGroupState? 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:
- Delete
Protection boolValidation Checking DeleteProtection of SLB instance before deleting. If true, this resource will not be deleted when its SLB instance enabled DeleteProtection. Default to false.
- Load
Balancer stringId The Load Balancer ID which is used to launch a new master slave server group.
- Name string
Name of the master slave server group.
- Servers
List<Pulumi.
Ali Cloud. Slb. Inputs. Master Slave Server Group Server Args> 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 serverfollows.
- Delete
Protection boolValidation Checking DeleteProtection of SLB instance before deleting. If true, this resource will not be deleted when its SLB instance enabled DeleteProtection. Default to false.
- Load
Balancer stringId The Load Balancer ID which is used to launch a new master slave server group.
- Name string
Name of the master slave server group.
- Servers
[]Master
Slave Server Group Server 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 serverfollows.
- delete
Protection booleanValidation Checking DeleteProtection of SLB instance before deleting. If true, this resource will not be deleted when its SLB instance enabled DeleteProtection. Default to false.
- load
Balancer stringId The Load Balancer ID which is used to launch a new master slave server group.
- name string
Name of the master slave server group.
- servers
Master
Slave Server Group Server[] 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 serverfollows.
- delete_
protection_ boolvalidation Checking DeleteProtection of SLB instance before deleting. If true, this resource will not be deleted when its SLB instance enabled DeleteProtection. Default to false.
- load_
balancer_ strid The Load Balancer ID which is used to launch a new master slave server group.
- name str
Name of the master slave server group.
- servers
List[Master
Slave Server Group Server] 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 serverfollows.
Supporting Types
MasterSlaveServerGroupServer
Package Details
- Repository
- https://github.com/pulumi/pulumi-alicloud
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
alicloudTerraform Provider.