Show / Hide Table of Contents

Class BackendServer

Add a group of backend servers (ECS or ENI instance) to the Server Load Balancer or remove them from it.

NOTE: Available in 1.53.0+

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") ?? "slbbackendservertest";
    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 defaultInstance = new List<AliCloud.Ecs.Instance>();
    for (var rangeIndex = 0; rangeIndex < 2; rangeIndex++)
    {
        var range = new { Value = rangeIndex };
        defaultInstance.Add(new AliCloud.Ecs.Instance($"defaultInstance-{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 defaultBackendServer = new AliCloud.Slb.BackendServer("defaultBackendServer", new AliCloud.Slb.BackendServerArgs
    {
        BackendServers = 
        {
            new AliCloud.Slb.Inputs.BackendServerBackendServerArgs
            {
                ServerId = defaultInstance[0].Id,
                Weight = 100,
            },
            new AliCloud.Slb.Inputs.BackendServerBackendServerArgs
            {
                ServerId = defaultInstance[1].Id,
                Weight = 100,
            },
        },
        LoadBalancerId = defaultLoadBalancer.Id,
    });
}

}

Block servers

The servers mapping supports the following:

  • server_id - (Required) A list backend server ID (ECS instance ID).
  • weight - (Optional) Weight of the backend server. Valid value range: [0-100].
  • type - (Optional) Type of the backend server. Valid value ecs, eni. Default to eni.
Inheritance
System.Object
Resource
CustomResource
BackendServer
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 BackendServer : CustomResource

Constructors

View Source

BackendServer(String, BackendServerArgs, CustomResourceOptions)

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

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

The unique name of the resource

BackendServerArgs 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

BackendServers

A list of instances to added backend server in the SLB. It contains three sub-fields as Block server follows.

Declaration
public Output<ImmutableArray<BackendServerBackendServer>> BackendServers { get; }
Property Value
Type Description
Output<System.Collections.Immutable.ImmutableArray<BackendServerBackendServer>>
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

ID of the load balancer.

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

Methods

View Source

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

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

Declaration
public static BackendServer Get(string name, Input<string> id, BackendServerState 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.

BackendServerState state

Any extra arguments used during the lookup.

CustomResourceOptions options

A bag of options that control this resource's behavior

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