Skip to content

LoadBalancer

This class encapsulates and extends the ROS resource type ALIYUN::SLB::LoadBalancerUse the , which resource type to create an SLB instance.

Initializers

import com.aliyun.ros.cdk.slb.LoadBalancer;
LoadBalancer.Builder.create(Construct scope, java.lang.String id, java.lang.Boolean enableResourcePropertyConstraint)
//  .addressIpVersion(java.lang.String)
//  .addressIpVersion(IResolvable)
//  .addressType(java.lang.String)
//  .addressType(IResolvable)
//  .bandwidth(java.lang.Number)
//  .bandwidth(IResolvable)
//  .deletionProtection(java.lang.Boolean)
//  .deletionProtection(IResolvable)
//  .instanceChargeType(java.lang.String)
//  .instanceChargeType(IResolvable)
//  .internetChargeType(java.lang.String)
//  .internetChargeType(IResolvable)
//  .loadBalancerName(java.lang.String)
//  .loadBalancerName(IResolvable)
//  .loadBalancerSpec(java.lang.String)
//  .loadBalancerSpec(IResolvable)
//  .masterZoneId(java.lang.String)
//  .masterZoneId(IResolvable)
//  .modificationProtectionReason(java.lang.String)
//  .modificationProtectionReason(IResolvable)
//  .modificationProtectionStatus(java.lang.String)
//  .modificationProtectionStatus(IResolvable)
//  .resourceGroupId(java.lang.String)
//  .resourceGroupId(IResolvable)
//  .slaveZoneId(java.lang.String)
//  .slaveZoneId(IResolvable)
//  .tags(java.util.List<TagsProperty>)
//  .vpcId(java.lang.String)
//  .vpcId(IResolvable)
//  .vSwitchId(java.lang.String)
//  .vSwitchId(IResolvable)
    .build();
Name Type Description
scope com.aliyun.ros.cdk.core.Construct No description.
id java.lang.String No description.
enableResourcePropertyConstraint java.lang.Boolean No description.
addressIpVersion java.lang.String OR com.aliyun.ros.cdk.core.IResolvable Property addressIpVersion: The IP version of the CLB instance.
addressType java.lang.String OR com.aliyun.ros.cdk.core.IResolvable Property addressType: The network type of the CLB instance.
bandwidth java.lang.Number OR com.aliyun.ros.cdk.core.IResolvable Property bandwidth: The bandwidth for network, unit in Mbps(Mega bit per second).
deletionProtection java.lang.Boolean OR com.aliyun.ros.cdk.core.IResolvable Property deletionProtection: Whether to enable deletion protection.
instanceChargeType java.lang.String OR com.aliyun.ros.cdk.core.IResolvable Property instanceChargeType: The resource metering method for the CLB instance.
internetChargeType java.lang.String OR com.aliyun.ros.cdk.core.IResolvable Property internetChargeType: The metering method of the Internet-facing CLB instance.
loadBalancerName java.lang.String OR com.aliyun.ros.cdk.core.IResolvable Property loadBalancerName: The CLB instance name.
loadBalancerSpec java.lang.String OR com.aliyun.ros.cdk.core.IResolvable Property loadBalancerSpec: The specification of the CLB instance.
masterZoneId java.lang.String OR com.aliyun.ros.cdk.core.IResolvable Property masterZoneId: The master zone id to create load balancer instance.
modificationProtectionReason java.lang.String OR com.aliyun.ros.cdk.core.IResolvable Property modificationProtectionReason: The reason for enabling the configuration read-only mode.
modificationProtectionStatus java.lang.String OR com.aliyun.ros.cdk.core.IResolvable Property modificationProtectionStatus: Specifies whether to enable the configuration read-only mode.
resourceGroupId java.lang.String OR com.aliyun.ros.cdk.core.IResolvable Property resourceGroupId: Resource group id.
slaveZoneId java.lang.String OR com.aliyun.ros.cdk.core.IResolvable Property slaveZoneId: The slave zone id to create load balancer instance.
tags java.util.List<TagsProperty> Property tags: Tags to attach to slb.
vpcId java.lang.String OR com.aliyun.ros.cdk.core.IResolvable Property vpcId: The VPC id to create load balancer instance.
vSwitchId java.lang.String OR com.aliyun.ros.cdk.core.IResolvable Property vSwitchId: The ID of the vSwitch to which the CLB instance belongs.

scopeRequired

  • Type: com.aliyun.ros.cdk.core.Construct

idRequired

  • Type: java.lang.String

enableResourcePropertyConstraintOptional

  • Type: java.lang.Boolean

addressIpVersionOptional

  • Type: java.lang.String OR com.aliyun.ros.cdk.core.IResolvable

Property addressIpVersion: The IP version of the CLB instance.

Valid values: ipv4 and ipv6.


addressTypeOptional

  • Type: java.lang.String OR com.aliyun.ros.cdk.core.IResolvable

Property addressType: The network type of the CLB instance.

Valid values:

  • internet (default): After an internet-facing CLB instance is created, the system assigns a public IP address to the CLB instance. Then, the CLB instance can forward requests over the Internet.
  • intranet: After an internal-facing CLB instance is created, the system assigns a private IP address to the CLB instance. Then, the CLB instance can forward requests only over the internal networks.

bandwidthOptional

  • Type: java.lang.Number OR com.aliyun.ros.cdk.core.IResolvable

Property bandwidth: The bandwidth for network, unit in Mbps(Mega bit per second).

Default is 1. If InternetChargeType is specified as "paybytraffic", this property will be ignore and please specify the "Bandwidth" in ALIYUN::SLB::Listener.


deletionProtectionOptional

  • Type: java.lang.Boolean OR com.aliyun.ros.cdk.core.IResolvable

Property deletionProtection: Whether to enable deletion protection.


instanceChargeTypeOptional

  • Type: java.lang.String OR com.aliyun.ros.cdk.core.IResolvable

Property instanceChargeType: The resource metering method for the CLB instance.

Valid value:

  • PayByCLCU: pay-by-data-transfer

As of 00:00:00 (UTC+8) on June 1, 2025, pay-by-specification CLB instances are no longer available for purchase. For more details, see .


internetChargeTypeOptional

  • Type: java.lang.String OR com.aliyun.ros.cdk.core.IResolvable

Property internetChargeType: The metering method of the Internet-facing CLB instance.

Valid values:

  • paybytraffic (default): If you set the value to paybytraffic, you do not need to specify Bandwidth. Even if you specify Bandwidth, the value does not take effect.
  • paybybandwidth: pay-by-bandwidth. Note If you set PayType to PayOnDemand and set InstanceChargeType to PayByCLCU, you must set InternetChargeType to paybytraffic.

loadBalancerNameOptional

  • Type: java.lang.String OR com.aliyun.ros.cdk.core.IResolvable

Property loadBalancerName: The CLB instance name.

The name must be 1 to 80 characters in length, and can contain digits, periods (.), underscores (_), and hyphens (-). It must start with a letter. If you do not specify this parameter, the system automatically assigns a name to the CLB instance.


loadBalancerSpecOptional

  • Type: java.lang.String OR com.aliyun.ros.cdk.core.IResolvable

Property loadBalancerSpec: The specification of the CLB instance.

Valid values:

  • slb.s1.small
  • slb.s2.small
  • slb.s2.medium
  • slb.s3.small
  • slb.s3.medium
  • slb.s3.large
  • If InstanceChargeType is set to PayByCLCU, this parameter is invalid and you do not need to specify this parameter.
  • As of 00:00:00 (UTC+8) on June 1, 2025, pay-by-specification CLB instances are no longer available for purchase. For more details, see .

masterZoneIdOptional

  • Type: java.lang.String OR com.aliyun.ros.cdk.core.IResolvable

Property masterZoneId: The master zone id to create load balancer instance.


modificationProtectionReasonOptional

  • Type: java.lang.String OR com.aliyun.ros.cdk.core.IResolvable

Property modificationProtectionReason: The reason for enabling the configuration read-only mode.

The reason must be 1 to 80 characters in length. It must start with a letter and can contain letters, digits, periods (.), underscores (_), and hyphens (-).

This parameter takes effect only when ModificationProtectionStatus is set to ConsoleProtection.


modificationProtectionStatusOptional

  • Type: java.lang.String OR com.aliyun.ros.cdk.core.IResolvable

Property modificationProtectionStatus: Specifies whether to enable the configuration read-only mode.

Valid values:

  • NonProtection: disables the configuration read-only mode. After you disable the configuration read-only mode, the value of ModificationProtectionReason is cleared.
  • ConsoleProtection: enables the configuration read-only mode.

If you set this parameter to ConsoleProtection, you cannot modify instance configurations in the CLB console. However, you can modify instance configurations by calling API operations.


resourceGroupIdOptional

  • Type: java.lang.String OR com.aliyun.ros.cdk.core.IResolvable

Property resourceGroupId: Resource group id.


slaveZoneIdOptional

  • Type: java.lang.String OR com.aliyun.ros.cdk.core.IResolvable

Property slaveZoneId: The slave zone id to create load balancer instance.


tagsOptional

Property tags: Tags to attach to slb.

Max support 5 tags to add during create slb. Each tag with two properties Key and Value, and Key is required.


vpcIdOptional

  • Type: java.lang.String OR com.aliyun.ros.cdk.core.IResolvable

Property vpcId: The VPC id to create load balancer instance.

For VPC network only.


vSwitchIdOptional

  • Type: java.lang.String OR com.aliyun.ros.cdk.core.IResolvable

Property vSwitchId: The ID of the vSwitch to which the CLB instance belongs.

If you want to deploy the CLB instance in a VPC, this parameter is required. If this parameter is specified, AddessType is set to intranet by default.

The vSwitch must be in the primary zone.


Methods

Name Description
toString Returns a string representation of this construct.
synthesize Allows this construct to emit artifacts into the cloud assembly during synthesis.
addCondition No description.
addCount No description.
addDependency No description.
addResourceDesc No description.
applyRemovalPolicy No description.
fetchCondition No description.
fetchDependency No description.
fetchResourceDesc No description.
getAtt No description.
setMetadata No description.

toString

public java.lang.String toString()

Returns a string representation of this construct.

synthesize

public void synthesize(ISynthesisSession session)

Allows this construct to emit artifacts into the cloud assembly during synthesis.

This method is usually implemented by framework-level constructs such as Stack and Asset as they participate in synthesizing the cloud assembly.

sessionRequired

  • Type: com.aliyun.ros.cdk.core.ISynthesisSession

The synthesis session.


addCondition

public void addCondition(RosCondition condition)

conditionRequired

  • Type: com.aliyun.ros.cdk.core.RosCondition

addCount

public void addCount(java.lang.Number OR IResolvable count)

countRequired

  • Type: java.lang.Number OR com.aliyun.ros.cdk.core.IResolvable

addDependency

public void addDependency(Resource resource)

resourceRequired

  • Type: com.aliyun.ros.cdk.core.Resource

addResourceDesc

public void addResourceDesc(java.lang.String desc)

descRequired

  • Type: java.lang.String

applyRemovalPolicy

public void applyRemovalPolicy(RemovalPolicy policy)

policyRequired

  • Type: com.aliyun.ros.cdk.core.RemovalPolicy

fetchCondition

public RosCondition fetchCondition()

fetchDependency

public java.util.List<java.lang.String> fetchDependency()

fetchResourceDesc

public java.lang.String fetchResourceDesc()

getAtt

public IResolvable getAtt(java.lang.String name)

nameRequired

  • Type: java.lang.String

setMetadata

public void setMetadata(java.lang.String key, java.lang.Object value)

keyRequired

  • Type: java.lang.String

valueRequired

  • Type: java.lang.Object

Static Functions

Name Description
isConstruct Return whether the given object is a Construct.

isConstruct

import com.aliyun.ros.cdk.slb.LoadBalancer;
LoadBalancer.isConstruct(java.lang.Object x)

Return whether the given object is a Construct.

xRequired

  • Type: java.lang.Object

Properties

Name Type Description
node com.aliyun.ros.cdk.core.ConstructNode The construct tree node associated with this construct.
env com.aliyun.ros.cdk.core.IResourceEnvironment The environment this resource belongs to.
ref java.lang.String No description.
stack com.aliyun.ros.cdk.core.Stack The stack in which this resource is defined.
resource com.aliyun.ros.cdk.core.RosResource No description.
attrAddressIpVersion java.lang.String OR com.aliyun.ros.cdk.core.IResolvable Attribute AddressIPVersion: IP version.
attrAddressType java.lang.String OR com.aliyun.ros.cdk.core.IResolvable Attribute AddressType: The address type of the load balancer.
attrBandwidth java.lang.String OR com.aliyun.ros.cdk.core.IResolvable Attribute Bandwidth: The bandwidth for network.
attrIpAddress java.lang.String OR com.aliyun.ros.cdk.core.IResolvable Attribute IpAddress: The ip address of the load balancer.
attrLoadBalancerId java.lang.String OR com.aliyun.ros.cdk.core.IResolvable Attribute LoadBalancerId: The id of load balance created.
attrLoadBalancerName java.lang.String OR com.aliyun.ros.cdk.core.IResolvable Attribute LoadBalancerName: Name of created load balancer.
attrLoadBalancerSpec java.lang.String OR com.aliyun.ros.cdk.core.IResolvable Attribute LoadBalancerSpec: The specification of the Server Load Balancer instance.
attrMasterZoneId java.lang.String OR com.aliyun.ros.cdk.core.IResolvable Attribute MasterZoneId: The master zone id to create load balancer instance.
attrNetworkType java.lang.String OR com.aliyun.ros.cdk.core.IResolvable Attribute NetworkType: The network type of the load balancer.
attrOrderId java.lang.String OR com.aliyun.ros.cdk.core.IResolvable Attribute OrderId: The order ID.
attrPayType java.lang.String OR com.aliyun.ros.cdk.core.IResolvable Attribute PayType: The billing method of the instance to be created.
attrResourceGroupId java.lang.String OR com.aliyun.ros.cdk.core.IResolvable Attribute ResourceGroupId: Resource group id.
attrSlaveZoneId java.lang.String OR com.aliyun.ros.cdk.core.IResolvable Attribute SlaveZoneId: The slave zone id to create load balancer instance.
attrVpcId java.lang.String OR com.aliyun.ros.cdk.core.IResolvable Attribute VpcId: Vpc id.
attrVSwitchId java.lang.String OR com.aliyun.ros.cdk.core.IResolvable Attribute VSwitchId: VSwitch id.
props LoadBalancerProps No description.

nodeRequired

public ConstructNode getNode();
  • Type: com.aliyun.ros.cdk.core.ConstructNode

The construct tree node associated with this construct.


envRequired

public IResourceEnvironment getEnv();
  • Type: com.aliyun.ros.cdk.core.IResourceEnvironment

The environment this resource belongs to.

For resources that are created and managed by the CDK (generally, those created by creating new class instances like Role, Bucket, etc.), this is always the same as the environment of the stack they belong to; however, for imported resources (those obtained from static methods like fromRoleArn, fromBucketName, etc.), that might be different than the stack they were imported into.


refRequired

public java.lang.String getRef();
  • Type: java.lang.String

stackRequired

public Stack getStack();
  • Type: com.aliyun.ros.cdk.core.Stack

The stack in which this resource is defined.


resourceOptional

public RosResource getResource();
  • Type: com.aliyun.ros.cdk.core.RosResource

attrAddressIpVersionRequired

public java.lang.Object getAttrAddressIpVersion();
  • Type: java.lang.String OR com.aliyun.ros.cdk.core.IResolvable

Attribute AddressIPVersion: IP version.


attrAddressTypeRequired

public java.lang.Object getAttrAddressType();
  • Type: java.lang.String OR com.aliyun.ros.cdk.core.IResolvable

Attribute AddressType: The address type of the load balancer.

"intranet" or "internet".


attrBandwidthRequired

public java.lang.Object getAttrBandwidth();
  • Type: java.lang.String OR com.aliyun.ros.cdk.core.IResolvable

Attribute Bandwidth: The bandwidth for network.


attrIpAddressRequired

public java.lang.Object getAttrIpAddress();
  • Type: java.lang.String OR com.aliyun.ros.cdk.core.IResolvable

Attribute IpAddress: The ip address of the load balancer.


attrLoadBalancerIdRequired

public java.lang.Object getAttrLoadBalancerId();
  • Type: java.lang.String OR com.aliyun.ros.cdk.core.IResolvable

Attribute LoadBalancerId: The id of load balance created.


attrLoadBalancerNameRequired

public java.lang.Object getAttrLoadBalancerName();
  • Type: java.lang.String OR com.aliyun.ros.cdk.core.IResolvable

Attribute LoadBalancerName: Name of created load balancer.


attrLoadBalancerSpecRequired

public java.lang.Object getAttrLoadBalancerSpec();
  • Type: java.lang.String OR com.aliyun.ros.cdk.core.IResolvable

Attribute LoadBalancerSpec: The specification of the Server Load Balancer instance.


attrMasterZoneIdRequired

public java.lang.Object getAttrMasterZoneId();
  • Type: java.lang.String OR com.aliyun.ros.cdk.core.IResolvable

Attribute MasterZoneId: The master zone id to create load balancer instance.


attrNetworkTypeRequired

public java.lang.Object getAttrNetworkType();
  • Type: java.lang.String OR com.aliyun.ros.cdk.core.IResolvable

Attribute NetworkType: The network type of the load balancer.

"vpc" or "classic" network.


attrOrderIdRequired

public java.lang.Object getAttrOrderId();
  • Type: java.lang.String OR com.aliyun.ros.cdk.core.IResolvable

Attribute OrderId: The order ID.


attrPayTypeRequired

public java.lang.Object getAttrPayType();
  • Type: java.lang.String OR com.aliyun.ros.cdk.core.IResolvable

Attribute PayType: The billing method of the instance to be created.


attrResourceGroupIdRequired

public java.lang.Object getAttrResourceGroupId();
  • Type: java.lang.String OR com.aliyun.ros.cdk.core.IResolvable

Attribute ResourceGroupId: Resource group id.


attrSlaveZoneIdRequired

public java.lang.Object getAttrSlaveZoneId();
  • Type: java.lang.String OR com.aliyun.ros.cdk.core.IResolvable

Attribute SlaveZoneId: The slave zone id to create load balancer instance.


attrVpcIdRequired

public java.lang.Object getAttrVpcId();
  • Type: java.lang.String OR com.aliyun.ros.cdk.core.IResolvable

Attribute VpcId: Vpc id.


attrVSwitchIdRequired

public java.lang.Object getAttrVSwitchId();
  • Type: java.lang.String OR com.aliyun.ros.cdk.core.IResolvable

Attribute VSwitchId: VSwitch id.


propsRequired

public LoadBalancerProps getProps();