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, eci. Default to ecs. NOTE: From 1.170.0+, The eci is valid.
  • server_ip - (Optional, Computed, Available in 1.93.0+) ServerIp of the backend server. This parameter can be specified when the type is eni. ecs type currently does not support adding server_ip parameter.

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
        {
            NameRegex = "^ubuntu_18.*64",
            MostRecent = true,
            Owners = "system",
        }));
        var defaultNetwork = new AliCloud.Vpc.Network("defaultNetwork", new AliCloud.Vpc.NetworkArgs
        {
            VpcName = name,
            CidrBlock = "172.16.0.0/16",
        });
        var defaultSwitch = new AliCloud.Vpc.Switch("defaultSwitch", new AliCloud.Vpc.SwitchArgs
        {
            VpcId = defaultNetwork.Id,
            CidrBlock = "172.16.0.0/16",
            ZoneId = defaultZones.Apply(defaultZones => defaultZones.Zones?[0]?.Id),
            VswitchName = name,
        });
        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
            {
                ImageId = defaultImages.Apply(defaultImages => defaultImages.Images?[0]?.Id),
                InstanceType = defaultInstanceTypes.Apply(defaultInstanceTypes => defaultInstanceTypes.InstanceTypes?[0]?.Id),
                InstanceName = name,
                SecurityGroups = 
                {
                    defaultSecurityGroup,
                }.Select(__item => __item.Id).ToList(),
                InternetChargeType = "PayByTraffic",
                InternetMaxBandwidthOut = 10,
                AvailabilityZone = defaultZones.Apply(defaultZones => defaultZones.Zones?[0]?.Id),
                InstanceChargeType = "PostPaid",
                SystemDiskCategory = "cloud_efficiency",
                VswitchId = defaultSwitch.Id,
            }));
        }
        var defaultApplicationLoadBalancer = new AliCloud.Slb.ApplicationLoadBalancer("defaultApplicationLoadBalancer", new AliCloud.Slb.ApplicationLoadBalancerArgs
        {
            LoadBalancerName = name,
            VswitchId = defaultSwitch.Id,
        });
        var defaultBackendServer = new AliCloud.Slb.BackendServer("defaultBackendServer", new AliCloud.Slb.BackendServerArgs
        {
            LoadBalancerId = defaultApplicationLoadBalancer.Id,
            BackendServers = 
            {
                new AliCloud.Slb.Inputs.BackendServerBackendServerArgs
                {
                    ServerId = defaultInstance[0].Id,
                    Weight = 100,
                },
                new AliCloud.Slb.Inputs.BackendServerBackendServerArgs
                {
                    ServerId = defaultInstance[1].Id,
                    Weight = 100,
                },
            },
        });
    }

}

Coming soon!

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.adb.inputs.GetZonesArgs;
import com.pulumi.alicloud.ecs.EcsFunctions;
import com.pulumi.alicloud.ecp.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.slb.BackendServer;
import com.pulumi.alicloud.slb.BackendServerArgs;
import com.pulumi.alicloud.slb.inputs.BackendServerBackendServerArgs;
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 name = config.get("name").orElse("slbbackendservertest");
        final var defaultZones = AlicloudFunctions.getZones(GetZonesArgs.builder()
            .availableDiskCategory("cloud_efficiency")
            .availableResourceCreation("VSwitch")
            .build());

        final var defaultInstanceTypes = EcsFunctions.getInstanceTypes(GetInstanceTypesArgs.builder()
            .availabilityZone(defaultZones.applyValue(getZonesResult -> getZonesResult.zones()[0].id()))
            .cpuCoreCount(1)
            .memorySize(2)
            .build());

        final var defaultImages = EcsFunctions.getImages(GetImagesArgs.builder()
            .nameRegex("^ubuntu_18.*64")
            .mostRecent(true)
            .owners("system")
            .build());

        var defaultNetwork = new Network("defaultNetwork", NetworkArgs.builder()        
            .vpcName(name)
            .cidrBlock("172.16.0.0/16")
            .build());

        var defaultSwitch = new Switch("defaultSwitch", SwitchArgs.builder()        
            .vpcId(defaultNetwork.id())
            .cidrBlock("172.16.0.0/16")
            .zoneId(defaultZones.applyValue(getZonesResult -> getZonesResult.zones()[0].id()))
            .vswitchName(name)
            .build());

        var defaultSecurityGroup = new SecurityGroup("defaultSecurityGroup", SecurityGroupArgs.builder()        
            .vpcId(defaultNetwork.id())
            .build());

        for (var i = 0; i < "2"; i++) {
            new Instance("defaultInstance-" + i, InstanceArgs.builder()            
                .imageId(defaultImages.applyValue(getImagesResult -> getImagesResult.images()[0].id()))
                .instanceType(defaultInstanceTypes.applyValue(getInstanceTypesResult -> getInstanceTypesResult.instanceTypes()[0].id()))
                .instanceName(name)
                .securityGroups(defaultSecurityGroup.stream().map(element -> element.id()).collect(toList()))
                .internetChargeType("PayByTraffic")
                .internetMaxBandwidthOut("10")
                .availabilityZone(defaultZones.applyValue(getZonesResult -> getZonesResult.zones()[0].id()))
                .instanceChargeType("PostPaid")
                .systemDiskCategory("cloud_efficiency")
                .vswitchId(defaultSwitch.id())
                .build());

        
}
        var defaultApplicationLoadBalancer = new ApplicationLoadBalancer("defaultApplicationLoadBalancer", ApplicationLoadBalancerArgs.builder()        
            .loadBalancerName(name)
            .vswitchId(defaultSwitch.id())
            .build());

        var defaultBackendServer = new BackendServer("defaultBackendServer", BackendServerArgs.builder()        
            .loadBalancerId(defaultApplicationLoadBalancer.id())
            .backendServers(            
                BackendServerBackendServerArgs.builder()
                    .serverId(defaultInstance[0].id())
                    .weight(100)
                    .build(),
                BackendServerBackendServerArgs.builder()
                    .serverId(defaultInstance[1].id())
                    .weight(100)
                    .build())
            .build());

    }
}
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(name_regex="^ubuntu_18.*64",
    most_recent=True,
    owners="system")
default_network = alicloud.vpc.Network("defaultNetwork",
    vpc_name=name,
    cidr_block="172.16.0.0/16")
default_switch = alicloud.vpc.Switch("defaultSwitch",
    vpc_id=default_network.id,
    cidr_block="172.16.0.0/16",
    zone_id=default_zones.zones[0].id,
    vswitch_name=name)
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']}",
        image_id=default_images.images[0].id,
        instance_type=default_instance_types.instance_types[0].id,
        instance_name=name,
        security_groups=[__item.id for __item in [default_security_group]],
        internet_charge_type="PayByTraffic",
        internet_max_bandwidth_out=10,
        availability_zone=default_zones.zones[0].id,
        instance_charge_type="PostPaid",
        system_disk_category="cloud_efficiency",
        vswitch_id=default_switch.id))
default_application_load_balancer = alicloud.slb.ApplicationLoadBalancer("defaultApplicationLoadBalancer",
    load_balancer_name=name,
    vswitch_id=default_switch.id)
default_backend_server = alicloud.slb.BackendServer("defaultBackendServer",
    load_balancer_id=default_application_load_balancer.id,
    backend_servers=[
        alicloud.slb.BackendServerBackendServerArgs(
            server_id=default_instance[0].id,
            weight=100,
        ),
        alicloud.slb.BackendServerBackendServerArgs(
            server_id=default_instance[1].id,
            weight=100,
        ),
    ])
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 = alicloud.getZones({
    availableDiskCategory: "cloud_efficiency",
    availableResourceCreation: "VSwitch",
});
const defaultInstanceTypes = defaultZones.then(defaultZones => alicloud.ecs.getInstanceTypes({
    availabilityZone: defaultZones.zones?[0]?.id,
    cpuCoreCount: 1,
    memorySize: 2,
}));
const defaultImages = alicloud.ecs.getImages({
    nameRegex: "^ubuntu_18.*64",
    mostRecent: true,
    owners: "system",
});
const defaultNetwork = new alicloud.vpc.Network("defaultNetwork", {
    vpcName: name,
    cidrBlock: "172.16.0.0/16",
});
const defaultSwitch = new alicloud.vpc.Switch("defaultSwitch", {
    vpcId: defaultNetwork.id,
    cidrBlock: "172.16.0.0/16",
    zoneId: defaultZones.then(defaultZones => defaultZones.zones?[0]?.id),
    vswitchName: name,
});
const defaultSecurityGroup = new alicloud.ecs.SecurityGroup("defaultSecurityGroup", {vpcId: defaultNetwork.id});
const defaultInstance: alicloud.ecs.Instance[];
for (const range = {value: 0}; range.value < "2"; range.value++) {
    defaultInstance.push(new alicloud.ecs.Instance(`defaultInstance-${range.value}`, {
        imageId: defaultImages.then(defaultImages => defaultImages.images?[0]?.id),
        instanceType: defaultInstanceTypes.then(defaultInstanceTypes => defaultInstanceTypes.instanceTypes?[0]?.id),
        instanceName: name,
        securityGroups: [defaultSecurityGroup].map(__item => __item.id),
        internetChargeType: "PayByTraffic",
        internetMaxBandwidthOut: 10,
        availabilityZone: defaultZones.then(defaultZones => defaultZones.zones?[0]?.id),
        instanceChargeType: "PostPaid",
        systemDiskCategory: "cloud_efficiency",
        vswitchId: defaultSwitch.id,
    }));
}
const defaultApplicationLoadBalancer = new alicloud.slb.ApplicationLoadBalancer("defaultApplicationLoadBalancer", {
    loadBalancerName: name,
    vswitchId: defaultSwitch.id,
});
const defaultBackendServer = new alicloud.slb.BackendServer("defaultBackendServer", {
    loadBalancerId: defaultApplicationLoadBalancer.id,
    backendServers: [
        {
            serverId: defaultInstance[0].id,
            weight: 100,
        },
        {
            serverId: defaultInstance[1].id,
            weight: 100,
        },
    ],
});

Coming soon!

Create BackendServer Resource

new BackendServer(name: string, args: BackendServerArgs, opts?: CustomResourceOptions);
@overload
def BackendServer(resource_name: str,
                  opts: Optional[ResourceOptions] = None,
                  backend_servers: Optional[Sequence[BackendServerBackendServerArgs]] = None,
                  delete_protection_validation: Optional[bool] = None,
                  load_balancer_id: Optional[str] = None)
@overload
def BackendServer(resource_name: str,
                  args: BackendServerArgs,
                  opts: Optional[ResourceOptions] = None)
func NewBackendServer(ctx *Context, name string, args BackendServerArgs, opts ...ResourceOption) (*BackendServer, error)
public BackendServer(string name, BackendServerArgs args, CustomResourceOptions? opts = null)
public BackendServer(String name, BackendServerArgs args)
public BackendServer(String name, BackendServerArgs args, CustomResourceOptions options)
type: alicloud:slb:BackendServer
properties: # The arguments to resource properties.
options: # 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.
resource_name str
The unique name of the resource.
args BackendServerArgs
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 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.
name String
The unique name of the resource.
args BackendServerArgs
The arguments to resource properties.
options 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 Architecture and Concepts 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 []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 List<BackendServerBackendServerArgs>

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.

backendServers BackendServerBackendServerArgs[]

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 Sequence[BackendServerBackendServerArgs]

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.

loadBalancerId String

ID of the load balancer.

backendServers List<Property Map>

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.

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 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 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
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        backend_servers: Optional[Sequence[BackendServerBackendServerArgs]] = None,
        delete_protection_validation: Optional[bool] = None,
        load_balancer_id: Optional[str] = None) -> BackendServer
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)
public static BackendServer get(String name, Output<String> id, BackendServerState 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.
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 []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 List<BackendServerBackendServerArgs>

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.

backendServers BackendServerBackendServerArgs[]

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 Sequence[BackendServerBackendServerArgs]

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.

backendServers List<Property Map>

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.

Supporting Types

BackendServerBackendServer

ServerId string
Weight int
ServerIp string
Type string
ServerId string
Weight int
ServerIp string
Type string
serverId String
weight Integer
serverIp String
type String
serverId string
weight number
serverIp string
type string
serverId String
weight Number
serverIp String
type String

Import

Load balancer backend server can be imported using the load balancer id.

 $ pulumi import alicloud:slb/backendServer:BackendServer example <load_balancer_id>

Package Details

Repository
https://github.com/pulumi/pulumi-alicloud
License
Apache-2.0
Notes

This Pulumi package is based on the alicloud Terraform Provider.