alicloud.slb.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 valueecs
,eni
,eci
. Default toecs
. NOTE: From 1.170.0+, Theeci
is valid.server_ip
- (Optional, Computed, Available in 1.93.0+) ServerIp of the backend server. This parameter can be specified when the type iseni
.ecs
type currently does not support addingserver_ip
parameter.
Example Usage
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AliCloud = Pulumi.AliCloud;
return await Deployment.RunAsync(() =>
{
var config = new Config();
var slbBackendServerName = config.Get("slbBackendServerName") ?? "slbbackendservertest";
var backendServerZones = AliCloud.GetZones.Invoke(new()
{
AvailableDiskCategory = "cloud_efficiency",
AvailableResourceCreation = "VSwitch",
});
var backendServerInstanceTypes = AliCloud.Ecs.GetInstanceTypes.Invoke(new()
{
AvailabilityZone = backendServerZones.Apply(getZonesResult => getZonesResult.Zones[0]?.Id),
CpuCoreCount = 1,
MemorySize = 2,
});
var backendServerImages = AliCloud.Ecs.GetImages.Invoke(new()
{
NameRegex = "^ubuntu_18.*64",
MostRecent = true,
Owners = "system",
});
var backendServerNetwork = new AliCloud.Vpc.Network("backendServerNetwork", new()
{
VpcName = slbBackendServerName,
CidrBlock = "172.16.0.0/16",
});
var backendServerSwitch = new AliCloud.Vpc.Switch("backendServerSwitch", new()
{
VpcId = backendServerNetwork.Id,
CidrBlock = "172.16.0.0/16",
ZoneId = backendServerZones.Apply(getZonesResult => getZonesResult.Zones[0]?.Id),
VswitchName = slbBackendServerName,
});
var backendServerSecurityGroup = new AliCloud.Ecs.SecurityGroup("backendServerSecurityGroup", new()
{
VpcId = backendServerNetwork.Id,
});
var backendServerInstance = new List<AliCloud.Ecs.Instance>();
for (var rangeIndex = 0; rangeIndex < "2"; rangeIndex++)
{
var range = new { Value = rangeIndex };
backendServerInstance.Add(new AliCloud.Ecs.Instance($"backendServerInstance-{range.Value}", new()
{
ImageId = backendServerImages.Apply(getImagesResult => getImagesResult.Images[0]?.Id),
InstanceType = backendServerInstanceTypes.Apply(getInstanceTypesResult => getInstanceTypesResult.InstanceTypes[0]?.Id),
InstanceName = slbBackendServerName,
SecurityGroups = new[]
{
backendServerSecurityGroup,
}.Select(__item => __item.Id).ToList(),
InternetChargeType = "PayByTraffic",
InternetMaxBandwidthOut = 10,
AvailabilityZone = backendServerZones.Apply(getZonesResult => getZonesResult.Zones[0]?.Id),
InstanceChargeType = "PostPaid",
SystemDiskCategory = "cloud_efficiency",
VswitchId = backendServerSwitch.Id,
}));
}
var backendServerApplicationLoadBalancer = new AliCloud.Slb.ApplicationLoadBalancer("backendServerApplicationLoadBalancer", new()
{
LoadBalancerName = slbBackendServerName,
VswitchId = backendServerSwitch.Id,
InstanceChargeType = "PayByCLCU",
});
var backendServerBackendServer = new AliCloud.Slb.BackendServer("backendServerBackendServer", new()
{
LoadBalancerId = backendServerApplicationLoadBalancer.Id,
BackendServers = new[]
{
new AliCloud.Slb.Inputs.BackendServerBackendServerArgs
{
ServerId = backendServerInstance[0].Id,
Weight = 100,
},
new AliCloud.Slb.Inputs.BackendServerBackendServerArgs
{
ServerId = backendServerInstance[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.inputs.GetZonesArgs;
import com.pulumi.alicloud.ecs.EcsFunctions;
import com.pulumi.alicloud.ecs.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 slbBackendServerName = config.get("slbBackendServerName").orElse("slbbackendservertest");
final var backendServerZones = AlicloudFunctions.getZones(GetZonesArgs.builder()
.availableDiskCategory("cloud_efficiency")
.availableResourceCreation("VSwitch")
.build());
final var backendServerInstanceTypes = EcsFunctions.getInstanceTypes(GetInstanceTypesArgs.builder()
.availabilityZone(backendServerZones.applyValue(getZonesResult -> getZonesResult.zones()[0].id()))
.cpuCoreCount(1)
.memorySize(2)
.build());
final var backendServerImages = EcsFunctions.getImages(GetImagesArgs.builder()
.nameRegex("^ubuntu_18.*64")
.mostRecent(true)
.owners("system")
.build());
var backendServerNetwork = new Network("backendServerNetwork", NetworkArgs.builder()
.vpcName(slbBackendServerName)
.cidrBlock("172.16.0.0/16")
.build());
var backendServerSwitch = new Switch("backendServerSwitch", SwitchArgs.builder()
.vpcId(backendServerNetwork.id())
.cidrBlock("172.16.0.0/16")
.zoneId(backendServerZones.applyValue(getZonesResult -> getZonesResult.zones()[0].id()))
.vswitchName(slbBackendServerName)
.build());
var backendServerSecurityGroup = new SecurityGroup("backendServerSecurityGroup", SecurityGroupArgs.builder()
.vpcId(backendServerNetwork.id())
.build());
for (var i = 0; i < "2"; i++) {
new Instance("backendServerInstance-" + i, InstanceArgs.builder()
.imageId(backendServerImages.applyValue(getImagesResult -> getImagesResult.images()[0].id()))
.instanceType(backendServerInstanceTypes.applyValue(getInstanceTypesResult -> getInstanceTypesResult.instanceTypes()[0].id()))
.instanceName(slbBackendServerName)
.securityGroups(backendServerSecurityGroup.stream().map(element -> element.id()).collect(toList()))
.internetChargeType("PayByTraffic")
.internetMaxBandwidthOut("10")
.availabilityZone(backendServerZones.applyValue(getZonesResult -> getZonesResult.zones()[0].id()))
.instanceChargeType("PostPaid")
.systemDiskCategory("cloud_efficiency")
.vswitchId(backendServerSwitch.id())
.build());
}
var backendServerApplicationLoadBalancer = new ApplicationLoadBalancer("backendServerApplicationLoadBalancer", ApplicationLoadBalancerArgs.builder()
.loadBalancerName(slbBackendServerName)
.vswitchId(backendServerSwitch.id())
.instanceChargeType("PayByCLCU")
.build());
var backendServerBackendServer = new BackendServer("backendServerBackendServer", BackendServerArgs.builder()
.loadBalancerId(backendServerApplicationLoadBalancer.id())
.backendServers(
BackendServerBackendServerArgs.builder()
.serverId(backendServerInstance[0].id())
.weight(100)
.build(),
BackendServerBackendServerArgs.builder()
.serverId(backendServerInstance[1].id())
.weight(100)
.build())
.build());
}
}
import pulumi
import pulumi_alicloud as alicloud
config = pulumi.Config()
slb_backend_server_name = config.get("slbBackendServerName")
if slb_backend_server_name is None:
slb_backend_server_name = "slbbackendservertest"
backend_server_zones = alicloud.get_zones(available_disk_category="cloud_efficiency",
available_resource_creation="VSwitch")
backend_server_instance_types = alicloud.ecs.get_instance_types(availability_zone=backend_server_zones.zones[0].id,
cpu_core_count=1,
memory_size=2)
backend_server_images = alicloud.ecs.get_images(name_regex="^ubuntu_18.*64",
most_recent=True,
owners="system")
backend_server_network = alicloud.vpc.Network("backendServerNetwork",
vpc_name=slb_backend_server_name,
cidr_block="172.16.0.0/16")
backend_server_switch = alicloud.vpc.Switch("backendServerSwitch",
vpc_id=backend_server_network.id,
cidr_block="172.16.0.0/16",
zone_id=backend_server_zones.zones[0].id,
vswitch_name=slb_backend_server_name)
backend_server_security_group = alicloud.ecs.SecurityGroup("backendServerSecurityGroup", vpc_id=backend_server_network.id)
backend_server_instance = []
for range in [{"value": i} for i in range(0, 2)]:
backend_server_instance.append(alicloud.ecs.Instance(f"backendServerInstance-{range['value']}",
image_id=backend_server_images.images[0].id,
instance_type=backend_server_instance_types.instance_types[0].id,
instance_name=slb_backend_server_name,
security_groups=[__item.id for __item in [backend_server_security_group]],
internet_charge_type="PayByTraffic",
internet_max_bandwidth_out=10,
availability_zone=backend_server_zones.zones[0].id,
instance_charge_type="PostPaid",
system_disk_category="cloud_efficiency",
vswitch_id=backend_server_switch.id))
backend_server_application_load_balancer = alicloud.slb.ApplicationLoadBalancer("backendServerApplicationLoadBalancer",
load_balancer_name=slb_backend_server_name,
vswitch_id=backend_server_switch.id,
instance_charge_type="PayByCLCU")
backend_server_backend_server = alicloud.slb.BackendServer("backendServerBackendServer",
load_balancer_id=backend_server_application_load_balancer.id,
backend_servers=[
alicloud.slb.BackendServerBackendServerArgs(
server_id=backend_server_instance[0].id,
weight=100,
),
alicloud.slb.BackendServerBackendServerArgs(
server_id=backend_server_instance[1].id,
weight=100,
),
])
import * as pulumi from "@pulumi/pulumi";
import * as alicloud from "@pulumi/alicloud";
const config = new pulumi.Config();
const slbBackendServerName = config.get("slbBackendServerName") || "slbbackendservertest";
const backendServerZones = alicloud.getZones({
availableDiskCategory: "cloud_efficiency",
availableResourceCreation: "VSwitch",
});
const backendServerInstanceTypes = backendServerZones.then(backendServerZones => alicloud.ecs.getInstanceTypes({
availabilityZone: backendServerZones.zones?.[0]?.id,
cpuCoreCount: 1,
memorySize: 2,
}));
const backendServerImages = alicloud.ecs.getImages({
nameRegex: "^ubuntu_18.*64",
mostRecent: true,
owners: "system",
});
const backendServerNetwork = new alicloud.vpc.Network("backendServerNetwork", {
vpcName: slbBackendServerName,
cidrBlock: "172.16.0.0/16",
});
const backendServerSwitch = new alicloud.vpc.Switch("backendServerSwitch", {
vpcId: backendServerNetwork.id,
cidrBlock: "172.16.0.0/16",
zoneId: backendServerZones.then(backendServerZones => backendServerZones.zones?.[0]?.id),
vswitchName: slbBackendServerName,
});
const backendServerSecurityGroup = new alicloud.ecs.SecurityGroup("backendServerSecurityGroup", {vpcId: backendServerNetwork.id});
const backendServerInstance: alicloud.ecs.Instance[] = [];
for (const range = {value: 0}; range.value < "2"; range.value++) {
backendServerInstance.push(new alicloud.ecs.Instance(`backendServerInstance-${range.value}`, {
imageId: backendServerImages.then(backendServerImages => backendServerImages.images?.[0]?.id),
instanceType: backendServerInstanceTypes.then(backendServerInstanceTypes => backendServerInstanceTypes.instanceTypes?.[0]?.id),
instanceName: slbBackendServerName,
securityGroups: [backendServerSecurityGroup].map(__item => __item.id),
internetChargeType: "PayByTraffic",
internetMaxBandwidthOut: 10,
availabilityZone: backendServerZones.then(backendServerZones => backendServerZones.zones?.[0]?.id),
instanceChargeType: "PostPaid",
systemDiskCategory: "cloud_efficiency",
vswitchId: backendServerSwitch.id,
}));
}
const backendServerApplicationLoadBalancer = new alicloud.slb.ApplicationLoadBalancer("backendServerApplicationLoadBalancer", {
loadBalancerName: slbBackendServerName,
vswitchId: backendServerSwitch.id,
instanceChargeType: "PayByCLCU",
});
const backendServerBackendServer = new alicloud.slb.BackendServer("backendServerBackendServer", {
loadBalancerId: backendServerApplicationLoadBalancer.id,
backendServers: [
{
serverId: backendServerInstance[0].id,
weight: 100,
},
{
serverId: backendServerInstance[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:
- Load
Balancer stringId ID of the load balancer.
- Backend
Servers List<Pulumi.Ali Cloud. Slb. Inputs. Backend Server Backend Server Args> A list of instances to added backend server in the SLB. It contains three sub-fields as
Block server
follows.- 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 ID of the load balancer.
- Backend
Servers []BackendServer Backend Server Args A list of instances to added backend server in the SLB. It contains three sub-fields as
Block server
follows.- 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 ID of the load balancer.
- backend
Servers List<BackendServer Backend Server Args> A list of instances to added backend server in the SLB. It contains three sub-fields as
Block server
follows.- 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 ID of the load balancer.
- backend
Servers BackendServer Backend Server Args[] A list of instances to added backend server in the SLB. It contains three sub-fields as
Block server
follows.- 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_ strid ID of the load balancer.
- backend_
servers Sequence[BackendServer Backend Server Args] A list of instances to added backend server in the SLB. It contains three sub-fields as
Block server
follows.- 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 ID of the load balancer.
- backend
Servers List<Property Map> A list of instances to added backend server in the SLB. It contains three sub-fields as
Block server
follows.- 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.
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.
- Backend
Servers List<Pulumi.Ali Cloud. Slb. Inputs. Backend Server Backend Server Args> A list of instances to added backend server in the SLB. It contains three sub-fields as
Block server
follows.- 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 ID of the load balancer.
- Backend
Servers []BackendServer Backend Server Args A list of instances to added backend server in the SLB. It contains three sub-fields as
Block server
follows.- 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 ID of the load balancer.
- backend
Servers List<BackendServer Backend Server Args> A list of instances to added backend server in the SLB. It contains three sub-fields as
Block server
follows.- 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 ID of the load balancer.
- backend
Servers BackendServer Backend Server Args[] A list of instances to added backend server in the SLB. It contains three sub-fields as
Block server
follows.- 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 ID of the load balancer.
- backend_
servers Sequence[BackendServer Backend Server Args] A list of instances to added backend server in the SLB. It contains three sub-fields as
Block server
follows.- 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 ID of the load balancer.
- backend
Servers List<Property Map> A list of instances to added backend server in the SLB. It contains three sub-fields as
Block server
follows.- 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 ID of the load balancer.
Supporting Types
BackendServerBackendServer
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
- Alibaba Cloud pulumi/pulumi-alicloud
- License
- Apache-2.0
- Notes
This Pulumi package is based on the
alicloud
Terraform Provider.