Creating a Load Balancer

Function

This API is used to create a dedicated load balancer. When you create a dedicated load balancer, note the following:

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

  • Specify publicip and either vpc_id or vip_subnet_cidr_id if you want to bind a new IPv4 EIP to the dedicated 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 dedicated load balancer.

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

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

  • You cannot bind an existing and unoccupied private IPv4 address, IPv6 address, or public IPv6 address to the dedicated load balancer.

Note

You cannot bind IPv6 addresses to a dedicated 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 Server. 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.

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.

Minimum: 0

Maximum: 36

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

No

String

Specifies the token used for IAM authentication.

Minimum: 0

Maximum: 4096

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

loadbalancer

Yes

CreateLoadBalancerOption object

Specifies the load balancer.

Table 4 CreateLoadBalancerOption

Parameter

Mandatory

Type

Description

project_id

No

String

Specifies the project ID.

Minimum: 1

Maximum: 32

name

No

String

Specifies the load balancer name.

Minimum: 0

Maximum: 255

description

No

String

Provides supplementary information about the load balancer.

Minimum: 0

Maximum: 255

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 by other services.

Note:

  • vip_subnet_cidr_id is also 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 both vip_address and vip_subnet_cidr_id are not passed, no private IPv4 address will be assigned, and the value of vip_address will be null.

vip_subnet_cidr_id

No

String

Specifies the ID of the IPv4 subnet where the load balancer resides. This parameter is mandatory if you need to create a load balancer with a private IPv4 address.

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

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 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.

Minimum: 1

Maximum: 36

ipv6_vip_virsubnet_id

No

String

Specifies the ID of the IPv6 subnet where the load balancer resides. You can query id in the response by calling the API (GET https://{VPC_Endpoint}/v1/{project_id}/subnets).

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.

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

provider

No

String

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

Minimum: 1

Maximum: 255

l4_flavor_id

No

String

Specifies the ID of a flavor at Layer 4.

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.

Minimum: 1

Maximum: 36

l7_flavor_id

No

String

Specifies the ID of a flavor at Layer 7.

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.

Minimum: 1

Maximum: 36

guaranteed

No

Boolean

Specifies whether the load balancer is a dedicated load balancer.

  • 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).

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.

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.

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.

This parameter is unsupported. Please do not use it.

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 the administrative status of the load balancer. The value can only be true (default).

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. 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 ID of the EIP the system will automatically assign and bind to the load balancer during load balancer creation. 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 on the downstream plane. You can query parameter neutron_network_id in the response by calling the API (GET https://{VPC_Endpoint}/v1/{project_id}/subnets).

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 pubilc 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.

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

The subnets must be in the VPC where the load balancer resides.

ip_target_enable

No

Boolean

Specifies whether to enable IP as a Backend Server.

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

This function is supported only by dedicated load balancers.

The value can be true (enable IP as a Backend Server) or false (disable IP as a Backend Server).

The value can only be update to true.

deletion_protection_enable

No

Boolean

Specifies whether to enable deletion protection for the load balancer.

  • true: Enable deletion protection.

  • false (default): Disable deletion protection.

Note

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

waf_failure_action

No

String

Specifies traffic distributing policies when the WAF is faulty.

  • discard: Traffic will not be distributed.

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

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

This parameter is unsupported. Please do not use it.

Default: forward

Minimum: 0

Maximum: 36

Table 5 Tag

Parameter

Mandatory

Type

Description

key

No

String

Specifies the tag key.

Minimum: 1

Maximum: 36

value

No

String

Specifies the tag value.

Minimum: 0

Maximum: 43

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).

Default: 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.

Minimum: 1

Maximum: 36

billing_info

No

String

Provides billing information about the EIP.

This parameter is unsupported. Please do not use it.

Minimum: 1

Maximum: 1024

description

No

String

Provides supplementary information about the EIP.

Minimum: 1

Maximum: 255

bandwidth

Yes

CreateLoadBalancerBandwidthOption object

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.

Minimum: 1

Maximum: 64

size

No

Integer

Specifies the bandwidth range.

The default range is 1 Mbit/s to 2,000 Mbit/s. (The specific range may vary depending on the configuration in each region. You can see the available bandwidth range on the management console.)

Note:

The minimum increment for bandwidth adjustment varies depending on the 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.

This parameter is mandatory if id is set to null.

Minimum: 0

Maximum: 99999

charge_mode

No

String

Specifies how the bandwidth used by the EIP is billed.

Currently, the bandwidth can be billed only by traffic.

This parameter is mandatory if id is set to null.

Minimum: 1

Maximum: 36

share_type

No

String

Specifies the bandwidth type.

  • PER: indicates dedicated bandwidth.

  • WHOLE: indicates shared bandwidth.

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.

This parameter is unsupported. Please do not use it.

Minimum: 1

Maximum: 1024

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.

Minimum: 1

Maximum: 36

Response Parameters

Status code: 201

Table 9 Response body parameters

Parameter

Type

Description

loadbalancer

LoadBalancer object

Specifies the load balancer. (This parameter is returned when the billing mode of the load balancer is pay-per-use.)

request_id

String

Specifies the request ID. The value is automatically generated.

Minimum: 0

Maximum: 36

Table 10 LoadBalancer

Parameter

Type

Description

id

String

Specifies the load balancer ID.

description

String

Provides supplementary information about the load balancer.

Minimum: 1

Maximum: 255

provisioning_status

String

Specifies the provisioning status of the load balancer. The value can be one of the following:

  • ACTIVE: The load balancer is successfully provisioned.

  • PENDING_DELETE: The load balancer is being deleted.

admin_state_up

Boolean

Specifies the administrative status of the load balancer. The value can only be true.

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. The value can only be ONLINE, indicating that the load balancer is running normally.

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 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.

The default security group associated with the port will take effect only after at least one backend server is associated with 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.

  • 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.

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

This parameter is unsupported. Please do not use it.

billing_info

String

Provides resource billing information.

This parameter is unsupported. Please do not use it.

Minimum: 1

Maximum: 1024

l4_flavor_id

String

Specifies the ID of a flavor at Layer 4.

Minimum: 1

Maximum: 255

l4_scale_flavor_id

String

Specifies the ID of the reserved flavor at Layer 4.

This parameter is unsupported. Please do not use it.

Minimum: 1

Maximum: 255

l7_flavor_id

String

Specifies the ID of a flavor at Layer 7.

Minimum: 1

Maximum: 255

l7_scale_flavor_id

String

Specifies the ID of the reserved flavor at Layer 7.

This parameter is unsupported. Please do not use it.

Minimum: 1

Maximum: 255

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.

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.

  • ipv4: IPv4 subnet

  • dualstack: subnet that supports IPv4/IPv6 dual stack

"dualstack" is not supported.

ip_target_enable

Boolean

Specifies whether to enable IP as a Backend Server.

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

This function is supported only by dedicated load balancers.

The value can be true (enable IP as a Backend Server) or false (disable IP as a Backend Server).

The value can only be update to true.

frozen_scene

String

Specifies the scenario where the load balancer is frozen. Multiple values are separated using commas (,).

This parameter is unsupported. Please do not use it.

ipv6_bandwidth

BandwidthRef object

Specifies the ID of the bandwidth used by an IPv6 address. 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 deletion protection is enabled.

  • false: Deletion protection is not enabled.

  • true: Deletion protection is enabled.

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.

public_border_group

String

Specifies the AZ group to which the load balancer belongs.

waf_failure_action

String

Specifies traffic distributing policies when the WAF is faulty.

  • discard: Traffic will not be distributed.

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

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

This parameter is unsupported. Please do not use it.

Table 11 PoolRef

Parameter

Type

Description

id

String

Specifies the ID of the backend server group.

Table 12 ListenerRef

Parameter

Type

Description

id

String

Specifies the listener ID.

Table 13 Tag

Parameter

Type

Description

key

String

Specifies the tag key.

Minimum: 1

Maximum: 36

value

String

Specifies the tag value.

Minimum: 0

Maximum: 43

Table 14 EipInfo

Parameter

Type

Description

eip_id

String

eip_id

eip_address

String

eip_address

ip_version

Integer

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

Table 15 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 16 BandwidthRef

Parameter

Type

Description

id

String

Specifies the shared bandwidth ID.

Example Requests

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

    POST https://{ELB_Endponit}/v3/060576782980d5762f9ec014dd2f1148/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_Endponit}/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.

{
  "request_id" : "6c63d0ac-7beb-451d-a3e0-a066beaea316",
  "loadbalancer" : {
    "id" : "cce5318e-c79a-4f68-94a2-9fb285c6efbe",
    "project_id" : "060576782980d5762f9ec014dd2f1148",
    "name" : "elb-reset",
    "description" : "",
    "vip_port_id" : null,
    "vip_address" : null,
    "admin_state_up" : true,
    "provisioning_status" : "ACTIVE",
    "operating_status" : "ONLINE",
    "listeners" : [ ],
    "pools" : [ ],
    "tags" : [ ],
    "provider" : "vlb",
    "created_at" : "2021-07-26T02:46:31Z",
    "updated_at" : "2021-07-26T02:46:59Z",
    "vpc_id" : "59cb11ef-f185-49ba-92af-0539e8ff9734",
    "enterprise_project_id" : "0",
    "availability_zone_list" : [ "az1" ],
    "ipv6_vip_address" : null,
    "ipv6_vip_virsubnet_id" : null,
    "ipv6_vip_port_id" : null,
    "publicips" : [ {
      "publicip_id" : "0c07e04d-e2f9-41ad-b934-f58a65b6734d",
      "publicip_address" : "97.97.2.171",
      "ip_version" : 4
    } ],
    "elb_virsubnet_ids" : [ "7f817f9c-8731-4002-9e47-18cb8d431787" ],
    "elb_virsubnet_type" : "dualstack",
    "ip_target_enable" : false,
    "frozen_scene" : null,
    "eips" : [ {
      "eip_id" : "0c07e04d-e2f9-41ad-b934-f58a65b6734d",
      "eip_address" : "97.97.2.171",
      "ip_version" : 4
    } ],
    "guaranteed" : true,
    "billing_info" : null,
    "l4_flavor_id" : "636ba721-935a-4ca5-a685-8076ce0e4148",
    "l4_scale_flavor_id" : null,
    "l7_flavor_id" : null,
    "l7_scale_flavor_id" : null,
    "vip_subnet_cidr_id" : null,
    "deletion_protection_enable" : false,
    "public_border_group" : "center",
    "waf_failure_action" : "forward"
  }
}

Status Codes

Status Code

Description

201

Normal response to POST requests.

Error Codes

See Error Codes.