Adding a Secondary CIDR Block to a VPC

Function

The IPv4 CIDR block you specify when you create a VPC is the primary one. The primary CIDR block cannot be changed after the VPC is created. If IP addresses in the primary CIDR block are insufficient, you can call this API to add a secondary CIDR block to a VPC.

URI

PUT /v3/{project_id}/vpc/vpcs/{vpc_id}/add-extend-cidr

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

  • Definition: ID of the project that a VPC belongs to.

  • Range: None

vpc_id

Yes

String

  • Definition: VPC ID, which uniquely identifies the VPC.

  • Range: None

Request Parameters

Table 2 Request body parameters

Parameter

Mandatory

Type

Description

dry_run

No

Boolean

  • Definition: Whether to only send the check request.

  • Constraints: None

  • Range:

    • true: Only the check request will be sent and no secondary CIDR block will not be added. Check items include mandatory parameters, request format, and constraints. If the check fails, an error will be returned. If the check succeeds, response code 202 will be returned.

    • false: A request will be sent and a secondary CIDR block will be added.

  • Default Value: false

vpc

Yes

AddExtendCidrOption object

  • Definition: Request body for adding a secondary CIDR block.

  • Constraints: None

  • Range: None

  • Default Value: None

Table 3 AddExtendCidrOption

Parameter

Mandatory

Type

Description

extend_cidrs

Yes

Array of strings

  • Definition: Secondary CIDR blocks of a VPC.

  • Constraints: Only IPv4 CIDR blocks are supported. Each VPC can have up to five secondary CIDR blocks.

  • Range: The following CIDR blocks are not supported:

    • 10.0.0.0/8: The IP address range is 10.0.0.0-10.255.255.255.

    • 172.16.0.0/12: The IP address range is 172.16.0.0-172.31.255.255.

    • 192.168.0.0/16: The IP address range is 192.168.0.0-192.168.255.255.

    • 172.31.0.0/16: The IP address range is 172.31.0.0-172.31.255.255.

    • 100.64.0.0/10: The IP address range is 100.64.0.0-100.127.255.255.

    • 214.0.0.0/7: The IP address range is 214.0.0.0-215.255.255.255.

    • 198.18.0.0/15: The IP address range is 198.18.0.0-198.19.255.255.

    • 169.254.0.0/16: The IP address range is 169.254.0.0-169.254.255.255.

    • 0.0.0.0/8: The IP address range is 0.0.0.0-0.255.255.255.

    • 127.0.0.0/8: The IP address range is 127.0.0.0-127.255.255.255.

    • 240.0.0.0/4: The IP address range is 240.0.0.0-255.255.255.255.

  • Default Value: None

Response Parameters

Status code: 200

Table 4 Response body parameters

Parameter

Type

Description

request_id

String

  • Definition: Request ID.

  • Range: None

vpc

Vpc object

  • Definition: Response body for adding a secondary CIDR block.

  • Range: None

Table 5 Vpc

Parameter

Type

Description

id

String

  • Definition: VPC ID. After a VPC is created, a VPC ID is generated, which uniquely identifies the VPC.

  • Range: The value is in UUID format with hyphens (-).

name

String

  • Definition: VPC name.

  • Range: The value can contain 0 to 64 characters. It can include letters, digits, underscores (_), hyphens (-), and periods (.).

description

String

  • Definition: Description of a VPC.

  • Range: The value can contain no more than 255 characters and cannot contain angle brackets (< or >).

cidr

String

  • Definition: Available subnets in a VPC.

  • Range:

    • 10.0.0.0/8-24: The IP address ranges from 10.0.0.0 to 10.255.255.255, and the netmask ranges from 8 to 24.

    • 172.16.0.0/12-24: The IP address ranges from 172.16.0.0 to 172.31.255.255, and the netmask ranges from 12 to 24.

    • 192.168.0.0/16-24: The IP address ranges from 192.168.0.0 to 192.168.255.255, and the netmask ranges from 16 to 24.

    • If cidr is not specified, the default value is "".

extend_cidrs

Array of strings

  • Definition: Secondary CIDR blocks of a VPC.

  • Range: The following CIDR blocks are not supported:

    • 10.0.0.0/8: The IP address range is 10.0.0.0-10.255.255.255.

    • 172.16.0.0/12: The IP address range is 172.16.0.0-172.31.255.255.

    • 192.168.0.0/16: The IP address range is 192.168.0.0-192.168.255.255.

    • 172.31.0.0/16: The IP address range is 172.31.0.0-172.31.255.255.

    • 100.64.0.0/10: The IP address range is 100.64.0.0-100.127.255.255.

    • 214.0.0.0/7: The IP address range is 214.0.0.0-215.255.255.255.

    • 198.18.0.0/15: The IP address range is 198.18.0.0-198.19.255.255.

    • 169.254.0.0/16: The IP address range is 169.254.0.0-169.254.255.255.

    • 0.0.0.0/8: The IP address range is 0.0.0.0-0.255.255.255.

    • 127.0.0.0/8: The IP address range is 127.0.0.0-127.255.255.255.

    • 240.0.0.0/4: The IP address range is 240.0.0.0-255.255.255.255.

status

String

  • Definition: VPC status.

  • Range:

    • PENDING: The VPC is being created.

    • ACTIVE: The VPC is created.

project_id

String

  • Definition: ID of the project that a VPC belongs to.

  • Range: None

enterprise_project_id

String

  • Definition: ID of the enterprise project that a VPC belongs to.

  • Range: The value is 0 or a string that contains a maximum of 36 characters in UUID format with hyphens (-). 0 indicates the default enterprise project.

created_at

String

  • Definition: Time when a VPC was created.

  • Range: UTC time in the format of yyyy-MM-ddTHH:mm:ssZ

updated_at

String

  • Definition: Time when a VPC was updated.

  • Range: UTC time in the format of yyyy-MM-ddTHH:mm:ssZ

cloud_resources

Array of CloudResource objects

  • Definition: Type and number of resources associated with a VPC. For example, subnets and route tables.

  • Range: None

tags

Array of ResponseTag objects

  • Definition: Tags of a VPC, including tag keys and tag values, which can be used to classify and identify resources. For details, see the tag objects.

  • Range: None

Table 6 CloudResource

Parameter

Type

Description

resource_type

String

  • Definition: Resource type.

  • Range: None

resource_count

Integer

  • Definition: Number of resources.

  • Range: None

Table 7 ResponseTag

Parameter

Type

Description

key

String

  • Definition: Tag key.

  • Range:

    • Each key can contain up to 36 Unicode characters and cannot be left blank.

    • Each key value of a resource must be unique.

    • The value can contain:

      • Letters

      • Digits

      • Special characters: underscores (_) ,at signs (@), and hyphens (-)

value

String

  • Definition: Tag value.

  • Range:

    • Each value can contain up to 43 Unicode characters and can be left blank.

    • The value can contain:

      • Letters

      • Digits

      • Special characters: underscore (_), at signs (@), and hyphen (-)

Status code: 202

Table 8 Response body parameters

Parameter

Type

Description

request_id

String

  • Definition: Request ID.

  • Range: None

error_msg

String

  • Definition: Error message.

  • Range: None

error_code

String

  • Definition: Error code.

  • Range: None

Example Requests

Add the secondary CIDR block 23.8.0.0/16 to the VPC whose ID is 0552091e-b83a-49dd-88a7-4a5c86fd9ec3.

PUT https://{Endpoint}/v3/{project_id}/vpc/vpcs/0552091e-b83a-49dd-88a7-4a5c86fd9ec3/add-extend-cidr

{
  "vpc" : {
    "extend_cidrs" : [ "23.8.0.0/16" ]
  }
}

Example Responses

Status code: 200

Normal response to the PUT operation. For more status codes, see Status Code.

{
  "request_id" : "84eb4f775d66dd916db121768ec55626",
  "vpc" : {
    "id" : "0552091e-b83a-49dd-88a7-4a5c86fd9ec3",
    "name" : "vpc1",
    "description" : "test1",
    "cidr" : "192.168.0.0/16",
    "extend_cidrs" : [ "23.8.0.0/16" ],
    "enterprise_project_id" : "0",
    "tags" : [ {
      "key" : "key",
      "value" : "value"
    } ],
    "cloud_resources" : [ {
      "resource_type" : "routetable",
      "resource_count" : 1
    } ],
    "status" : "ACTIVE",
    "project_id" : "060576782980d5762f9ec014dd2f1148",
    "created_at" : "2018-03-23T09:26:08",
    "updated_at" : "2018-08-24T08:49:53"
  }
}

Status code: 202

Normal response to the specified preflight request of API V3. For more status codes, see Status Code.

{
  "error_msg" : "Request validation has been passed with dry run...",
  "error_code" : "SYS.0202",
  "request_id" : "cfd81aea3f59eac7128dba4b36d516c8"
}

Status Codes

Status Code

Description

200

Normal response to the PUT operation. For more status codes, see Status Code.

202

Normal response to the specified preflight request of API V3. For more status codes, see Status Code.

Error Codes

See Error Codes.