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+

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.

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,
        });
    }

}

Coming soon!

import pulumi
import pulumi_alicloud as alicloud

config = pulumi.Config()
name = config.get("name")
if name is None:
    name = "slbbackendservertest"
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)
default_instance = []
for range in [{"value": i} for i in range(0, 2)]:
    default_instance.append(alicloud.ecs.Instance(f"defaultInstance-{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_backend_server = alicloud.slb.BackendServer("defaultBackendServer",
    backend_servers=[
        {
            "serverId": default_instance[0].id,
            "weight": 100,
        },
        {
            "serverId": default_instance[1].id,
            "weight": 100,
        },
    ],
    load_balancer_id=default_load_balancer.id)
import * as pulumi from "@pulumi/pulumi";
import * as alicloud from "@pulumi/alicloud";

const config = new pulumi.Config();
const name = config.get("name") || "slbbackendservertest";

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 defaultInstance: alicloud.ecs.Instance[] = [];
for (let i = 0; i < 2; i++) {
    defaultInstance.push(new alicloud.ecs.Instance(`default-${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 defaultBackendServer = new alicloud.slb.BackendServer("default", {
    backendServers: [
        {
            serverId: defaultInstance[0].id,
            weight: 100,
        },
        {
            serverId: defaultInstance[1].id,
            weight: 100,
        },
    ],
    loadBalancerId: defaultLoadBalancer.id,
});

Create a BackendServer Resource

def BackendServer(resource_name, opts=None, backend_servers=None, delete_protection_validation=None, load_balancer_id=None, __props__=None);
name string
The unique name of the resource.
args BackendServerArgs
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 BackendServerArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args BackendServerArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.

BackendServer Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Programming Model docs.

Inputs

The BackendServer resource accepts the following input properties:

LoadBalancerId string

ID of the load balancer.

BackendServers List<Pulumi.AliCloud.Slb.Inputs.BackendServerBackendServerArgs>

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

DeleteProtectionValidation bool

Checking DeleteProtection of SLB instance before deleting. If true, this resource will not be deleted when its SLB instance enabled DeleteProtection. Default to false.

LoadBalancerId string

ID of the load balancer.

BackendServers []BackendServerBackendServer

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

DeleteProtectionValidation bool

Checking DeleteProtection of SLB instance before deleting. If true, this resource will not be deleted when its SLB instance enabled DeleteProtection. Default to false.

loadBalancerId string

ID of the load balancer.

backendServers BackendServerBackendServer[]

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

deleteProtectionValidation boolean

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_id str

ID of the load balancer.

backend_servers List[BackendServerBackendServer]

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

delete_protection_validation bool

Checking DeleteProtection of SLB instance before deleting. If true, this resource will not be deleted when its SLB instance enabled DeleteProtection. Default to false.

Outputs

All input properties are implicitly available as output properties. Additionally, the BackendServer 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 str
The provider-assigned unique ID for this managed resource.

Look up an Existing BackendServer Resource

Get an existing BackendServer 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?: BackendServerState, opts?: CustomResourceOptions): BackendServer
static get(resource_name, id, opts=None, backend_servers=None, delete_protection_validation=None, load_balancer_id=None, __props__=None);
func GetBackendServer(ctx *Context, name string, id IDInput, state *BackendServerState, opts ...ResourceOption) (*BackendServer, error)
public static BackendServer Get(string name, Input<string> id, BackendServerState? 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:

BackendServers List<Pulumi.AliCloud.Slb.Inputs.BackendServerBackendServerArgs>

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

DeleteProtectionValidation bool

Checking DeleteProtection of SLB instance before deleting. If true, this resource will not be deleted when its SLB instance enabled DeleteProtection. Default to false.

LoadBalancerId string

ID of the load balancer.

BackendServers []BackendServerBackendServer

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

DeleteProtectionValidation bool

Checking DeleteProtection of SLB instance before deleting. If true, this resource will not be deleted when its SLB instance enabled DeleteProtection. Default to false.

LoadBalancerId string

ID of the load balancer.

backendServers BackendServerBackendServer[]

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

deleteProtectionValidation boolean

Checking DeleteProtection of SLB instance before deleting. If true, this resource will not be deleted when its SLB instance enabled DeleteProtection. Default to false.

loadBalancerId string

ID of the load balancer.

backend_servers List[BackendServerBackendServer]

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

delete_protection_validation bool

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_id str

ID of the load balancer.

Supporting Types

BackendServerBackendServer

See the input and output API doc for this type.

See the input and output API doc for this type.

See the input and output API doc for this type.

ServerId string
Weight int
Type string
ServerId string
Weight int
Type string
serverId string
weight number
type string
serverId str
weight float
type str

Package Details

Repository
https://github.com/pulumi/pulumi-alicloud
License
Apache-2.0
Notes
This Pulumi package is based on the alicloud Terraform Provider.