ServerGroup
A virtual server group contains several ECS instances. The virtual server group can help you to define multiple listening dimension, and to meet the personalized requirements of domain name and URL forwarding.
NOTE: One ECS instance can be added into multiple virtual server groups.
NOTE: One virtual server group can be attached with multiple listeners in one load balancer.
NOTE: One Classic and Internet load balancer, its virtual server group can add Classic and VPC ECS instances.
NOTE: One Classic and Intranet load balancer, its virtual server group can only add Classic ECS instances.
NOTE: One VPC load balancer, its virtual server group can only add the same VPC ECS instances.
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.
Example Usage
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AliCloud = Pulumi.AliCloud;
class MyStack : Stack
{
public MyStack()
{
var config = new Config();
var name = config.Get("name") ?? "slbservergroupvpc";
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,
CpuCoreCount = 1,
MemorySize = 2,
})));
var defaultImages = Output.Create(AliCloud.Ecs.GetImages.InvokeAsync(new AliCloud.Ecs.GetImagesArgs
{
MostRecent = true,
NameRegex = "^ubuntu_18.*64",
Owners = "system",
}));
var defaultNetwork = new AliCloud.Vpc.Network("defaultNetwork", new AliCloud.Vpc.NetworkArgs
{
CidrBlock = "172.16.0.0/16",
});
var defaultSwitch = new AliCloud.Vpc.Switch("defaultSwitch", new AliCloud.Vpc.SwitchArgs
{
AvailabilityZone = defaultZones.Apply(defaultZones => defaultZones.Zones[0].Id),
CidrBlock = "172.16.0.0/16",
VpcId = defaultNetwork.Id,
});
var defaultSecurityGroup = new AliCloud.Ecs.SecurityGroup("defaultSecurityGroup", new AliCloud.Ecs.SecurityGroupArgs
{
VpcId = defaultNetwork.Id,
});
var instance = new List<AliCloud.Ecs.Instance>();
for (var rangeIndex = 0; rangeIndex < 2; rangeIndex++)
{
var range = new { Value = rangeIndex };
instance.Add(new AliCloud.Ecs.Instance($"instance-{range.Value}", new AliCloud.Ecs.InstanceArgs
{
AvailabilityZone = defaultZones.Apply(defaultZones => defaultZones.Zones[0].Id),
ImageId = defaultImages.Apply(defaultImages => defaultImages.Images[0].Id),
InstanceChargeType = "PostPaid",
InstanceName = name,
InstanceType = defaultInstanceTypes.Apply(defaultInstanceTypes => defaultInstanceTypes.InstanceTypes[0].Id),
InternetChargeType = "PayByTraffic",
InternetMaxBandwidthOut = 10,
SecurityGroups =
{
defaultSecurityGroup,
}.Select(__item => __item.Id).ToList(),
SystemDiskCategory = "cloud_efficiency",
VswitchId = defaultSwitch.Id,
}));
}
var defaultLoadBalancer = new AliCloud.Slb.LoadBalancer("defaultLoadBalancer", new AliCloud.Slb.LoadBalancerArgs
{
VswitchId = defaultSwitch.Id,
});
var defaultServerGroup = new AliCloud.Slb.ServerGroup("defaultServerGroup", new AliCloud.Slb.ServerGroupArgs
{
LoadBalancerId = defaultLoadBalancer.Id,
Servers =
{
new AliCloud.Slb.Inputs.ServerGroupServerArgs
{
Port = 100,
ServerIds =
{
instance[0].Id,
instance[1].Id,
},
Weight = 10,
},
new AliCloud.Slb.Inputs.ServerGroupServerArgs
{
Port = 80,
ServerIds = instance.Select(__item => __item.Id).ToList(),
Weight = 100,
},
},
});
}
}
Coming soon!
import pulumi
import pulumi_alicloud as alicloud
config = pulumi.Config()
name = config.get("name")
if name is None:
name = "slbservergroupvpc"
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"],
cpu_core_count=1,
memory_size=2)
default_images = alicloud.ecs.get_images(most_recent=True,
name_regex="^ubuntu_18.*64",
owners="system")
default_network = alicloud.vpc.Network("defaultNetwork", cidr_block="172.16.0.0/16")
default_switch = alicloud.vpc.Switch("defaultSwitch",
availability_zone=default_zones.zones[0]["id"],
cidr_block="172.16.0.0/16",
vpc_id=default_network.id)
default_security_group = alicloud.ecs.SecurityGroup("defaultSecurityGroup", vpc_id=default_network.id)
instance = []
for range in [{"value": i} for i in range(0, 2)]:
instance.append(alicloud.ecs.Instance(f"instance-{range['value']}",
availability_zone=default_zones.zones[0]["id"],
image_id=default_images.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=[__item.id for __item in [default_security_group]],
system_disk_category="cloud_efficiency",
vswitch_id=default_switch.id))
default_load_balancer = alicloud.slb.LoadBalancer("defaultLoadBalancer", vswitch_id=default_switch.id)
default_server_group = alicloud.slb.ServerGroup("defaultServerGroup",
load_balancer_id=default_load_balancer.id,
servers=[
{
"port": 100,
"serverIds": [
instance[0].id,
instance[1].id,
],
"weight": 10,
},
{
"port": 80,
"serverIds": [__item.id for __item in instance],
"weight": 100,
},
])import * as pulumi from "@pulumi/pulumi";
import * as alicloud from "@pulumi/alicloud";
const config = new pulumi.Config();
const name = config.get("name") || "slbservergroupvpc";
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,
cpuCoreCount: 1,
memorySize: 2,
}, { async: true }));
const defaultImages = pulumi.output(alicloud.ecs.getImages({
mostRecent: true,
nameRegex: "^ubuntu_18.*64",
owners: "system",
}, { async: true }));
const defaultNetwork = new alicloud.vpc.Network("default", {
cidrBlock: "172.16.0.0/16",
});
const defaultSwitch = new alicloud.vpc.Switch("default", {
availabilityZone: defaultZones.zones[0].id,
cidrBlock: "172.16.0.0/16",
vpcId: defaultNetwork.id,
});
const defaultSecurityGroup = new alicloud.ecs.SecurityGroup("default", {
vpcId: defaultNetwork.id,
});
const instance: alicloud.ecs.Instance[] = [];
for (let i = 0; i < 2; i++) {
instance.push(new alicloud.ecs.Instance(`instance-${i}`, {
availabilityZone: defaultZones.zones[0].id,
imageId: defaultImages.images[0].id,
instanceChargeType: "PostPaid",
instanceName: name,
instanceType: defaultInstanceTypes.instanceTypes[0].id,
internetChargeType: "PayByTraffic",
internetMaxBandwidthOut: 10,
securityGroups: defaultSecurityGroup.id,
systemDiskCategory: "cloud_efficiency",
vswitchId: defaultSwitch.id,
}));
}
const defaultLoadBalancer = new alicloud.slb.LoadBalancer("default", {
vswitchId: defaultSwitch.id,
});
const defaultServerGroup = new alicloud.slb.ServerGroup("default", {
loadBalancerId: defaultLoadBalancer.id,
servers: [
{
port: 100,
serverIds: [
instance[0].id,
instance[1].id,
],
weight: 10,
},
{
port: 80,
serverIds: instance.map(v => v.id),
weight: 100,
},
],
});Create a ServerGroup Resource
new ServerGroup(name: string, args: ServerGroupArgs, opts?: CustomResourceOptions);def ServerGroup(resource_name, opts=None, delete_protection_validation=None, load_balancer_id=None, name=None, servers=None, __props__=None);func NewServerGroup(ctx *Context, name string, args ServerGroupArgs, opts ...ResourceOption) (*ServerGroup, error)public ServerGroup(string name, ServerGroupArgs args, CustomResourceOptions? opts = null)- name string
- The unique name of the resource.
- args ServerGroupArgs
- 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 ServerGroupArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args ServerGroupArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
ServerGroup Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Programming Model docs.
Inputs
The ServerGroup resource accepts the following input properties:
- Load
Balancer stringId The Load Balancer ID which is used to launch a new virtual 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 virtual server group. Our plugin provides a default name: “tf-server-group”.
- Servers
List<Pulumi.
Ali Cloud. Slb. Inputs. Server Group Server Args> A list of ECS instances to be added. At most 20 ECS instances can be supported in one resource. It contains three sub-fields as
Block serverfollows.
- Load
Balancer stringId The Load Balancer ID which is used to launch a new virtual 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 virtual server group. Our plugin provides a default name: “tf-server-group”.
- Servers
[]Server
Group Server A list of ECS instances to be added. At most 20 ECS instances can be supported in one resource. It contains three sub-fields as
Block serverfollows.
- load
Balancer stringId The Load Balancer ID which is used to launch a new virtual 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 virtual server group. Our plugin provides a default name: “tf-server-group”.
- servers
Server
Group Server[] A list of ECS instances to be added. At most 20 ECS instances can be supported in one resource. It contains three sub-fields as
Block serverfollows.
- load_
balancer_ strid The Load Balancer ID which is used to launch a new virtual 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 virtual server group. Our plugin provides a default name: “tf-server-group”.
- servers
List[Server
Group Server] A list of ECS instances to be added. At most 20 ECS instances can be supported in one resource. It contains three sub-fields as
Block serverfollows.
Outputs
All input properties are implicitly available as output properties. Additionally, the ServerGroup resource produces the following output properties:
Look up an Existing ServerGroup Resource
Get an existing ServerGroup 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?: ServerGroupState, opts?: CustomResourceOptions): ServerGroupstatic get(resource_name, id, opts=None, delete_protection_validation=None, load_balancer_id=None, name=None, servers=None, __props__=None);func GetServerGroup(ctx *Context, name string, id IDInput, state *ServerGroupState, opts ...ResourceOption) (*ServerGroup, error)public static ServerGroup Get(string name, Input<string> id, ServerGroupState? 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 virtual server group.
- Name string
Name of the virtual server group. Our plugin provides a default name: “tf-server-group”.
- Servers
List<Pulumi.
Ali Cloud. Slb. Inputs. Server Group Server Args> A list of ECS instances to be added. At most 20 ECS instances can be supported in one resource. It contains three 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 virtual server group.
- Name string
Name of the virtual server group. Our plugin provides a default name: “tf-server-group”.
- Servers
[]Server
Group Server A list of ECS instances to be added. At most 20 ECS instances can be supported in one resource. It contains three 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 virtual server group.
- name string
Name of the virtual server group. Our plugin provides a default name: “tf-server-group”.
- servers
Server
Group Server[] A list of ECS instances to be added. At most 20 ECS instances can be supported in one resource. It contains three 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 virtual server group.
- name str
Name of the virtual server group. Our plugin provides a default name: “tf-server-group”.
- servers
List[Server
Group Server] A list of ECS instances to be added. At most 20 ECS instances can be supported in one resource. It contains three sub-fields as
Block serverfollows.
Supporting Types
ServerGroupServer
Package Details
- Repository
- https://github.com/pulumi/pulumi-alicloud
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
alicloudTerraform Provider.