Bu sayfa henüz yerel dilinizde mevcut değildir. Daha fazla dil seçeneği eklemek için yoğun bir şekilde çalışıyoruz. Desteğiniz için teşekkür ederiz.

Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive

Creating a Load Balancer

Function

This API is used to create a dedicated load balancer.

When you create a load balancer, note the following:

  • Specify vip_subnet_cidr_id if you want to bind a private IPv4 address to the load balancer.

  • Specify publicip and either vpc_id or vip_subnet_cidr_id if you want to bind a new IPv4 EIP to the load balancer.

  • Specify publicip_ids and either vpc_id or vip_subnet_cidr_id if you want to bind an existing IPv4 EIP to the load balancer.

  • Specify ipv6_vip_virsubnet_id if you want to bind a private IPv6 address to the load balancer.

  • Specify both ipv6_vip_virsubnet_id and ipv6_bandwidth if you want to bind a public IPv6 address to the load balancer.

  • Specify l4_flavor_id if you want to create a network load balancer and l7_flavor_id to create an application load balancer. Specify both l4_flavor_id and l7_flavor_id if you want to create a load balancer that can work at both Layer 4 and Layer 7.

  • If prepaid_options is not specified, pay-per-use load balancers will be created, which are billed by fixed specifications or elastic specifications you have selected for l4_flavor_id and l7_flavor_id when creating the load balancer.

Constraints

There are some constraints when you create a dedicated load balancer:

  • vpc_id, vip_subnet_cidr_id, and ipv6_vip_virsubnet_id cannot be left blank at the same time.

  • ip_target_enable specifies whether to enable IP as a Backend. If you enable this function for a dedicated load balancer, you can associate servers in a VPC connected through a VPC peering connection, in a VPC connected through a cloud connection, or in an on-premises data center at the other end of a Direct Connect or VPN connection, by using server IP addresses.

  • admin_state_up must be set to true.

  • provider must be set to vlb.

  • elb_virsubnet_ids indicates the subnets that support IPv4/IPv6 dual stack or only IPv4 subnets. If only IPv4 subnets are supported, ipv6_vip_virsubnet_id must be left blank.

  • If you bind an EIP to the load balancer during creation, you cannot unbind it from the load balancer by calling the API after the load balancer is created. Instead, you can unbind the EIP only on the ELB console. Locate the dedicated load balancer in the load balancer list and click More > Unbind EIP in the Operation column.

  • publicip_ids and publicip cannot be specified at the same time. Set either publicip_ids to bind an existing EIP to the load balancer, or publicip to bind a new EIP to the load balancer, or neither of them.

  • If you want to add the load balancer to a shared bandwidth, you must specify the ID of the shared bandwidth. If you want the load balancer to use a new dedicated bandwidth, charge_mode, share_type, and size are required.

Calling Method

For details, see Calling APIs.

URI

POST /v3/{project_id}/elb/loadbalancers

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Specifies the project ID of the load balancer.

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

No

String

Specifies the token used for IAM authentication.

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

loadbalancer

Yes

CreateLoadBalancerOption object

Parameters for creating a load balancer.

Table 4 CreateLoadBalancerOption

Parameter

Mandatory

Type

Description

project_id

No

String

Specifies the project ID.

name

No

String

Specifies the load balancer name.

Note: The value can be left blank and can contain up to Unicode 255 characters, including letters and more.

description

No

String

Provides supplementary information about the load balancer.

Note: The value can be left blank and can contain up to Unicode 255 characters, including letters and more.

vip_address

No

String

Specifies the private IPv4 address bound to the load balancer. The IP address must be from the IPv4 subnet where the load balancer resides and should not be occupied.

Note:

  • vip_subnet_cidr_id is required if vip_address is passed.

  • If only vip_subnet_cidr_id is passed, the system will automatically assign a private IPv4 address to the load balancer.

  • If neither vip_address nor vip_subnet_cidr_id is specified, no private IPv4 address will be assigned, and the value of vip_address will be null.

The IP address must be in [0-255].[0-255].[0-255].[0-255] format, for example, 192.168.1.1.

vip_subnet_cidr_id

No

String

Specifies the ID of the frontend IPv4 subnet where the load balancer resides.

You can query parameter neutron_subnet_id in the response by calling the API (GET https://{VPC_Endpoint}/v1/{project_id}/subnets).

Note:

  • This parameter is mandatory if you need to create a load balancer with a private IPv4 address.

  • vpc_id, vip_subnet_cidr_id, and ipv6_vip_virsubnet_id cannot be left blank at the same time. The subnet specified by vip_subnet_cidr_id and that specified by ipv6_vip_virsubnet_id must be in the VPC specified by vpc_id.

  • The subnet specified by vip_subnet_cidr_id must be in the VPC specified by vpc_id if both vpc_id and vip_subnet_cidr_id are passed.

The ID must be in UUID format and can contain up to 36 characters.

ipv6_vip_virsubnet_id

No

String

Specifies the ID of the frontend IPv6 subnet where the load balancer resides.

You can query parameter neutron_network_id in the response by calling the API (GET https://{VPC_Endpoint}/v1/{project_id}/subnets).

Note:

  • This parameter is mandatory if you need to create a load balancer with a private IPv6 address.

  • vpc_id, vip_subnet_cidr_id, and ipv6_vip_virsubnet_id cannot be left blank at the same time. The subnet specified by vip_subnet_cidr_id and that specified by ipv6_vip_virsubnet_id must be in the VPC specified by vpc_id.

  • IPv6 must have been enabled for the IPv6 subnet where the load balancer resides.

The ID must be in UUID format and can contain up to 36 characters.

provider

No

String

Specifies the provider of the load balancer. The value can only be vlb.

l4_flavor_id

No

String

Specifies the flavor ID of a network load balancer.

You can query parameter id in the response by calling the API (GET https://{ELB_Endpoint}/v3/{project_id}/elb/flavors?type=L4).

Note:

  • If neither l4_flavor_id nor l7_flavor_id is specified, the default flavor is used. The default flavor varies depending on the sites.

  • If l4_flavor_idis specified, the load balancer is billed by fixed flavor.

  • If L4_elastic_max is specified, the load balancer is billed by how many LCUs you use.

The ID must be in UUID format and can contain up to 36 characters.

l7_flavor_id

No

String

Specifies the flavor ID of the application load balancer.

Note:

  • You can query parameter id in the response by calling the API (GET https://{ELB_Endpoint}/v3/{project_id}/elb/flavors?type=L7).

  • If neither l4_flavor_id nor l7_flavor_id is specified, the default flavor is used.

    The default flavor varies by site.

  • If the flavor type is L7, the load balancer uses the fixed flavor and will be billed by the specification you select.

  • If the flavor type is L7_elastic_max, the load balancer uses the elastic flavor and will be billed by how many LCUs you use.

  • This parameter cannot be specified when shared load balancers are created in batches.

The ID must be in UUID format and can contain up to 36 characters.

guaranteed

No

Boolean

Specifies whether the load balancer is a dedicated load balancer.

Value options:

  • true (default): The load balancer is a dedicated load balancer.

  • false: The load balancer is a shared load balancer.

Currently, the value can only be true. If the value is set to false, 400 Bad Request will be returned.

vpc_id

No

String

Specifies the ID of the VPC where the load balancer resides.

You can query parameter id in the response by calling the API (GET https://{VPC_Endpoint}/v1/{project_id}/vpcs).

Note: vpc_id, vip_subnet_cidr_id, and ipv6_vip_virsubnet_id cannot be left blank at the same time. The subnet specified by vip_subnet_cidr_id and the subnet specified by ipv6_vip_virsubnet_id must be in the VPC specified by vpc_id.

The ID must be in UUID format and can contain up to 36 characters.

availability_zone_list

Yes

Array of strings

Specifies the list of AZs where the load balancer can be created.

You can query the AZs by calling the API (GET https://{ELB_Endpoint}/v3/{project_id}/elb/availability-zones). Select one or more AZs in the same set.

NOTE:

If disaster recovery is required, you are advised to select multiple AZs.

enterprise_project_id

No

String

Specifies the ID of the enterprise project that the load balancer belongs to. The value cannot be "", "0", or the ID of an enterprise project that does not exist. If this parameter is not passed during resource creation, the resource belongs to the default enterprise project, and 0 will be returned.

tags

No

Array of Tag objects

Lists the tags added to the load balancer.

Example: "tags":[{"key":"my_tag","value":"my_tag_value"}]

admin_state_up

No

Boolean

Specifies whether the load balancer is enabled.

Value options:

  • true: indicates the load balancer is enabled.

  • false: indicates the load balancer is disabled.

    Default value: true

billing_info

No

String

Provides resource billing information.

Note:

  • If the value is left blank, the resource is billed in pay-per-use mode.

This parameter is unsupported. Please do not use it.

ipv6_bandwidth

No

BandwidthRef object

Specifies the ID of the bandwidth used by an IPv6 address.

Note: This parameter is available only when you create or update a load balancer with a public IPv6 address. If you use a new IPv6 address and specify a shared bandwidth, the IPv6 address will be added to the shared bandwidth.

publicip_ids

No

Array of strings

Specifies the IDs of the EIP the system will automatically assign and bind to the load balancer during load balancer creation.

Note:

  • Only the first EIP will be bound to the load balancer although multiple EIP IDs can be set.

publicip

No

CreateLoadBalancerPublicIpOption object

Specifies the new EIP that will be bound to the load balancer.

elb_virsubnet_ids

No

Array of strings

Specifies the IDs of subnets where the load balancers work.

You can query parameter neutron_network_id in the response by calling the API (GET https://{VPC_Endpoint}/v1/{project_id}/subnets?vpc_id=xxxx).

A load balancer uses IP addresses in such subnets to communicate with backend servers (such as in health check, and FullNAT scenarios).

Note:

  • The backend subnet must in the VPC where the load balancer works.

  • You need to specify a backend subnet for the load balancer and add rules to the security group associated with the backend server to allow access from the backend subnet.

  • If there is more than one subnet, the first subnet in the list will be used.

  • If this parameter is not specified, select subnets as follows:

    • If IPv6 is enabled for a load balancer, the ID of subnet specified in ipv6_vip_virsubnet_id will be used.

    • If IPv4 is enabled for a load balancer, the ID of subnet specified in vip_subnet_cidr_id will be used.

    • If only public network is available for a load balancer, the ID of any subnet in the VPC where the load balancer resides will be used. Subnets with more IP addresses are preferred.

  • You are advised to use a dedicated subnet with sufficient IP addresses for easier O&M.

  • A load balancer uses IP addresses in the backend subnet to communicate with backend servers (such as in health check, and FullNAT scenarios). To prevent traffic from being blocked by the security groups associated with backend servers, add security group rules to allow access from the backend subnet of the load balancer to backend servers.

  • In the elastic scaling scenario, the reserved IP addresses may change. It is recommended that you should add security group rules to allow access from the backend subnet of the load balancer instead of certain IP addresses.

ip_target_enable

No

Boolean

Specifies whether to add backend servers that are not in the load balancer's VPC.

If you enable this function, you can add servers in a peer VPC connected through a VPC peering connection, servers in other public clouds, or servers in an on-premises data center at the other end of a Direct Connect or VPN connection, by using their IP addresses.

Value options:

  • true: Enable IP as a Backend.

  • false: Disable IP as a Backend.

Note:

  • The value can only be updated to true.

  • If you need to connect your server to a shared VPC, ensure the VPC principal has created a VPC peering connections between the two VPCs.

  • This function is supported only by dedicated load balancers.

deletion_protection_enable

No

Boolean

Specifies whether to enable deletion protection for the load balancer.

Value options:

  • true: Enable deletion protection.

  • false (default): Disable deletion protection.

NOTE:

Disable deletion protection for all your resources before deleting your account.

prepaid_options

No

PrepaidCreateOption object

Shows the yearly/monthly billing information. If this parameter is passed, a yearly/monthly load balancer will be created.

This parameter is unsupported. Please do not use it.

autoscaling

No

CreateLoadbalancerAutoscalingOption object

Specifies information about elastic scaling. If elastic scaling is enabled, the load balancer specifications can be automatically adjusted based on incoming traffic.

Note:

  • This parameter is only available for users on the whitelist.

  • If elastic scaling is enabled, l4_flavor_id indicates the ID of the maximum elastic flavor at Layer 4. l7_flavor_id indicates the ID of the maximum elastic flavor at Layer 7.

  • This parameter has been deprecated, but is retained for compatibility purposes. Using this parameter is not recommended. If this parameter is specified, the load balancer with minimum specifications will be created and you will be billed for the minimum specifications.

waf_failure_action

No

String

Specifies traffic distributing policies when the WAF is faulty.

Value options:

  • discard: Traffic will not be distributed.

  • forward (default): Traffic will be distributed to the default backend servers.

Note: This parameter takes effect only when WAF is enabled for the load balancer.

protection_status

No

String

Specifies the protection status. This parameter is used to prevent resources from being modified by accident on the console. If this parameter is set to consoleProtection, you cannot modify resource settings on the console, but you can call APIs to modify resource settings, such as resource tags.

Value options:

  • nonProtection (default): The load balancer is not protected.

  • consoleProtection: Modification Protection is enabled on the console.

protection_reason

No

String

Specifies why the modification protection is enabled.

Note: This parameter is valid only when protection_status is set to consoleProtection. The value can contain a maximum of 255 Unicode characters, excluding angle brackets (<>).

charge_mode

No

String

Specifies the charge mode when creating a load balancer.

Value options:

  • flavor: billed by the fixed specification you select.

  • lcu: billed by how many LCUs you have used.

Constraints:

You are not recommended to specify this parameter. The charge mode will be selected based on the value you have specified for l4_flavor_id or l7_flavor_id.

Note:

  • If this parameter is not specified during the creation of a shared load balancer, flavor is selected by default.

  • If you create a dedicated load balancer, this parameter is ignored. The charge mode will be selected based on the value you have specified for l4_flavor_id or l7_flavor_id.

ipv6_vip_address

No

String

Specifies the IPv6 address bound to the load balancer.

Note:

  • The IPv6 address must be one in the subnet defined by ipv6_vip_virsubnet_id.

  • Subnets defined by elb_virsubnet_ids must support IPv4/IPv6 dual stack.

Table 5 Tag

Parameter

Mandatory

Type

Description

key

No

String

Specifies the tag key.

value

No

String

Specifies the tag value.

Table 6 BandwidthRef

Parameter

Mandatory

Type

Description

id

Yes

String

Specifies the shared bandwidth ID.

Table 7 CreateLoadBalancerPublicIpOption

Parameter

Mandatory

Type

Description

ip_version

No

Integer

Specifies the IP address version. The value can be 4 (IPv4) or 6 (IPv6).

The default value is 4.

network_type

Yes

String

Specifies the EIP type. The default value is 5_bgp. For more information, see the API for assigning an EIP in the Virtual Private Cloud API Reference.

billing_info

No

String

Provides billing information about the EIP.

  • If the value is left blank, the EIP is billed in pay-per-use mode.

This parameter is unsupported. Please do not use it.

description

No

String

Provides supplementary information about the EIP.

bandwidth

Yes

CreateLoadBalancerBandwidthOption object

Provides supplementary information about the bandwidth.

Table 8 CreateLoadBalancerBandwidthOption

Parameter

Mandatory

Type

Description

name

No

String

Specifies the bandwidth name.

The value can contain 1 to 64 characters, including letters, digits, underscores (_), hyphens (-), and periods.

Note:

  • This parameter is mandatory if share_type is set to PER.

  • This parameter will be ignored if the bandwidth reference has a specific ID.

size

No

Integer

Specifies the bandwidth range.

The default bandwidth range is 1 Mbit/s to 2,000 Mbit/s, which may vary by region and can be viewed on the management console.

Note:

  • This parameter is mandatory if id is set to null.

  • The minimum increment for bandwidth adjustment varies by bandwidth range. The following are the details:

    • The minimum increment is 1 Mbit/s if the bandwidth range is from 0 Mbit/s to 300 Mbit/s.

    • The minimum increment is 50 Mbit/s if the bandwidth range is from 301 Mbit/s to 1,000 Mbit/s.

    • The minimum increment is 500 Mbit/s if the bandwidth is greater than 1,000 Mbit/s.

charge_mode

No

String

Specifies how the bandwidth used by the EIP is billed.

  • traffic: The bandwidth will be billed by traffic.

  • bandwidth: The bandwidth will be billed by fixed bandwidth.

This parameter is mandatory if id is set to null.

share_type

No

String

Specifies the bandwidth type.

Value options:

  • PER: indicates dedicated bandwidths.

  • WHOLE: indicates shared bandwidths.

Note:

  • This parameter is mandatory when id is set to null. It will be ignored if the value of id is not null.

  • The bandwidth ID must be specified if the bandwidth type is set to WHOLE.

  • The bandwidth type cannot be WHOLE for IPv6 EIPs.

billing_info

No

String

Specifies bandwidth billing information.

Note:

This parameter is unsupported. Please do not use it.

id

No

String

Specifies the ID of the shared bandwidth to which the IP address bound to the load balancer is added.

Note:

  • The value is the bandwidth ID when share_type is set to WHOLE.

Table 9 PrepaidCreateOption

Parameter

Mandatory

Type

Description

period_type

Yes

String

Specifies the subscription period.

  • month: monthly subscription

  • year: yearly subscription

period_num

No

Integer

Specifies the number of subscription periods.

Value ranges:

  • If period_type is set to month, the value ranges from 1 to 9.

  • If period_type is set to year, the value ranges from 1 to 3.

auto_renew

No

Boolean

Specifies whether to automatically renew the subscription.

  • true: Enable automatic renewal.

  • False (default): Disable automatic renewal.

auto_pay

No

Boolean

Specifies whether the payment will be automatically deducted from the customer's account after an order is placed.

  • true: The payment will be automatically deducted from the customer's account.

  • false (default): The payment will not be automatically deducted from the customer's account.

If you want to use coupons, submit your request. The system automatically will switch to the billing center, where you can use the coupons.

Table 10 CreateLoadbalancerAutoscalingOption

Parameter

Mandatory

Type

Description

enable

Yes

Boolean

Specifies whether to enable elastic scaling for the load balancer.

The value can be true (elastic scaling enabled) or false (elastic scaling disabled).

min_l7_flavor_id

No

String

Specifies the ID of the minimum elastic flavor at Layer 7. This parameter cannot be left blank if there are HTTP or HTTPS listeners.

Response Parameters

Status code: 201

Table 11 Response body parameters

Parameter

Type

Description

loadbalancer

LoadBalancer object

Specifies the load balancer.

request_id

String

Specifies the request ID.

Note: The value is automatically generated.

Table 12 LoadBalancer

Parameter

Type

Description

id

String

Specifies the load balancer ID.

description

String

Provides supplementary information about the load balancer.

provisioning_status

String

Specifies the provisioning status of the load balancer.

Value options:

  • ACTIVE: The load balancer is successfully provisioned.

  • PENDING_DELETE: The load balancer is being deleted.

admin_state_up

Boolean

Specifies whether the load balancer is enabled.

Value options:

  • true: indicates the load balancer is enabled.

  • false: indicates the load balancer is disabled.

provider

String

Specifies the provider of the load balancer. The value can only be vlb.

pools

Array of PoolRef objects

Lists the IDs of backend server groups associated with the load balancer.

listeners

Array of ListenerRef objects

Lists the IDs of listeners added to the load balancer.

operating_status

String

Specifies the operating status of the load balancer.

Value options:

  • ONLINE: indicates that the load balancer is running normally.

  • FROZEN: indicates that the load balancer is frozen.

name

String

Specifies the load balancer name.

project_id

String

Specifies the project ID of the load balancer.

vip_subnet_cidr_id

String

Specifies the ID of the frontend IPv4 subnet where the load balancer resides.

vip_address

String

Specifies the private IPv4 address bound to the load balancer.

vip_port_id

String

Specifies the ID of the port bound to the private IPv4 address of the load balancer.

tags

Array of Tag objects

Lists the tags added to the load balancer.

created_at

String

Specifies the time when the load balancer was created, in the format of yyyy-MM-dd''T''HH:mm:ss''Z''.

updated_at

String

Specifies the time when the load balancer was updated, in the format of yyyy-MM-dd''T''HH:mm:ss''Z''.

guaranteed

Boolean

Specifies whether the load balancer is a dedicated load balancer.

Value options:

  • true (default): The load balancer is a dedicated load balancer.

  • false: The load balancer is a shared load balancer.

vpc_id

String

Specifies the ID of the VPC where the load balancer resides.

eips

Array of EipInfo objects

Specifies the EIP bound to the load balancer. Only one EIP can be bound to a load balancer.

This parameter has the same meaning as publicips.

ipv6_vip_address

String

Specifies the IPv6 address bound to the load balancer.

ipv6_vip_virsubnet_id

String

Specifies the ID of the IPv6 subnet where the load balancer resides.

ipv6_vip_port_id

String

Specifies the ID of the port bound to the IPv6 address of the load balancer.

availability_zone_list

Array of strings

Specifies the list of AZs where the load balancer is created.

enterprise_project_id

String

Specifies the enterprise project ID.

If this parameter is not passed during resource creation, "0" will be returned, and the resource belongs to the default enterprise project.

Note: "0" is not a valid enterprise project ID and cannot be used in the APIs for creating, updating the load balancer, or querying the details of the load balancer.

billing_info

String

Provides resource billing information.

  • If the value is left blank, the resource is billed in pay-per-use mode.

This parameter is unsupported. Please do not use it.

l4_flavor_id

String

Specifies the ID of a flavor at Layer 4.

l4_flavor_id defines the maximum elastic flavor at Layer 4.

Note:

  • If l4_flavor_id is specified, the load balancer is billed by fixed specifications.

  • If L4_elastic_max is specified, the load balancer is billed by how many LCUs you use.

l4_scale_flavor_id

String

Specifies the ID of the reserved flavor at Layer 4.

This parameter is unsupported. Please do not use it.

l7_flavor_id

String

Specifies the ID of a flavor at Layer 7.

l7_flavor_id defines the maximum elastic flavor at Layer 7.

Note:

  • If l7_flavor_id is specified, the load balancer is billed by fixed specifications.

  • If L7_elastic_max is specified, the load balancer is billed by how many LCUs you use.

l7_scale_flavor_id

String

Specifies the ID of the reserved flavor at Layer 7.

This parameter is unsupported. Please do not use it.

publicips

Array of PublicIpInfo objects

Specifies the EIP bound to the load balancer. Only one EIP can be bound to a load balancer.

This parameter has the same meaning as eips.

global_eips

Array of GlobalEipInfo objects

Specifies the global EIP bound to the load balancer.

Only the first global EIP specified under global_eips will be bound.

elb_virsubnet_ids

Array of strings

Lists the IDs of subnets on the downstream plane.

elb_virsubnet_type

String

Specifies the type of the subnet on the downstream plane.

Value options:

  • ipv4: IPv4 subnet

  • dualstack: subnet that supports IPv4/IPv6 dual stack

ip_target_enable

Boolean

Specifies whether to add backend servers that are not in the load balancer's VPC.

If you enable this function, you can add servers in a peer VPC connected through a VPC peering connection, servers in other public clouds, or servers in an on-premises data center at the other end of a Direct Connect or VPN connection, by using their IP addresses.

Value options:

  • true: Enable IP as a Backend.

  • false: Disable IP as a Backend.

Note:

  • The value can only be updated to true.

  • If you need to connect your server to a shared VPC, ensure the VPC principal has created a VPC peering connections between the two VPCs.

  • This function is supported only by dedicated load balancers.

frozen_scene

String

Specifies the scenario where the load balancer is frozen.

Multiple values are separated using commas (,).

Value options:

  • POLICE: The load balancer is frozen due to security reasons.

  • ILLEGAL: The load balancer is frozen due to violation of laws and regulations.

  • VERIFY: Your account has not completed real-name authentication.

  • PARTNER: The load balancer is frozen by the partner.

  • ARREAR: Your account is in arrears.

ipv6_bandwidth

BandwidthRef object

Specifies the ID of the bandwidth used by an IPv6 address.

Note: This parameter is available only when you create or update a load balancer with a public IPv6 address. If you use a new IPv6 address and specify a shared bandwidth, the IPv6 address will be added to the shared bandwidth.

deletion_protection_enable

Boolean

Specifies whether to enable deletion protection.

Value options:

  • true: Enable deletion protection.

  • false: Disable deletion protection.

Note:

  • Disable deletion protection for all your resources before deleting your account.

  • This parameter is returned only when deletion protection is enabled at the site.

autoscaling

AutoscalingRef object

Specifies information about elastic scaling. If elastic scaling is enabled, the load balancer specifications can be automatically adjusted based on incoming traffic.

Note:

  • This parameter is only available for users on the whitelist.

  • If elastic scaling is enabled, l4_flavor_id indicates the ID of the maximum elastic flavor at Layer 4. l7_flavor_id indicates the ID of the maximum elastic flavor at Layer 7.

  • This parameter has been deprecated, but is retained for compatibility purposes. Using this parameter is not recommended. If this parameter is specified, the load balancer with minimum specifications will be created and you will be billed for the minimum specifications.

public_border_group

String

Specifies the AZ group to which the load balancer belongs.

charge_mode

String

Specifies the charge mode when creating a load balancer.

Value options:

  • flavor: billed by the fixed specification you select.

  • lcu: billed by how many LCUs you have used.

  • If this parameter is left blank:

    • If it is a shared load balancer, it is free.

    • If it is a dedicated load balancer, it will be billed by the fixed specification you select.

waf_failure_action

String

Specifies traffic distributing policies when the WAF is faulty.

Value options:

  • discard: Traffic will not be distributed.

  • forward (default): Traffic will be distributed to the default backend servers.

Note: This parameter takes effect only when WAF is enabled for the load balancer.

protection_status

String

Specifies the protection status.

Value options:

  • nonProtection (default): The load balancer is not protected.

  • consoleProtection: Modification Protection is enabled on the console.

protection_reason

String

Specifies why the modification protection is enabled.

Note: This parameter is valid only when protection_status is set to consoleProtection. The value can contain a maximum of 255 Unicode characters, excluding angle brackets (<>).

log_group_id

String

Specifies the ID of the log group that is associated with the load balancer.

log_topic_id

String

Specifies the ID of the log topic that is associated with the load balancer.

Table 13 PoolRef

Parameter

Type

Description

id

String

Specifies the ID of the backend server group.

Table 14 ListenerRef

Parameter

Type

Description

id

String

Specifies the listener ID.

Table 15 Tag

Parameter

Type

Description

key

String

Specifies the tag key.

value

String

Specifies the tag value.

Table 16 EipInfo

Parameter

Type

Description

eip_id

String

Specifies the EIP ID.

eip_address

String

Specifies the EIP.

ip_version

Integer

Specifies the IP version. 4 indicates IPv4, and 6 indicates IPv6.

Table 17 PublicIpInfo

Parameter

Type

Description

publicip_id

String

Specifies the EIP ID.

publicip_address

String

Specifies the IP address.

ip_version

Integer

Specifies the IP version. The value can be 4 (IPv4) or 6 (IPv6).

Table 18 GlobalEipInfo

Parameter

Type

Description

global_eip_id

String

Specifies the ID of the global EIP.

global_eip_address

String

Specifies the global EIP.

ip_version

Integer

Specifies the IP version.

The value can be 4 and 6. 4 indicates an IPv4 address, and 6 indicates an IPv6 address.

Table 19 BandwidthRef

Parameter

Type

Description

id

String

Specifies the shared bandwidth ID.

Table 20 AutoscalingRef

Parameter

Type

Description

enable

Boolean

Specifies whether to enable elastic scaling for the load balancer.

Value options:

  • true: Enable elastic scaling.

  • false (default): Disable elastic scaling.

min_l7_flavor_id

String

Specifies the ID of the minimum elastic flavor at Layer 7.

Note:

  • This parameter cannot be left blank if there are HTTP or HTTPS listeners.

  • This parameter has been deprecated, but is retained for compatibility purposes. Using this parameter is not recommended. If this parameter is specified, the load balancer with minimum specifications will be created and you will be billed for the minimum specifications.

Example Requests

  • Example 1: Creating a load balancer with a private IPv4 address

    POST https://{ELB_Endpoint}/v3/060576798a80d5762fafc01a9b5eedc7/elb/loadbalancers
    
    {
      "loadbalancer" : {
        "name" : "loadbalancer",
        "description" : "simple lb",
        "vip_subnet_cidr_id" : "1992ec06-f364-4ae3-b936-6a8cc24633b7",
        "admin_state_up" : true,
        "availability_zone_list" : [ "AZ1" ]
      }
    }
  • Example 2: Creating a load balancer with an IPv4 EIP

    POST https://{ELB_Endpoint}/v3/060576782980d5762f9ec014dd2f1148/elb/loadbalancers
    
    {
      "loadbalancer" : {
        "vip_subnet_cidr_id" : "e6e9271d-aef4-48f0-a93a-ccc7b09032c1",
        "availability_zone_list" : [ "AZ1" ],
        "admin_state_up" : true,
        "publicip" : {
          "network_type" : "5_bgp",
          "bandwidth" : {
            "size" : 2,
            "share_type" : "PER",
            "charge_mode" : "bandwidth",
            "name" : "bandwidth_test"
          }
        },
        "name" : "elb_eip-test"
      }
    }

Example Responses

Status code: 201

Normal response to POST requests.

{
  "loadbalancer" : {
    "name" : "my_loadbalancer",
    "id" : "29cc669b-3ac8-4498-9094-bdf6193425c2",
    "project_id" : "060576798a80d5762fafc01a9b5eedc7",
    "description" : "",
    "vip_port_id" : "98697944-0cc7-4d3b-a829-001c2fb82232",
    "vip_address" : "192.168.0.214",
    "admin_state_up" : true,
    "provisioning_status" : "ACTIVE",
    "operating_status" : "ONLINE",
    "listeners" : [ ],
    "pools" : [ ],
    "tags" : [ {
      "key" : "tab_key",
      "value" : "tag1"
    } ],
    "provider" : "vlb",
    "created_at" : "2023-03-22T07:59:57Z",
    "updated_at" : "2023-03-22T07:59:59Z",
    "vpc_id" : "a1f33a4c-95b9-48a7-9350-684e2ed844b3",
    "enterprise_project_id" : "134f2181-5720-47e7-bd78-1356ed3737d6",
    "availability_zone_list" : [ ],
    "ipv6_vip_address" : null,
    "ipv6_vip_virsubnet_id" : null,
    "ipv6_vip_port_id" : null,
    "publicips" : [ {
      "publicip_id" : "3388574a-4f6f-4471-869e-97d74d21eee9",
      "publicip_address" : "88.88.87.205",
      "ip_version" : 4
    } ],
    "global_eips" : [ ],
    "elb_virsubnet_ids" : [ ],
    "elb_virsubnet_type" : null,
    "ip_target_enable" : false,
    "autoscaling" : {
      "enable" : false,
      "min_l7_flavor_id" : ""
    },
    "frozen_scene" : null,
    "public_border_group" : "center",
    "eips" : [ {
      "eip_id" : "3388574a-4f6f-4471-869e-97d74d21eee9",
      "eip_address" : "88.88.87.205",
      "ip_version" : 4
    } ],
    "guaranteed" : false,
    "billing_info" : null,
    "l4_flavor_id" : null,
    "l4_scale_flavor_id" : null,
    "l7_flavor_id" : null,
    "l7_scale_flavor_id" : null,
    "waf_failure_action" : "",
    "vip_subnet_cidr_id" : "abf31f3b-706e-4e55-a6dc-f2fcc707fd3a"
  },
  "request_id" : "bf29597181cb81b30d19f1a0115a157d"
}

SDK Sample Code

The SDK sample code is as follows.

  • Example 1: Creating a load balancer with a private IPv4 address

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    package com.huaweicloud.sdk.test;
    
    import com.huaweicloud.sdk.core.auth.ICredential;
    import com.huaweicloud.sdk.core.auth.BasicCredentials;
    import com.huaweicloud.sdk.core.exception.ConnectionException;
    import com.huaweicloud.sdk.core.exception.RequestTimeoutException;
    import com.huaweicloud.sdk.core.exception.ServiceResponseException;
    import com.huaweicloud.sdk.elb.v3.region.ElbRegion;
    import com.huaweicloud.sdk.elb.v3.*;
    import com.huaweicloud.sdk.elb.v3.model.*;
    
    import java.util.List;
    import java.util.ArrayList;
    
    public class CreateLoadBalancerSolution {
    
        public static void main(String[] args) {
            // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
            // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
            String ak = System.getenv("CLOUD_SDK_AK");
            String sk = System.getenv("CLOUD_SDK_SK");
            String projectId = "{project_id}";
    
            ICredential auth = new BasicCredentials()
                    .withProjectId(projectId)
                    .withAk(ak)
                    .withSk(sk);
    
            ElbClient client = ElbClient.newBuilder()
                    .withCredential(auth)
                    .withRegion(ElbRegion.valueOf("<YOUR REGION>"))
                    .build();
            CreateLoadBalancerRequest request = new CreateLoadBalancerRequest();
            CreateLoadBalancerRequestBody body = new CreateLoadBalancerRequestBody();
            List<String> listLoadbalancerAvailabilityZoneList = new ArrayList<>();
            listLoadbalancerAvailabilityZoneList.add("AZ1");
            CreateLoadBalancerOption loadbalancerbody = new CreateLoadBalancerOption();
            loadbalancerbody.withName("loadbalancer")
                .withDescription("simple lb")
                .withVipSubnetCidrId("1992ec06-f364-4ae3-b936-6a8cc24633b7")
                .withAvailabilityZoneList(listLoadbalancerAvailabilityZoneList)
                .withAdminStateUp(true);
            body.withLoadbalancer(loadbalancerbody);
            request.withBody(body);
            try {
                CreateLoadBalancerResponse response = client.createLoadBalancer(request);
                System.out.println(response.toString());
            } catch (ConnectionException e) {
                e.printStackTrace();
            } catch (RequestTimeoutException e) {
                e.printStackTrace();
            } catch (ServiceResponseException e) {
                e.printStackTrace();
                System.out.println(e.getHttpStatusCode());
                System.out.println(e.getRequestId());
                System.out.println(e.getErrorCode());
                System.out.println(e.getErrorMsg());
            }
        }
    }
    
  • Example 2: Creating a load balancer with an IPv4 EIP

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    package com.huaweicloud.sdk.test;
    
    import com.huaweicloud.sdk.core.auth.ICredential;
    import com.huaweicloud.sdk.core.auth.BasicCredentials;
    import com.huaweicloud.sdk.core.exception.ConnectionException;
    import com.huaweicloud.sdk.core.exception.RequestTimeoutException;
    import com.huaweicloud.sdk.core.exception.ServiceResponseException;
    import com.huaweicloud.sdk.elb.v3.region.ElbRegion;
    import com.huaweicloud.sdk.elb.v3.*;
    import com.huaweicloud.sdk.elb.v3.model.*;
    
    import java.util.List;
    import java.util.ArrayList;
    
    public class CreateLoadBalancerSolution {
    
        public static void main(String[] args) {
            // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
            // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
            String ak = System.getenv("CLOUD_SDK_AK");
            String sk = System.getenv("CLOUD_SDK_SK");
            String projectId = "{project_id}";
    
            ICredential auth = new BasicCredentials()
                    .withProjectId(projectId)
                    .withAk(ak)
                    .withSk(sk);
    
            ElbClient client = ElbClient.newBuilder()
                    .withCredential(auth)
                    .withRegion(ElbRegion.valueOf("<YOUR REGION>"))
                    .build();
            CreateLoadBalancerRequest request = new CreateLoadBalancerRequest();
            CreateLoadBalancerRequestBody body = new CreateLoadBalancerRequestBody();
            CreateLoadBalancerBandwidthOption bandwidthPublicip = new CreateLoadBalancerBandwidthOption();
            bandwidthPublicip.withName("bandwidth_test")
                .withSize(2)
                .withChargeMode(CreateLoadBalancerBandwidthOption.ChargeModeEnum.fromValue("bandwidth"))
                .withShareType(CreateLoadBalancerBandwidthOption.ShareTypeEnum.fromValue("PER"));
            CreateLoadBalancerPublicIpOption publicipLoadbalancer = new CreateLoadBalancerPublicIpOption();
            publicipLoadbalancer.withNetworkType("5_bgp")
                .withBandwidth(bandwidthPublicip);
            List<String> listLoadbalancerAvailabilityZoneList = new ArrayList<>();
            listLoadbalancerAvailabilityZoneList.add("AZ1");
            CreateLoadBalancerOption loadbalancerbody = new CreateLoadBalancerOption();
            loadbalancerbody.withName("elb_eip-test")
                .withVipSubnetCidrId("e6e9271d-aef4-48f0-a93a-ccc7b09032c1")
                .withAvailabilityZoneList(listLoadbalancerAvailabilityZoneList)
                .withAdminStateUp(true)
                .withPublicip(publicipLoadbalancer);
            body.withLoadbalancer(loadbalancerbody);
            request.withBody(body);
            try {
                CreateLoadBalancerResponse response = client.createLoadBalancer(request);
                System.out.println(response.toString());
            } catch (ConnectionException e) {
                e.printStackTrace();
            } catch (RequestTimeoutException e) {
                e.printStackTrace();
            } catch (ServiceResponseException e) {
                e.printStackTrace();
                System.out.println(e.getHttpStatusCode());
                System.out.println(e.getRequestId());
                System.out.println(e.getErrorCode());
                System.out.println(e.getErrorMsg());
            }
        }
    }
    
  • Example 1: Creating a load balancer with a private IPv4 address

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    # coding: utf-8
    
    import os
    from huaweicloudsdkcore.auth.credentials import BasicCredentials
    from huaweicloudsdkelb.v3.region.elb_region import ElbRegion
    from huaweicloudsdkcore.exceptions import exceptions
    from huaweicloudsdkelb.v3 import *
    
    if __name__ == "__main__":
        # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
        # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
        ak = os.environ["CLOUD_SDK_AK"]
        sk = os.environ["CLOUD_SDK_SK"]
        projectId = "{project_id}"
    
        credentials = BasicCredentials(ak, sk, projectId)
    
        client = ElbClient.new_builder() \
            .with_credentials(credentials) \
            .with_region(ElbRegion.value_of("<YOUR REGION>")) \
            .build()
    
        try:
            request = CreateLoadBalancerRequest()
            listAvailabilityZoneListLoadbalancer = [
                "AZ1"
            ]
            loadbalancerbody = CreateLoadBalancerOption(
                name="loadbalancer",
                description="simple lb",
                vip_subnet_cidr_id="1992ec06-f364-4ae3-b936-6a8cc24633b7",
                availability_zone_list=listAvailabilityZoneListLoadbalancer,
                admin_state_up=True
            )
            request.body = CreateLoadBalancerRequestBody(
                loadbalancer=loadbalancerbody
            )
            response = client.create_load_balancer(request)
            print(response)
        except exceptions.ClientRequestException as e:
            print(e.status_code)
            print(e.request_id)
            print(e.error_code)
            print(e.error_msg)
    
  • Example 2: Creating a load balancer with an IPv4 EIP

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    # coding: utf-8
    
    import os
    from huaweicloudsdkcore.auth.credentials import BasicCredentials
    from huaweicloudsdkelb.v3.region.elb_region import ElbRegion
    from huaweicloudsdkcore.exceptions import exceptions
    from huaweicloudsdkelb.v3 import *
    
    if __name__ == "__main__":
        # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
        # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
        ak = os.environ["CLOUD_SDK_AK"]
        sk = os.environ["CLOUD_SDK_SK"]
        projectId = "{project_id}"
    
        credentials = BasicCredentials(ak, sk, projectId)
    
        client = ElbClient.new_builder() \
            .with_credentials(credentials) \
            .with_region(ElbRegion.value_of("<YOUR REGION>")) \
            .build()
    
        try:
            request = CreateLoadBalancerRequest()
            bandwidthPublicip = CreateLoadBalancerBandwidthOption(
                name="bandwidth_test",
                size=2,
                charge_mode="bandwidth",
                share_type="PER"
            )
            publicipLoadbalancer = CreateLoadBalancerPublicIpOption(
                network_type="5_bgp",
                bandwidth=bandwidthPublicip
            )
            listAvailabilityZoneListLoadbalancer = [
                "AZ1"
            ]
            loadbalancerbody = CreateLoadBalancerOption(
                name="elb_eip-test",
                vip_subnet_cidr_id="e6e9271d-aef4-48f0-a93a-ccc7b09032c1",
                availability_zone_list=listAvailabilityZoneListLoadbalancer,
                admin_state_up=True,
                publicip=publicipLoadbalancer
            )
            request.body = CreateLoadBalancerRequestBody(
                loadbalancer=loadbalancerbody
            )
            response = client.create_load_balancer(request)
            print(response)
        except exceptions.ClientRequestException as e:
            print(e.status_code)
            print(e.request_id)
            print(e.error_code)
            print(e.error_msg)
    
  • Example 1: Creating a load balancer with a private IPv4 address

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    package main
    
    import (
    	"fmt"
    	"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
        elb "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/elb/v3"
    	"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/elb/v3/model"
        region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/elb/v3/region"
    )
    
    func main() {
        // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
        // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
        ak := os.Getenv("CLOUD_SDK_AK")
        sk := os.Getenv("CLOUD_SDK_SK")
        projectId := "{project_id}"
    
        auth := basic.NewCredentialsBuilder().
            WithAk(ak).
            WithSk(sk).
            WithProjectId(projectId).
            Build()
    
        client := elb.NewElbClient(
            elb.ElbClientBuilder().
                WithRegion(region.ValueOf("<YOUR REGION>")).
                WithCredential(auth).
                Build())
    
        request := &model.CreateLoadBalancerRequest{}
    	var listAvailabilityZoneListLoadbalancer = []string{
            "AZ1",
        }
    	nameLoadbalancer:= "loadbalancer"
    	descriptionLoadbalancer:= "simple lb"
    	vipSubnetCidrIdLoadbalancer:= "1992ec06-f364-4ae3-b936-6a8cc24633b7"
    	adminStateUpLoadbalancer:= true
    	loadbalancerbody := &model.CreateLoadBalancerOption{
    		Name: &nameLoadbalancer,
    		Description: &descriptionLoadbalancer,
    		VipSubnetCidrId: &vipSubnetCidrIdLoadbalancer,
    		AvailabilityZoneList: listAvailabilityZoneListLoadbalancer,
    		AdminStateUp: &adminStateUpLoadbalancer,
    	}
    	request.Body = &model.CreateLoadBalancerRequestBody{
    		Loadbalancer: loadbalancerbody,
    	}
    	response, err := client.CreateLoadBalancer(request)
    	if err == nil {
            fmt.Printf("%+v\n", response)
        } else {
            fmt.Println(err)
        }
    }
    
  • Example 2: Creating a load balancer with an IPv4 EIP

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    package main
    
    import (
    	"fmt"
    	"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
        elb "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/elb/v3"
    	"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/elb/v3/model"
        region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/elb/v3/region"
    )
    
    func main() {
        // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
        // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
        ak := os.Getenv("CLOUD_SDK_AK")
        sk := os.Getenv("CLOUD_SDK_SK")
        projectId := "{project_id}"
    
        auth := basic.NewCredentialsBuilder().
            WithAk(ak).
            WithSk(sk).
            WithProjectId(projectId).
            Build()
    
        client := elb.NewElbClient(
            elb.ElbClientBuilder().
                WithRegion(region.ValueOf("<YOUR REGION>")).
                WithCredential(auth).
                Build())
    
        request := &model.CreateLoadBalancerRequest{}
    	nameBandwidth:= "bandwidth_test"
    	sizeBandwidth:= int32(2)
    	chargeModeBandwidth:= model.GetCreateLoadBalancerBandwidthOptionChargeModeEnum().BANDWIDTH
    	shareTypeBandwidth:= model.GetCreateLoadBalancerBandwidthOptionShareTypeEnum().PER
    	bandwidthPublicip := &model.CreateLoadBalancerBandwidthOption{
    		Name: &nameBandwidth,
    		Size: &sizeBandwidth,
    		ChargeMode: &chargeModeBandwidth,
    		ShareType: &shareTypeBandwidth,
    	}
    	publicipLoadbalancer := &model.CreateLoadBalancerPublicIpOption{
    		NetworkType: "5_bgp",
    		Bandwidth: bandwidthPublicip,
    	}
    	var listAvailabilityZoneListLoadbalancer = []string{
            "AZ1",
        }
    	nameLoadbalancer:= "elb_eip-test"
    	vipSubnetCidrIdLoadbalancer:= "e6e9271d-aef4-48f0-a93a-ccc7b09032c1"
    	adminStateUpLoadbalancer:= true
    	loadbalancerbody := &model.CreateLoadBalancerOption{
    		Name: &nameLoadbalancer,
    		VipSubnetCidrId: &vipSubnetCidrIdLoadbalancer,
    		AvailabilityZoneList: listAvailabilityZoneListLoadbalancer,
    		AdminStateUp: &adminStateUpLoadbalancer,
    		Publicip: publicipLoadbalancer,
    	}
    	request.Body = &model.CreateLoadBalancerRequestBody{
    		Loadbalancer: loadbalancerbody,
    	}
    	response, err := client.CreateLoadBalancer(request)
    	if err == nil {
            fmt.Printf("%+v\n", response)
        } else {
            fmt.Println(err)
        }
    }
    

For SDK sample code of more programming languages, see the Sample Code tab in API Explorer. SDK sample code can be automatically generated.

  • Example 1: Creating a load balancer with a private IPv4 address

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    package com.huaweicloud.sdk.test;
    
    import com.huaweicloud.sdk.core.auth.ICredential;
    import com.huaweicloud.sdk.core.auth.BasicCredentials;
    import com.huaweicloud.sdk.core.exception.ConnectionException;
    import com.huaweicloud.sdk.core.exception.RequestTimeoutException;
    import com.huaweicloud.sdk.core.exception.ServiceResponseException;
    import com.huaweicloud.sdk.elb.v3.region.ElbRegion;
    import com.huaweicloud.sdk.elb.v3.*;
    import com.huaweicloud.sdk.elb.v3.model.*;
    
    import java.util.List;
    import java.util.ArrayList;
    
    public class CreateLoadBalancerSolution {
    
        public static void main(String[] args) {
            // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
            // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
            String ak = System.getenv("CLOUD_SDK_AK");
            String sk = System.getenv("CLOUD_SDK_SK");
            String projectId = "{project_id}";
    
            ICredential auth = new BasicCredentials()
                    .withProjectId(projectId)
                    .withAk(ak)
                    .withSk(sk);
    
            ElbClient client = ElbClient.newBuilder()
                    .withCredential(auth)
                    .withRegion(ElbRegion.valueOf("<YOUR REGION>"))
                    .build();
            CreateLoadBalancerRequest request = new CreateLoadBalancerRequest();
            CreateLoadBalancerRequestBody body = new CreateLoadBalancerRequestBody();
            List<String> listLoadbalancerAvailabilityZoneList = new ArrayList<>();
            listLoadbalancerAvailabilityZoneList.add("AZ1");
            CreateLoadBalancerOption loadbalancerbody = new CreateLoadBalancerOption();
            loadbalancerbody.withName("loadbalancer")
                .withDescription("simple lb")
                .withVipSubnetCidrId("1992ec06-f364-4ae3-b936-6a8cc24633b7")
                .withAvailabilityZoneList(listLoadbalancerAvailabilityZoneList)
                .withAdminStateUp(true);
            body.withLoadbalancer(loadbalancerbody);
            request.withBody(body);
            try {
                CreateLoadBalancerResponse response = client.createLoadBalancer(request);
                System.out.println(response.toString());
            } catch (ConnectionException e) {
                e.printStackTrace();
            } catch (RequestTimeoutException e) {
                e.printStackTrace();
            } catch (ServiceResponseException e) {
                e.printStackTrace();
                System.out.println(e.getHttpStatusCode());
                System.out.println(e.getRequestId());
                System.out.println(e.getErrorCode());
                System.out.println(e.getErrorMsg());
            }
        }
    }
    
  • Example 2: Creating a load balancer with an IPv4 EIP

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    package com.huaweicloud.sdk.test;
    
    import com.huaweicloud.sdk.core.auth.ICredential;
    import com.huaweicloud.sdk.core.auth.BasicCredentials;
    import com.huaweicloud.sdk.core.exception.ConnectionException;
    import com.huaweicloud.sdk.core.exception.RequestTimeoutException;
    import com.huaweicloud.sdk.core.exception.ServiceResponseException;
    import com.huaweicloud.sdk.elb.v3.region.ElbRegion;
    import com.huaweicloud.sdk.elb.v3.*;
    import com.huaweicloud.sdk.elb.v3.model.*;
    
    import java.util.List;
    import java.util.ArrayList;
    
    public class CreateLoadBalancerSolution {
    
        public static void main(String[] args) {
            // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
            // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
            String ak = System.getenv("CLOUD_SDK_AK");
            String sk = System.getenv("CLOUD_SDK_SK");
            String projectId = "{project_id}";
    
            ICredential auth = new BasicCredentials()
                    .withProjectId(projectId)
                    .withAk(ak)
                    .withSk(sk);
    
            ElbClient client = ElbClient.newBuilder()
                    .withCredential(auth)
                    .withRegion(ElbRegion.valueOf("<YOUR REGION>"))
                    .build();
            CreateLoadBalancerRequest request = new CreateLoadBalancerRequest();
            CreateLoadBalancerRequestBody body = new CreateLoadBalancerRequestBody();
            CreateLoadBalancerBandwidthOption bandwidthPublicip = new CreateLoadBalancerBandwidthOption();
            bandwidthPublicip.withName("bandwidth_test")
                .withSize(2)
                .withChargeMode(CreateLoadBalancerBandwidthOption.ChargeModeEnum.fromValue("bandwidth"))
                .withShareType(CreateLoadBalancerBandwidthOption.ShareTypeEnum.fromValue("PER"));
            CreateLoadBalancerPublicIpOption publicipLoadbalancer = new CreateLoadBalancerPublicIpOption();
            publicipLoadbalancer.withNetworkType("5_bgp")
                .withBandwidth(bandwidthPublicip);
            List<String> listLoadbalancerAvailabilityZoneList = new ArrayList<>();
            listLoadbalancerAvailabilityZoneList.add("AZ1");
            CreateLoadBalancerOption loadbalancerbody = new CreateLoadBalancerOption();
            loadbalancerbody.withName("elb_eip-test")
                .withVipSubnetCidrId("e6e9271d-aef4-48f0-a93a-ccc7b09032c1")
                .withAvailabilityZoneList(listLoadbalancerAvailabilityZoneList)
                .withAdminStateUp(true)
                .withPublicip(publicipLoadbalancer);
            body.withLoadbalancer(loadbalancerbody);
            request.withBody(body);
            try {
                CreateLoadBalancerResponse response = client.createLoadBalancer(request);
                System.out.println(response.toString());
            } catch (ConnectionException e) {
                e.printStackTrace();
            } catch (RequestTimeoutException e) {
                e.printStackTrace();
            } catch (ServiceResponseException e) {
                e.printStackTrace();
                System.out.println(e.getHttpStatusCode());
                System.out.println(e.getRequestId());
                System.out.println(e.getErrorCode());
                System.out.println(e.getErrorMsg());
            }
        }
    }
    
  • Example 1: Creating a load balancer with a private IPv4 address

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    # coding: utf-8
    
    import os
    from huaweicloudsdkcore.auth.credentials import BasicCredentials
    from huaweicloudsdkelb.v3.region.elb_region import ElbRegion
    from huaweicloudsdkcore.exceptions import exceptions
    from huaweicloudsdkelb.v3 import *
    
    if __name__ == "__main__":
        # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
        # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
        ak = os.environ["CLOUD_SDK_AK"]
        sk = os.environ["CLOUD_SDK_SK"]
        projectId = "{project_id}"
    
        credentials = BasicCredentials(ak, sk, projectId)
    
        client = ElbClient.new_builder() \
            .with_credentials(credentials) \
            .with_region(ElbRegion.value_of("<YOUR REGION>")) \
            .build()
    
        try:
            request = CreateLoadBalancerRequest()
            listAvailabilityZoneListLoadbalancer = [
                "AZ1"
            ]
            loadbalancerbody = CreateLoadBalancerOption(
                name="loadbalancer",
                description="simple lb",
                vip_subnet_cidr_id="1992ec06-f364-4ae3-b936-6a8cc24633b7",
                availability_zone_list=listAvailabilityZoneListLoadbalancer,
                admin_state_up=True
            )
            request.body = CreateLoadBalancerRequestBody(
                loadbalancer=loadbalancerbody
            )
            response = client.create_load_balancer(request)
            print(response)
        except exceptions.ClientRequestException as e:
            print(e.status_code)
            print(e.request_id)
            print(e.error_code)
            print(e.error_msg)
    
  • Example 2: Creating a load balancer with an IPv4 EIP

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    # coding: utf-8
    
    import os
    from huaweicloudsdkcore.auth.credentials import BasicCredentials
    from huaweicloudsdkelb.v3.region.elb_region import ElbRegion
    from huaweicloudsdkcore.exceptions import exceptions
    from huaweicloudsdkelb.v3 import *
    
    if __name__ == "__main__":
        # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
        # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
        ak = os.environ["CLOUD_SDK_AK"]
        sk = os.environ["CLOUD_SDK_SK"]
        projectId = "{project_id}"
    
        credentials = BasicCredentials(ak, sk, projectId)
    
        client = ElbClient.new_builder() \
            .with_credentials(credentials) \
            .with_region(ElbRegion.value_of("<YOUR REGION>")) \
            .build()
    
        try:
            request = CreateLoadBalancerRequest()
            bandwidthPublicip = CreateLoadBalancerBandwidthOption(
                name="bandwidth_test",
                size=2,
                charge_mode="bandwidth",
                share_type="PER"
            )
            publicipLoadbalancer = CreateLoadBalancerPublicIpOption(
                network_type="5_bgp",
                bandwidth=bandwidthPublicip
            )
            listAvailabilityZoneListLoadbalancer = [
                "AZ1"
            ]
            loadbalancerbody = CreateLoadBalancerOption(
                name="elb_eip-test",
                vip_subnet_cidr_id="e6e9271d-aef4-48f0-a93a-ccc7b09032c1",
                availability_zone_list=listAvailabilityZoneListLoadbalancer,
                admin_state_up=True,
                publicip=publicipLoadbalancer
            )
            request.body = CreateLoadBalancerRequestBody(
                loadbalancer=loadbalancerbody
            )
            response = client.create_load_balancer(request)
            print(response)
        except exceptions.ClientRequestException as e:
            print(e.status_code)
            print(e.request_id)
            print(e.error_code)
            print(e.error_msg)
    
  • Example 1: Creating a load balancer with a private IPv4 address

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    package main
    
    import (
    	"fmt"
    	"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
        elb "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/elb/v3"
    	"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/elb/v3/model"
        region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/elb/v3/region"
    )
    
    func main() {
        // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
        // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
        ak := os.Getenv("CLOUD_SDK_AK")
        sk := os.Getenv("CLOUD_SDK_SK")
        projectId := "{project_id}"
    
        auth := basic.NewCredentialsBuilder().
            WithAk(ak).
            WithSk(sk).
            WithProjectId(projectId).
            Build()
    
        client := elb.NewElbClient(
            elb.ElbClientBuilder().
                WithRegion(region.ValueOf("<YOUR REGION>")).
                WithCredential(auth).
                Build())
    
        request := &model.CreateLoadBalancerRequest{}
    	var listAvailabilityZoneListLoadbalancer = []string{
            "AZ1",
        }
    	nameLoadbalancer:= "loadbalancer"
    	descriptionLoadbalancer:= "simple lb"
    	vipSubnetCidrIdLoadbalancer:= "1992ec06-f364-4ae3-b936-6a8cc24633b7"
    	adminStateUpLoadbalancer:= true
    	loadbalancerbody := &model.CreateLoadBalancerOption{
    		Name: &nameLoadbalancer,
    		Description: &descriptionLoadbalancer,
    		VipSubnetCidrId: &vipSubnetCidrIdLoadbalancer,
    		AvailabilityZoneList: listAvailabilityZoneListLoadbalancer,
    		AdminStateUp: &adminStateUpLoadbalancer,
    	}
    	request.Body = &model.CreateLoadBalancerRequestBody{
    		Loadbalancer: loadbalancerbody,
    	}
    	response, err := client.CreateLoadBalancer(request)
    	if err == nil {
            fmt.Printf("%+v\n", response)
        } else {
            fmt.Println(err)
        }
    }
    
  • Example 2: Creating a load balancer with an IPv4 EIP

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    package main
    
    import (
    	"fmt"
    	"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
        elb "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/elb/v3"
    	"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/elb/v3/model"
        region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/elb/v3/region"
    )
    
    func main() {
        // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
        // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
        ak := os.Getenv("CLOUD_SDK_AK")
        sk := os.Getenv("CLOUD_SDK_SK")
        projectId := "{project_id}"
    
        auth := basic.NewCredentialsBuilder().
            WithAk(ak).
            WithSk(sk).
            WithProjectId(projectId).
            Build()
    
        client := elb.NewElbClient(
            elb.ElbClientBuilder().
                WithRegion(region.ValueOf("<YOUR REGION>")).
                WithCredential(auth).
                Build())
    
        request := &model.CreateLoadBalancerRequest{}
    	nameBandwidth:= "bandwidth_test"
    	sizeBandwidth:= int32(2)
    	chargeModeBandwidth:= model.GetCreateLoadBalancerBandwidthOptionChargeModeEnum().BANDWIDTH
    	shareTypeBandwidth:= model.GetCreateLoadBalancerBandwidthOptionShareTypeEnum().PER
    	bandwidthPublicip := &model.CreateLoadBalancerBandwidthOption{
    		Name: &nameBandwidth,
    		Size: &sizeBandwidth,
    		ChargeMode: &chargeModeBandwidth,
    		ShareType: &shareTypeBandwidth,
    	}
    	publicipLoadbalancer := &model.CreateLoadBalancerPublicIpOption{
    		NetworkType: "5_bgp",
    		Bandwidth: bandwidthPublicip,
    	}
    	var listAvailabilityZoneListLoadbalancer = []string{
            "AZ1",
        }
    	nameLoadbalancer:= "elb_eip-test"
    	vipSubnetCidrIdLoadbalancer:= "e6e9271d-aef4-48f0-a93a-ccc7b09032c1"
    	adminStateUpLoadbalancer:= true
    	loadbalancerbody := &model.CreateLoadBalancerOption{
    		Name: &nameLoadbalancer,
    		VipSubnetCidrId: &vipSubnetCidrIdLoadbalancer,
    		AvailabilityZoneList: listAvailabilityZoneListLoadbalancer,
    		AdminStateUp: &adminStateUpLoadbalancer,
    		Publicip: publicipLoadbalancer,
    	}
    	request.Body = &model.CreateLoadBalancerRequestBody{
    		Loadbalancer: loadbalancerbody,
    	}
    	response, err := client.CreateLoadBalancer(request)
    	if err == nil {
            fmt.Printf("%+v\n", response)
        } else {
            fmt.Println(err)
        }
    }
    

For SDK sample code of more programming languages, see the Sample Code tab in API Explorer. SDK sample code can be automatically generated.

Status Codes

Status Code

Description

201

Normal response to POST requests.

Error Codes

See Error Codes.

Sitemizi ve deneyiminizi iyileştirmek için çerezleri kullanırız. Sitemizde tarama yapmaya devam ederek çerez politikamızı kabul etmiş olursunuz. Daha fazla bilgi edinin

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback