# Creating a VPC Endpoint

#### Function

This API is used to create a VPC endpoint for accessing a VPC endpoint service.

#### URI

POST /v1/{project_id}/vpc-endpoints

Table 1 describes the required parameters.

Table 1 Parameter description
Parameter | Mandatory | Description
--- | --- | ---
project_id | Yes | Specifies the project ID. For details about how to obtain the project ID, see Obtaining a Project ID.

#### Request

- Parameter description

  Table 2 Request parameters
  Parameter | Mandatory | Type | Description
  --- | --- | --- | ---

  subnet_id

  No

  NOTE:

  This parameter is mandatory to create an interface VPC endpoint.

  String

  The ID must be the ID of the subnet created in the VPC specified by vpc_id and in the format of the UUID.

  For details, see response field id in Querying Subnet Details in the Virtual Private Cloud API Reference.

  This parameter is mandatory only if you create a VPC endpoint for connecting to an interface VPC endpoint service.

  NOTE:
  - The CIDR block of the VPC subnet cannot overlap with 198.19.128.0/20.
  - The destination address of the custom route in the VPC route table cannot overlap with 198.19.128.0/20.

  endpoint_service_id | Yes | String | Specifies the ID of the VPC endpoint service. You can obtain the ID of the VPC endpoint service to be connected by performing operations in Querying Basic Information of a VPC Endpoint Service.
  vpc_id | Yes | String | Specifies the ID of the VPC where the VPC endpoint is to be created. For details, see response field id in Querying VPC Details in the Virtual Private Cloud API Reference.

  enable_dns

  No

  Boolean

  Specifies whether to create a private domain name.
  - true: indicates that a private domain name is created.
  - false: indicates that a private domain name is not created.

  The default value is false.

  NOTE:

  When a VPC endpoint for connecting to a gateway VPC endpoint service is created, no private domain name is created no matter enable_dns is set to true or false.

  tags | No | Array of objects | Lists the resource tags. For details, see Table 3. A maximum of 20 tags can be added to each VPC endpoint.
  routetables | No | Array of objects | Lists the IDs of route tables. For details, see response field id in Querying a VPC Route in the Virtual Private Cloud API Reference. This parameter is mandatory only if you create a VPC endpoint for connecting to a gateway VPC endpoint service. NOTE: If this parameter is not configured, use the default route table.
  port_ip | No | String | Specifies the IP address for accessing the associated VPC endpoint service. You can specify IP addresses for accessing the associated VPC endpoint service when creating a VPC endpoint. Only IPv4 addresses are supported. This parameter is mandatory only if you create a VPC endpoint for connecting to an interface VPC endpoint service.
  whitelist | No | Array of strings | Specifies the whitelist for controlling access to the VPC endpoint. IPv4 addresses or CIDR blocks can be specified to control access when you create a VPC endpoint. This parameter is available only when you create a VPC endpoint for connecting to an interface VPC endpoint service.
  enable_whitelist | No | Boolean | Specifies whether to enable access control.

  Table 3 ResourceTags parameters
  Parameter | Mandatory | Type | Description
  --- | --- | --- | ---
  key | No | String | Specifies the tag key. A tag key contains a maximum of 36 Unicode characters. This parameter cannot be left blank. It can contain only digits, letters, hyphens (-), underscores (_), and at signs (@).
  value | No | String | Specifies the tag value. A tag value contains a maximum of 43 Unicode characters and can be left blank. It can contain only digits, letters, hyphens (-), underscores (_), and at signs (@).

- Example request

      POST https://{endpoint}/v1/{project_id}/vpc-endpoints

      {
      "subnet_id": "68bfbcc1-dff2-47e4-a9d4-332b9bc1b8de",
      "vpc_id": "84758cf5-9c62-43ae-a778-3dbd8370c0a4",
      "tags":[
                  {
                      "key":"test1",
                      "value":"test1"
                  }
             ],
      "endpoint_service_id":"e0c748b7-d982-47df-ba06-b9c8c7650c1a",
      "enable_dns":true
      }

#### Response

- Parameter description

  Table 4 Response parameters
  Parameter | Type | Description
  --- | --- | ---
  id | String | Specifies the unique ID of the VPC endpoint.

  service_type

  String

  Specifies the type of the VPC endpoint service that is associated with the VPC endpoint.
  - Gateway: VPC endpoint services of this type are configured by operations people. You can use them directly without the need to create one by yourselves.
  - Interface: VPC endpoint services of this type include cloud services configured by operations people and private services created by yourselves. You cannot configure these cloud services, but can use them.

  You can view those VPC endpoint services that are configured by operations people and are visible and accessible to all users. For detailed steps, see Querying Public VPC Endpoint Services. Perform the operations in Creating a VPC Endpoint Service to create an interface VPC endpoint service.

  status

  String

  Specifies the connection status of the VPC endpoint.
  - pendingAcceptance: indicates that the VPC endpoint is pending acceptance.
  - creating: indicates the VPC endpoint is being created.
  - accepted: indicates the VPC endpoint has been accepted.
  - failed: indicates the creation of the VPC endpoint failed.

  active_status

  String

  Specifies the domain status.
  - frozen: indicates that the domain is frozen.
  - active: indicates that the domain is normal.

  endpoint_service_name | String | Specifies the name of the VPC endpoint service.
  marker_id | Integer | Specifies the packet ID of the VPC endpoint.
  endpoint_service_id | String | Specifies the ID of the VPC endpoint service.

  enable_dns

  Boolean

  Specifies whether to create a private domain name.
  - true: indicates that a private domain name is created.
  - false: indicates that a private domain name is not created.
  NOTE:

  When a VPC endpoint for connecting to a gateway VPC endpoint service is created, no private domain name is created no matter enable_dns is set to true or false.

  dns_names | Array of strings | Specifies the domain name for accessing the associated VPC endpoint service. This parameter is only available when enable_dns is set to true.
  subnet_id | String | Specifies the ID of the subnet in the VPC specified by vpc_id. The ID is in the UUID format.
  vpc_id | String | Specifies the ID of the VPC where the VPC endpoint is to be created.
  created_at | String | Specifies the creation time of the VPC endpoint. The UTC time format is used: YYYY-MM-DDTHH:MM:SSZ.
  updated_at | String | Specifies the update time of the VPC endpoint. The UTC time format is used: YYYY-MM-DDTHH:MM:SSZ.
  project_id | String | Specifies the project ID. For details about how to obtain the project ID, see Obtaining a Project ID.
  tags | Array of objects | Lists the resource tags. For details, see Table 5.
  whitelist | Array of strings | Specifies the whitelist for controlling access to the VPC endpoint. If you do not specify this parameter, an empty whitelist is returned. This parameter is available only if you create a VPC endpoint for connecting to an interface VPC endpoint service.

  enable_whitelist

  Boolean

  Specifies whether to enable access control.
  - true: indicates that access control is enabled.
  - false: indicates that access control is disabled.

  If you do not specify this parameter, the whitelist is not enabled.

  This parameter is available only if you create a VPC endpoint for connecting to an interface VPC endpoint service.

  routetables | Array of strings | Lists the IDs of route tables. If you do not specify this parameter, the route table ID of the VPC is returned. This parameter is available only when you create a VPC endpoint for connecting to a gateway VPC endpoint service.

  Table 5 ResourceTags parameters
  Parameter | Type | Description
  --- | --- | ---
  key | String | Specifies the tag key. A tag key contains a maximum of 36 Unicode characters. This parameter cannot be left blank. It can contain only digits, letters, hyphens (-), and underscores (_).
  value | String | Specifies the tag value. A tag value contains a maximum of 43 Unicode characters and can be left blank. It can contain only digits, letters, hyphens (-), and underscores (_).

- Example response

      {
          "id": "4189d3c2-8882-4871-a3c2-d380272eed83",
          "service_type": "interface",
          "marker_id": 322312312312,
          "status": "creating",
          "vpc_id": "4189d3c2-8882-4871-a3c2-d380272eed83",
          "enable_dns": false,
          "endpoint_service_name": "test123",
          "endpoint_service_id": "test123",
          "project_id": "6e9dfd51d1124e8d8498dce894923a0d",
          "whitelist": [
              "127.0.0.1"
          ],
          "enable_whitelist": true,
          "created_at": "2018-01-30T07:42:01.174",
          "update_at": "2018-01-30T07:42:01.174",
          "tags": [
              {
                  "key": "test1",
                  "value": "test1"
              }
          ]
      }

#### Status Code

For details about status codes, see Status Code.

Parent topic: APIs for Managing VPC Endpoints