Class 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.
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,
},
},
});
}
}
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.
Inherited Members
Namespace: Pulumi.AliCloud.Slb
Assembly: Pulumi.AliCloud.dll
Syntax
public class ServerGroup : CustomResource
Constructors
View SourceServerGroup(String, ServerGroupArgs, CustomResourceOptions)
Create a ServerGroup resource with the given unique name, arguments, and options.
Declaration
public ServerGroup(string name, ServerGroupArgs args, CustomResourceOptions options = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | The unique name of the resource |
| ServerGroupArgs | args | The arguments used to populate this resource's properties |
| CustomResourceOptions | options | A bag of options that control this resource's behavior |
Properties
View SourceDeleteProtectionValidation
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>> |
LoadBalancerId
The Load Balancer ID which is used to launch a new virtual server group.
Declaration
public Output<string> LoadBalancerId { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
Name
Name of the virtual server group. Our plugin provides a default name: "tf-server-group".
Declaration
public Output<string> Name { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
Servers
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 server follows.
Declaration
public Output<ImmutableArray<ServerGroupServer>> Servers { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Collections.Immutable.ImmutableArray<ServerGroupServer>> |
Methods
View SourceGet(String, Input<String>, ServerGroupState, CustomResourceOptions)
Get an existing ServerGroup resource's state with the given name, ID, and optional extra properties used to qualify the lookup.
Declaration
public static ServerGroup Get(string name, Input<string> id, ServerGroupState 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. |
| ServerGroupState | state | Any extra arguments used during the lookup. |
| CustomResourceOptions | options | A bag of options that control this resource's behavior |
Returns
| Type | Description |
|---|---|
| ServerGroup |