alicloud.slb.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 Pulumi;
using AliCloud = Pulumi.AliCloud;
return await Deployment.RunAsync(() =>
{
var msServerGroupZones = AliCloud.GetZones.Invoke(new()
{
AvailableDiskCategory = "cloud_efficiency",
AvailableResourceCreation = "VSwitch",
});
var msServerGroupInstanceTypes = AliCloud.Ecs.GetInstanceTypes.Invoke(new()
{
AvailabilityZone = msServerGroupZones.Apply(getZonesResult => getZonesResult.Zones[0]?.Id),
EniAmount = 2,
});
var image = AliCloud.Ecs.GetImages.Invoke(new()
{
NameRegex = "^ubuntu_18.*64",
MostRecent = true,
Owners = "system",
});
var config = new Config();
var slbMasterSlaveServerGroup = config.Get("slbMasterSlaveServerGroup") ?? "forSlbMasterSlaveServerGroup";
var mainNetwork = new AliCloud.Vpc.Network("mainNetwork", new()
{
VpcName = slbMasterSlaveServerGroup,
CidrBlock = "172.16.0.0/16",
});
var mainSwitch = new AliCloud.Vpc.Switch("mainSwitch", new()
{
VpcId = mainNetwork.Id,
CidrBlock = "172.16.0.0/16",
ZoneId = msServerGroupZones.Apply(getZonesResult => getZonesResult.Zones[0]?.Id),
VswitchName = slbMasterSlaveServerGroup,
});
var groupSecurityGroup = new AliCloud.Ecs.SecurityGroup("groupSecurityGroup", new()
{
VpcId = mainNetwork.Id,
});
var msServerGroupInstance = new List<AliCloud.Ecs.Instance>();
for (var rangeIndex = 0; rangeIndex < 2; rangeIndex++)
{
var range = new { Value = rangeIndex };
msServerGroupInstance.Add(new AliCloud.Ecs.Instance($"msServerGroupInstance-{range.Value}", new()
{
ImageId = image.Apply(getImagesResult => getImagesResult.Images[0]?.Id),
InstanceType = msServerGroupInstanceTypes.Apply(getInstanceTypesResult => getInstanceTypesResult.InstanceTypes[0]?.Id),
InstanceName = slbMasterSlaveServerGroup,
SecurityGroups = new[]
{
groupSecurityGroup.Id,
},
InternetChargeType = "PayByTraffic",
InternetMaxBandwidthOut = 10,
AvailabilityZone = msServerGroupZones.Apply(getZonesResult => getZonesResult.Zones[0]?.Id),
InstanceChargeType = "PostPaid",
SystemDiskCategory = "cloud_efficiency",
VswitchId = mainSwitch.Id,
}));
}
var msServerGroupApplicationLoadBalancer = new AliCloud.Slb.ApplicationLoadBalancer("msServerGroupApplicationLoadBalancer", new()
{
LoadBalancerName = slbMasterSlaveServerGroup,
VswitchId = mainSwitch.Id,
LoadBalancerSpec = "slb.s2.small",
});
var msServerGroupEcsNetworkInterface = new AliCloud.Ecs.EcsNetworkInterface("msServerGroupEcsNetworkInterface", new()
{
NetworkInterfaceName = slbMasterSlaveServerGroup,
VswitchId = mainSwitch.Id,
SecurityGroupIds = new[]
{
groupSecurityGroup.Id,
},
});
var msServerGroupEcsNetworkInterfaceAttachment = new AliCloud.Ecs.EcsNetworkInterfaceAttachment("msServerGroupEcsNetworkInterfaceAttachment", new()
{
InstanceId = msServerGroupInstance[0].Id,
NetworkInterfaceId = msServerGroupEcsNetworkInterface.Id,
});
var groupMasterSlaveServerGroup = new AliCloud.Slb.MasterSlaveServerGroup("groupMasterSlaveServerGroup", new()
{
LoadBalancerId = msServerGroupApplicationLoadBalancer.Id,
Servers = new[]
{
new AliCloud.Slb.Inputs.MasterSlaveServerGroupServerArgs
{
ServerId = msServerGroupInstance[0].Id,
Port = 100,
Weight = 100,
ServerType = "Master",
},
new AliCloud.Slb.Inputs.MasterSlaveServerGroupServerArgs
{
ServerId = msServerGroupInstance[1].Id,
Port = 100,
Weight = 100,
ServerType = "Slave",
},
},
});
var tcp = new AliCloud.Slb.Listener("tcp", new()
{
LoadBalancerId = msServerGroupApplicationLoadBalancer.Id,
MasterSlaveServerGroupId = groupMasterSlaveServerGroup.Id,
FrontendPort = 22,
Protocol = "tcp",
Bandwidth = 10,
HealthCheckType = "tcp",
PersistenceTimeout = 3600,
HealthyThreshold = 8,
UnhealthyThreshold = 8,
HealthCheckTimeout = 8,
HealthCheckInterval = 5,
HealthCheckHttpCode = "http_2xx",
HealthCheckConnectPort = 20,
HealthCheckUri = "/console",
EstablishedTimeout = 600,
});
});
package main
import (
"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud"
"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/ecs"
"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/slb"
"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/vpc"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi/config"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
msServerGroupZones, err := alicloud.GetZones(ctx, &alicloud.GetZonesArgs{
AvailableDiskCategory: pulumi.StringRef("cloud_efficiency"),
AvailableResourceCreation: pulumi.StringRef("VSwitch"),
}, nil)
if err != nil {
return err
}
msServerGroupInstanceTypes, err := ecs.GetInstanceTypes(ctx, &ecs.GetInstanceTypesArgs{
AvailabilityZone: pulumi.StringRef(msServerGroupZones.Zones[0].Id),
EniAmount: pulumi.IntRef(2),
}, nil)
if err != nil {
return err
}
image, err := ecs.GetImages(ctx, &ecs.GetImagesArgs{
NameRegex: pulumi.StringRef("^ubuntu_18.*64"),
MostRecent: pulumi.BoolRef(true),
Owners: pulumi.StringRef("system"),
}, nil)
if err != nil {
return err
}
cfg := config.New(ctx, "")
slbMasterSlaveServerGroup := "forSlbMasterSlaveServerGroup"
if param := cfg.Get("slbMasterSlaveServerGroup"); param != "" {
slbMasterSlaveServerGroup = param
}
mainNetwork, err := vpc.NewNetwork(ctx, "mainNetwork", &vpc.NetworkArgs{
VpcName: pulumi.String(slbMasterSlaveServerGroup),
CidrBlock: pulumi.String("172.16.0.0/16"),
})
if err != nil {
return err
}
mainSwitch, err := vpc.NewSwitch(ctx, "mainSwitch", &vpc.SwitchArgs{
VpcId: mainNetwork.ID(),
CidrBlock: pulumi.String("172.16.0.0/16"),
ZoneId: *pulumi.String(msServerGroupZones.Zones[0].Id),
VswitchName: pulumi.String(slbMasterSlaveServerGroup),
})
if err != nil {
return err
}
groupSecurityGroup, err := ecs.NewSecurityGroup(ctx, "groupSecurityGroup", &ecs.SecurityGroupArgs{
VpcId: mainNetwork.ID(),
})
if err != nil {
return err
}
var msServerGroupInstance []*ecs.Instance
for index := 0; index < 2; index++ {
key0 := index
_ := index
__res, err := ecs.NewInstance(ctx, fmt.Sprintf("msServerGroupInstance-%v", key0), &ecs.InstanceArgs{
ImageId: *pulumi.String(image.Images[0].Id),
InstanceType: *pulumi.String(msServerGroupInstanceTypes.InstanceTypes[0].Id),
InstanceName: pulumi.String(slbMasterSlaveServerGroup),
SecurityGroups: pulumi.StringArray{
groupSecurityGroup.ID(),
},
InternetChargeType: pulumi.String("PayByTraffic"),
InternetMaxBandwidthOut: pulumi.Int(10),
AvailabilityZone: *pulumi.String(msServerGroupZones.Zones[0].Id),
InstanceChargeType: pulumi.String("PostPaid"),
SystemDiskCategory: pulumi.String("cloud_efficiency"),
VswitchId: mainSwitch.ID(),
})
if err != nil {
return err
}
msServerGroupInstance = append(msServerGroupInstance, __res)
}
msServerGroupApplicationLoadBalancer, err := slb.NewApplicationLoadBalancer(ctx, "msServerGroupApplicationLoadBalancer", &slb.ApplicationLoadBalancerArgs{
LoadBalancerName: pulumi.String(slbMasterSlaveServerGroup),
VswitchId: mainSwitch.ID(),
LoadBalancerSpec: pulumi.String("slb.s2.small"),
})
if err != nil {
return err
}
msServerGroupEcsNetworkInterface, err := ecs.NewEcsNetworkInterface(ctx, "msServerGroupEcsNetworkInterface", &ecs.EcsNetworkInterfaceArgs{
NetworkInterfaceName: pulumi.String(slbMasterSlaveServerGroup),
VswitchId: mainSwitch.ID(),
SecurityGroupIds: pulumi.StringArray{
groupSecurityGroup.ID(),
},
})
if err != nil {
return err
}
_, err = ecs.NewEcsNetworkInterfaceAttachment(ctx, "msServerGroupEcsNetworkInterfaceAttachment", &ecs.EcsNetworkInterfaceAttachmentArgs{
InstanceId: msServerGroupInstance[0].ID(),
NetworkInterfaceId: msServerGroupEcsNetworkInterface.ID(),
})
if err != nil {
return err
}
groupMasterSlaveServerGroup, err := slb.NewMasterSlaveServerGroup(ctx, "groupMasterSlaveServerGroup", &slb.MasterSlaveServerGroupArgs{
LoadBalancerId: msServerGroupApplicationLoadBalancer.ID(),
Servers: slb.MasterSlaveServerGroupServerArray{
&slb.MasterSlaveServerGroupServerArgs{
ServerId: msServerGroupInstance[0].ID(),
Port: pulumi.Int(100),
Weight: pulumi.Int(100),
ServerType: pulumi.String("Master"),
},
&slb.MasterSlaveServerGroupServerArgs{
ServerId: msServerGroupInstance[1].ID(),
Port: pulumi.Int(100),
Weight: pulumi.Int(100),
ServerType: pulumi.String("Slave"),
},
},
})
if err != nil {
return err
}
_, err = slb.NewListener(ctx, "tcp", &slb.ListenerArgs{
LoadBalancerId: msServerGroupApplicationLoadBalancer.ID(),
MasterSlaveServerGroupId: groupMasterSlaveServerGroup.ID(),
FrontendPort: pulumi.Int(22),
Protocol: pulumi.String("tcp"),
Bandwidth: pulumi.Int(10),
HealthCheckType: pulumi.String("tcp"),
PersistenceTimeout: pulumi.Int(3600),
HealthyThreshold: pulumi.Int(8),
UnhealthyThreshold: pulumi.Int(8),
HealthCheckTimeout: pulumi.Int(8),
HealthCheckInterval: pulumi.Int(5),
HealthCheckHttpCode: pulumi.String("http_2xx"),
HealthCheckConnectPort: pulumi.Int(20),
HealthCheckUri: pulumi.String("/console"),
EstablishedTimeout: pulumi.Int(600),
})
if err != nil {
return err
}
return nil
})
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.alicloud.AlicloudFunctions;
import com.pulumi.alicloud.inputs.GetZonesArgs;
import com.pulumi.alicloud.ecs.EcsFunctions;
import com.pulumi.alicloud.ecs.inputs.GetInstanceTypesArgs;
import com.pulumi.alicloud.ecs.inputs.GetImagesArgs;
import com.pulumi.alicloud.vpc.Network;
import com.pulumi.alicloud.vpc.NetworkArgs;
import com.pulumi.alicloud.vpc.Switch;
import com.pulumi.alicloud.vpc.SwitchArgs;
import com.pulumi.alicloud.ecs.SecurityGroup;
import com.pulumi.alicloud.ecs.SecurityGroupArgs;
import com.pulumi.alicloud.ecs.Instance;
import com.pulumi.alicloud.ecs.InstanceArgs;
import com.pulumi.alicloud.slb.ApplicationLoadBalancer;
import com.pulumi.alicloud.slb.ApplicationLoadBalancerArgs;
import com.pulumi.alicloud.ecs.EcsNetworkInterface;
import com.pulumi.alicloud.ecs.EcsNetworkInterfaceArgs;
import com.pulumi.alicloud.ecs.EcsNetworkInterfaceAttachment;
import com.pulumi.alicloud.ecs.EcsNetworkInterfaceAttachmentArgs;
import com.pulumi.alicloud.slb.MasterSlaveServerGroup;
import com.pulumi.alicloud.slb.MasterSlaveServerGroupArgs;
import com.pulumi.alicloud.slb.inputs.MasterSlaveServerGroupServerArgs;
import com.pulumi.alicloud.slb.Listener;
import com.pulumi.alicloud.slb.ListenerArgs;
import com.pulumi.codegen.internal.KeyedValue;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
final var config = ctx.config();
final var msServerGroupZones = AlicloudFunctions.getZones(GetZonesArgs.builder()
.availableDiskCategory("cloud_efficiency")
.availableResourceCreation("VSwitch")
.build());
final var msServerGroupInstanceTypes = EcsFunctions.getInstanceTypes(GetInstanceTypesArgs.builder()
.availabilityZone(msServerGroupZones.applyValue(getZonesResult -> getZonesResult.zones()[0].id()))
.eniAmount(2)
.build());
final var image = EcsFunctions.getImages(GetImagesArgs.builder()
.nameRegex("^ubuntu_18.*64")
.mostRecent(true)
.owners("system")
.build());
final var slbMasterSlaveServerGroup = config.get("slbMasterSlaveServerGroup").orElse("forSlbMasterSlaveServerGroup");
var mainNetwork = new Network("mainNetwork", NetworkArgs.builder()
.vpcName(slbMasterSlaveServerGroup)
.cidrBlock("172.16.0.0/16")
.build());
var mainSwitch = new Switch("mainSwitch", SwitchArgs.builder()
.vpcId(mainNetwork.id())
.cidrBlock("172.16.0.0/16")
.zoneId(msServerGroupZones.applyValue(getZonesResult -> getZonesResult.zones()[0].id()))
.vswitchName(slbMasterSlaveServerGroup)
.build());
var groupSecurityGroup = new SecurityGroup("groupSecurityGroup", SecurityGroupArgs.builder()
.vpcId(mainNetwork.id())
.build());
for (var i = 0; i < 2; i++) {
new Instance("msServerGroupInstance-" + i, InstanceArgs.builder()
.imageId(image.applyValue(getImagesResult -> getImagesResult.images()[0].id()))
.instanceType(msServerGroupInstanceTypes.applyValue(getInstanceTypesResult -> getInstanceTypesResult.instanceTypes()[0].id()))
.instanceName(slbMasterSlaveServerGroup)
.securityGroups(groupSecurityGroup.id())
.internetChargeType("PayByTraffic")
.internetMaxBandwidthOut("10")
.availabilityZone(msServerGroupZones.applyValue(getZonesResult -> getZonesResult.zones()[0].id()))
.instanceChargeType("PostPaid")
.systemDiskCategory("cloud_efficiency")
.vswitchId(mainSwitch.id())
.build());
}
var msServerGroupApplicationLoadBalancer = new ApplicationLoadBalancer("msServerGroupApplicationLoadBalancer", ApplicationLoadBalancerArgs.builder()
.loadBalancerName(slbMasterSlaveServerGroup)
.vswitchId(mainSwitch.id())
.loadBalancerSpec("slb.s2.small")
.build());
var msServerGroupEcsNetworkInterface = new EcsNetworkInterface("msServerGroupEcsNetworkInterface", EcsNetworkInterfaceArgs.builder()
.networkInterfaceName(slbMasterSlaveServerGroup)
.vswitchId(mainSwitch.id())
.securityGroupIds(groupSecurityGroup.id())
.build());
var msServerGroupEcsNetworkInterfaceAttachment = new EcsNetworkInterfaceAttachment("msServerGroupEcsNetworkInterfaceAttachment", EcsNetworkInterfaceAttachmentArgs.builder()
.instanceId(msServerGroupInstance[0].id())
.networkInterfaceId(msServerGroupEcsNetworkInterface.id())
.build());
var groupMasterSlaveServerGroup = new MasterSlaveServerGroup("groupMasterSlaveServerGroup", MasterSlaveServerGroupArgs.builder()
.loadBalancerId(msServerGroupApplicationLoadBalancer.id())
.servers(
MasterSlaveServerGroupServerArgs.builder()
.serverId(msServerGroupInstance[0].id())
.port(100)
.weight(100)
.serverType("Master")
.build(),
MasterSlaveServerGroupServerArgs.builder()
.serverId(msServerGroupInstance[1].id())
.port(100)
.weight(100)
.serverType("Slave")
.build())
.build());
var tcp = new Listener("tcp", ListenerArgs.builder()
.loadBalancerId(msServerGroupApplicationLoadBalancer.id())
.masterSlaveServerGroupId(groupMasterSlaveServerGroup.id())
.frontendPort("22")
.protocol("tcp")
.bandwidth("10")
.healthCheckType("tcp")
.persistenceTimeout(3600)
.healthyThreshold(8)
.unhealthyThreshold(8)
.healthCheckTimeout(8)
.healthCheckInterval(5)
.healthCheckHttpCode("http_2xx")
.healthCheckConnectPort(20)
.healthCheckUri("/console")
.establishedTimeout(600)
.build());
}
}
import pulumi
import pulumi_alicloud as alicloud
ms_server_group_zones = alicloud.get_zones(available_disk_category="cloud_efficiency",
available_resource_creation="VSwitch")
ms_server_group_instance_types = alicloud.ecs.get_instance_types(availability_zone=ms_server_group_zones.zones[0].id,
eni_amount=2)
image = alicloud.ecs.get_images(name_regex="^ubuntu_18.*64",
most_recent=True,
owners="system")
config = pulumi.Config()
slb_master_slave_server_group = config.get("slbMasterSlaveServerGroup")
if slb_master_slave_server_group is None:
slb_master_slave_server_group = "forSlbMasterSlaveServerGroup"
main_network = alicloud.vpc.Network("mainNetwork",
vpc_name=slb_master_slave_server_group,
cidr_block="172.16.0.0/16")
main_switch = alicloud.vpc.Switch("mainSwitch",
vpc_id=main_network.id,
cidr_block="172.16.0.0/16",
zone_id=ms_server_group_zones.zones[0].id,
vswitch_name=slb_master_slave_server_group)
group_security_group = alicloud.ecs.SecurityGroup("groupSecurityGroup", vpc_id=main_network.id)
ms_server_group_instance = []
for range in [{"value": i} for i in range(0, 2)]:
ms_server_group_instance.append(alicloud.ecs.Instance(f"msServerGroupInstance-{range['value']}",
image_id=image.images[0].id,
instance_type=ms_server_group_instance_types.instance_types[0].id,
instance_name=slb_master_slave_server_group,
security_groups=[group_security_group.id],
internet_charge_type="PayByTraffic",
internet_max_bandwidth_out=10,
availability_zone=ms_server_group_zones.zones[0].id,
instance_charge_type="PostPaid",
system_disk_category="cloud_efficiency",
vswitch_id=main_switch.id))
ms_server_group_application_load_balancer = alicloud.slb.ApplicationLoadBalancer("msServerGroupApplicationLoadBalancer",
load_balancer_name=slb_master_slave_server_group,
vswitch_id=main_switch.id,
load_balancer_spec="slb.s2.small")
ms_server_group_ecs_network_interface = alicloud.ecs.EcsNetworkInterface("msServerGroupEcsNetworkInterface",
network_interface_name=slb_master_slave_server_group,
vswitch_id=main_switch.id,
security_group_ids=[group_security_group.id])
ms_server_group_ecs_network_interface_attachment = alicloud.ecs.EcsNetworkInterfaceAttachment("msServerGroupEcsNetworkInterfaceAttachment",
instance_id=ms_server_group_instance[0].id,
network_interface_id=ms_server_group_ecs_network_interface.id)
group_master_slave_server_group = alicloud.slb.MasterSlaveServerGroup("groupMasterSlaveServerGroup",
load_balancer_id=ms_server_group_application_load_balancer.id,
servers=[
alicloud.slb.MasterSlaveServerGroupServerArgs(
server_id=ms_server_group_instance[0].id,
port=100,
weight=100,
server_type="Master",
),
alicloud.slb.MasterSlaveServerGroupServerArgs(
server_id=ms_server_group_instance[1].id,
port=100,
weight=100,
server_type="Slave",
),
])
tcp = alicloud.slb.Listener("tcp",
load_balancer_id=ms_server_group_application_load_balancer.id,
master_slave_server_group_id=group_master_slave_server_group.id,
frontend_port=22,
protocol="tcp",
bandwidth=10,
health_check_type="tcp",
persistence_timeout=3600,
healthy_threshold=8,
unhealthy_threshold=8,
health_check_timeout=8,
health_check_interval=5,
health_check_http_code="http_2xx",
health_check_connect_port=20,
health_check_uri="/console",
established_timeout=600)
import * as pulumi from "@pulumi/pulumi";
import * as alicloud from "@pulumi/alicloud";
const msServerGroupZones = alicloud.getZones({
availableDiskCategory: "cloud_efficiency",
availableResourceCreation: "VSwitch",
});
const msServerGroupInstanceTypes = msServerGroupZones.then(msServerGroupZones => alicloud.ecs.getInstanceTypes({
availabilityZone: msServerGroupZones.zones?.[0]?.id,
eniAmount: 2,
}));
const image = alicloud.ecs.getImages({
nameRegex: "^ubuntu_18.*64",
mostRecent: true,
owners: "system",
});
const config = new pulumi.Config();
const slbMasterSlaveServerGroup = config.get("slbMasterSlaveServerGroup") || "forSlbMasterSlaveServerGroup";
const mainNetwork = new alicloud.vpc.Network("mainNetwork", {
vpcName: slbMasterSlaveServerGroup,
cidrBlock: "172.16.0.0/16",
});
const mainSwitch = new alicloud.vpc.Switch("mainSwitch", {
vpcId: mainNetwork.id,
cidrBlock: "172.16.0.0/16",
zoneId: msServerGroupZones.then(msServerGroupZones => msServerGroupZones.zones?.[0]?.id),
vswitchName: slbMasterSlaveServerGroup,
});
const groupSecurityGroup = new alicloud.ecs.SecurityGroup("groupSecurityGroup", {vpcId: mainNetwork.id});
const msServerGroupInstance: alicloud.ecs.Instance[] = [];
for (const range = {value: 0}; range.value < 2; range.value++) {
msServerGroupInstance.push(new alicloud.ecs.Instance(`msServerGroupInstance-${range.value}`, {
imageId: image.then(image => image.images?.[0]?.id),
instanceType: msServerGroupInstanceTypes.then(msServerGroupInstanceTypes => msServerGroupInstanceTypes.instanceTypes?.[0]?.id),
instanceName: slbMasterSlaveServerGroup,
securityGroups: [groupSecurityGroup.id],
internetChargeType: "PayByTraffic",
internetMaxBandwidthOut: 10,
availabilityZone: msServerGroupZones.then(msServerGroupZones => msServerGroupZones.zones?.[0]?.id),
instanceChargeType: "PostPaid",
systemDiskCategory: "cloud_efficiency",
vswitchId: mainSwitch.id,
}));
}
const msServerGroupApplicationLoadBalancer = new alicloud.slb.ApplicationLoadBalancer("msServerGroupApplicationLoadBalancer", {
loadBalancerName: slbMasterSlaveServerGroup,
vswitchId: mainSwitch.id,
loadBalancerSpec: "slb.s2.small",
});
const msServerGroupEcsNetworkInterface = new alicloud.ecs.EcsNetworkInterface("msServerGroupEcsNetworkInterface", {
networkInterfaceName: slbMasterSlaveServerGroup,
vswitchId: mainSwitch.id,
securityGroupIds: [groupSecurityGroup.id],
});
const msServerGroupEcsNetworkInterfaceAttachment = new alicloud.ecs.EcsNetworkInterfaceAttachment("msServerGroupEcsNetworkInterfaceAttachment", {
instanceId: msServerGroupInstance[0].id,
networkInterfaceId: msServerGroupEcsNetworkInterface.id,
});
const groupMasterSlaveServerGroup = new alicloud.slb.MasterSlaveServerGroup("groupMasterSlaveServerGroup", {
loadBalancerId: msServerGroupApplicationLoadBalancer.id,
servers: [
{
serverId: msServerGroupInstance[0].id,
port: 100,
weight: 100,
serverType: "Master",
},
{
serverId: msServerGroupInstance[1].id,
port: 100,
weight: 100,
serverType: "Slave",
},
],
});
const tcp = new alicloud.slb.Listener("tcp", {
loadBalancerId: msServerGroupApplicationLoadBalancer.id,
masterSlaveServerGroupId: groupMasterSlaveServerGroup.id,
frontendPort: 22,
protocol: "tcp",
bandwidth: 10,
healthCheckType: "tcp",
persistenceTimeout: 3600,
healthyThreshold: 8,
unhealthyThreshold: 8,
healthCheckTimeout: 8,
healthCheckInterval: 5,
healthCheckHttpCode: "http_2xx",
healthCheckConnectPort: 20,
healthCheckUri: "/console",
establishedTimeout: 600,
});
configuration:
slbMasterSlaveServerGroup:
type: string
default: forSlbMasterSlaveServerGroup
resources:
mainNetwork:
type: alicloud:vpc:Network
properties:
vpcName: ${slbMasterSlaveServerGroup}
cidrBlock: 172.16.0.0/16
mainSwitch:
type: alicloud:vpc:Switch
properties:
vpcId: ${mainNetwork.id}
cidrBlock: 172.16.0.0/16
zoneId: ${msServerGroupZones.zones[0].id}
vswitchName: ${slbMasterSlaveServerGroup}
groupSecurityGroup:
type: alicloud:ecs:SecurityGroup
properties:
vpcId: ${mainNetwork.id}
msServerGroupInstance:
type: alicloud:ecs:Instance
properties:
imageId: ${image.images[0].id}
instanceType: ${msServerGroupInstanceTypes.instanceTypes[0].id}
instanceName: ${slbMasterSlaveServerGroup}
securityGroups:
- ${groupSecurityGroup.id}
internetChargeType: PayByTraffic
internetMaxBandwidthOut: '10'
availabilityZone: ${msServerGroupZones.zones[0].id}
instanceChargeType: PostPaid
systemDiskCategory: cloud_efficiency
vswitchId: ${mainSwitch.id}
options: {}
msServerGroupApplicationLoadBalancer:
type: alicloud:slb:ApplicationLoadBalancer
properties:
loadBalancerName: ${slbMasterSlaveServerGroup}
vswitchId: ${mainSwitch.id}
loadBalancerSpec: slb.s2.small
msServerGroupEcsNetworkInterface:
type: alicloud:ecs:EcsNetworkInterface
properties:
networkInterfaceName: ${slbMasterSlaveServerGroup}
vswitchId: ${mainSwitch.id}
securityGroupIds:
- ${groupSecurityGroup.id}
msServerGroupEcsNetworkInterfaceAttachment:
type: alicloud:ecs:EcsNetworkInterfaceAttachment
properties:
instanceId: ${msServerGroupInstance[0].id}
networkInterfaceId: ${msServerGroupEcsNetworkInterface.id}
groupMasterSlaveServerGroup:
type: alicloud:slb:MasterSlaveServerGroup
properties:
loadBalancerId: ${msServerGroupApplicationLoadBalancer.id}
servers:
- serverId: ${msServerGroupInstance[0].id}
port: 100
weight: 100
serverType: Master
- serverId: ${msServerGroupInstance[1].id}
port: 100
weight: 100
serverType: Slave
tcp:
type: alicloud:slb:Listener
properties:
loadBalancerId: ${msServerGroupApplicationLoadBalancer.id}
masterSlaveServerGroupId: ${groupMasterSlaveServerGroup.id}
frontendPort: '22'
protocol: tcp
bandwidth: '10'
healthCheckType: tcp
persistenceTimeout: 3600
healthyThreshold: 8
unhealthyThreshold: 8
healthCheckTimeout: 8
healthCheckInterval: 5
healthCheckHttpCode: http_2xx
healthCheckConnectPort: 20
healthCheckUri: /console
establishedTimeout: 600
variables:
msServerGroupZones:
fn::invoke:
Function: alicloud:getZones
Arguments:
availableDiskCategory: cloud_efficiency
availableResourceCreation: VSwitch
msServerGroupInstanceTypes:
fn::invoke:
Function: alicloud:ecs:getInstanceTypes
Arguments:
availabilityZone: ${msServerGroupZones.zones[0].id}
eniAmount: 2
image:
fn::invoke:
Function: alicloud:ecs:getImages
Arguments:
nameRegex: ^ubuntu_18.*64
mostRecent: true
owners: system
Create MasterSlaveServerGroup Resource
new MasterSlaveServerGroup(name: string, args: MasterSlaveServerGroupArgs, opts?: CustomResourceOptions);
@overload
def MasterSlaveServerGroup(resource_name: str,
opts: Optional[ResourceOptions] = None,
delete_protection_validation: Optional[bool] = None,
load_balancer_id: Optional[str] = None,
name: Optional[str] = None,
servers: Optional[Sequence[MasterSlaveServerGroupServerArgs]] = None)
@overload
def MasterSlaveServerGroup(resource_name: str,
args: MasterSlaveServerGroupArgs,
opts: Optional[ResourceOptions] = None)
func NewMasterSlaveServerGroup(ctx *Context, name string, args MasterSlaveServerGroupArgs, opts ...ResourceOption) (*MasterSlaveServerGroup, error)
public MasterSlaveServerGroup(string name, MasterSlaveServerGroupArgs args, CustomResourceOptions? opts = null)
public MasterSlaveServerGroup(String name, MasterSlaveServerGroupArgs args)
public MasterSlaveServerGroup(String name, MasterSlaveServerGroupArgs args, CustomResourceOptions options)
type: alicloud:slb:MasterSlaveServerGroup
properties: # The arguments to resource properties.
options: # 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.
- resource_name str
- The unique name of the resource.
- args MasterSlaveServerGroupArgs
- The arguments to resource properties.
- opts ResourceOptions
- Bag of options to control 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.
- name String
- The unique name of the resource.
- args MasterSlaveServerGroupArgs
- The arguments to resource properties.
- options 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 Architecture and Concepts 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 server
follows.
- 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 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 server
follows.
- 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
List<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 server
follows.
- 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 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 server
follows.
- 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
Sequence[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 server
follows.
- 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 List<Property Map>
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.
Outputs
All input properties are implicitly available as output properties. Additionally, the MasterSlaveServerGroup resource produces the following output properties:
- Id string
The provider-assigned unique ID for this managed resource.
- Id string
The provider-assigned unique ID for this managed resource.
- id String
The provider-assigned unique ID for this managed resource.
- id string
The provider-assigned unique ID for this managed resource.
- id str
The provider-assigned unique ID for this managed resource.
- id String
The provider-assigned unique ID for this managed resource.
Look up 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): MasterSlaveServerGroup
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
delete_protection_validation: Optional[bool] = None,
load_balancer_id: Optional[str] = None,
name: Optional[str] = None,
servers: Optional[Sequence[MasterSlaveServerGroupServerArgs]] = None) -> MasterSlaveServerGroup
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)
public static MasterSlaveServerGroup get(String name, Output<String> id, MasterSlaveServerGroupState state, CustomResourceOptions options)
Resource lookup is not supported in YAML
- 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.
- 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.
- 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 server
follows.
- 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 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 server
follows.
- 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
List<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 server
follows.
- 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 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 server
follows.
- 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
Sequence[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 server
follows.
- 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 List<Property Map>
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.
Supporting Types
MasterSlaveServerGroupServer
Import
Load balancer master slave server group can be imported using the id, e.g.
$ pulumi import alicloud:slb/masterSlaveServerGroup:MasterSlaveServerGroup example abc123456
Package Details
- Repository
- Alibaba Cloud pulumi/pulumi-alicloud
- License
- Apache-2.0
- Notes
This Pulumi package is based on the
alicloud
Terraform Provider.