Help Center > Virtual Private Cloud > API Reference > VPC Peering Connection > Creating a VPC Peering Connection

Creating a VPC Peering Connection

Function

This interface is used to create a VPC peering connection.

If you create a VPC peering connection with another VPC of your own, the connection is created without the need for your to accept the connection.

If you create a VPC peering connection with a VPC of another tenant, the peer tenant must accept the connection so that the connection can be created. If the peer tenant refuses the connection, it cannot be created.

API Format

Method

URI

Description

POST

/v2.0/vpc/peerings

Creates a VPC peering connection.

Restrictions

N/A

Extension Description

N/A

Request Parameter

Parameter

Type

Mandatory

Description

peering

Dict

Yes

Specifies the VPC peering connection object list. For details, see Table 1.

Mandatory fields: request_vpc_id and accept_vpc_id. If you create a VPC peering connection with a VPC of another tenant, you must specify tenant_id of the peer tenant.

Response Parameter

Parameter

Type

Mandatory

Description

peering

Dict

Yes

Specifies the VPC peering connection information. For details, see the peering object model.

Example Request

POST /v2.0/vpc/peerings 
{ 
    "peering": { 
        "name": "test",  
        "request_vpc_info": {
           "vpc_id": "9daeac7c-a98f-430f-8e38-67f9c044e299"
        }, 
        "accept_vpc_info": {
           "vpc_id": "f583c072-0bb8-4e19-afb2-afb7c1693be5"
        }
    } 
}

Example Response

{ 
    "peering": { 
        "name": "test", 
        "id": "22b76469-08e3-4937-8c1d-7aad34892be1"
        "request_vpc_info": {
           "vpc_id": "9daeac7c-a98f-430f-8e38-67f9c044e299",
           "tenant_id": "f65e9ebc-ed5d-418b-a931-9a723718ba4e"
        },
        "accept_vpc_info": {
           "vpc_id": "f583c072-0bb8-4e19-afb2-afb7c1693be5",
           "tenant_id": "f65e9ebc-ed5d-418b-a931-9a723718ba4e"
        }, 
        "status": "ACTIVE"
    }
}

Error Codes

Normal Response Code

Type

Description

200

OK

Specifies the normal response code for the GET and PUT operations.

201

Created

Specifies the normal response code for the POST operation.

204

No Content

Specifies the normal response code for the DELETE operation.

Returned Value

Description

400 Bad Request

The server failed to process the request.

401 Unauthorized

You must enter the username and password to access the requested page.

403 Forbidden

You are forbidden to access the requested page.

404 Not Found

The server could not find the requested page.

405 Method Not Allowed

You are not allowed to use the method specified in the request.

406 Not Acceptable

The response generated by the server could not be accepted by the client.

407 Proxy Authentication Required

You must use the proxy server for authentication so that the request can be processed.

408 Request Timeout

The request timed out.

409 Conflict

The request could not be processed due to a conflict.

500 Internal Server Error

Failed to complete the request because of an internal service error.

501 Not Implemented

Failed to complete the request because the server does not support the requested function.

502 Bad Gateway

Failed to complete the request because the request is invalid.

503 Service Unavailable

Failed to complete the request because the service is unavailable.

504 Gateway Timeout

A gateway timeout error occurred.

Registration