Creating a VPC
Scenarios
This section describes how to call the VPC creation API to create a VPC. For details about the parameters for creating a VPC and the response message, see section Creating a VPC.
Prerequisites
You have planned the region where you want to create the VPC and obtained the endpoint required for API calls. For details, see Endpoints.
To use token authentication, you need to obtain a token and add X-Auth-Token to the request headers. Obtain the token by performing the steps provided in section Authentication.
The token obtained from IAM is valid for only 24 hours. If you want to use one token for authentication, you can cache it to avoid frequently obtaining the token.
Procedure
- Send POST https://VPC endpoint/v1/{project_id}/vpcs. Parameter project_id indicates the project ID.
- Add X-Auth-Token to the request header.
- Specify the following parameters in the request body:
{ "vpc": { "name": "vpc", //VPC name "cidr": "192.168.0.0/16" //Available subnet IP address ranges in the VPC } }
- Check the response message.
- The request is successful if the following response is displayed. In the response, id indicates the VPC ID.
{ "vpc": { "id": "b6684a27-b049-407d-90b4-c9551f2390e1", "name": "vpc", "cidr": "192.168.0.0/16", "status": "CREATING", "routes": [] } }
- For details about the error codes displayed if the request fails, see section Error Codes.
- The request is successful if the following response is displayed. In the response, id indicates the VPC ID.
- Query the VPC details as well as update or delete the VPC based on the vpc_id and project_id values.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot