Creates a VPN gateway.
Operation description
-
Before you create a VPN gateway, review the limits of VPN gateways. For more information, see Limits on VPN gateways.
-
In some regions, VPN gateway instances support only the creation of IPsec-VPN connections in dual-tunnel mode by default. When you call the
CreateVpnGatewayoperation to create a VPN gateway instance in these regions, you must specify the VSwitchId and DisasterRecoveryVSwitchId parameters in addition to the required parameters. For more information about the regions and zones that support IPsec-VPN connections in dual-tunnel mode, see Upgrade an IPsec-VPN connection to dual-tunnel mode. -
The CreateVpnGateway operation is asynchronous. The system returns an instance ID, but the VPN gateway is not yet created and the creation task is still running in the background. You can call the DescribeVpnGateway operation to query the creation status of the VPN gateway:
If the VPN gateway is in the provisioning state, the VPN gateway is being created.
If the VPN gateway is in the active state, the VPN gateway is created.
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
vpc:CreateVpnGateway |
create |
*VpnGateway
|
None | None |
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| RegionId |
string |
Yes |
The region ID of the VPN gateway. You can call the DescribeRegions operation to query region IDs. |
cn-hangzhou |
| Name |
string |
No |
The name of the VPN gateway. Default value: the ID of the VPN gateway. The name must be 2 to 100 characters in length, and cannot start with |
MYVPN |
| VpcId |
string |
Yes |
The ID of the VPC to which the VPN gateway belongs. |
vpc-bp1ub1yt9cvakoelj**** |
| InstanceChargeType |
string |
No |
The billing method of the VPN gateway. Valid value: POSTPAY (pay-as-you-go billing method). |
Example value for the China site: PREPAY. Example value for the international site: POSTPAY |
| Period |
integer |
No |
The subscription duration. Unit: months. Valid values: 1 to 9, 12, 24, and 36. |
1 |
| AutoPay |
boolean |
No |
Specifies whether to automatically pay the bill for the VPN gateway. Valid values:
Note
To successfully create the VPN gateway instance, enable automatic payment. If you disable automatic payment, you must manually pay the bill to create the VPN gateway instance. |
false |
| Bandwidth |
integer |
Yes |
The bandwidth of the VPN gateway. Unit: Mbit/s.
Note
In some regions, the maximum bandwidth supported by a VPN gateway is 500 Mbit/s. For more information, see Limits on VPN gateways. |
5 |
| EnableIpsec |
boolean |
No |
Specifies whether to enable the IPsec-VPN feature. Valid values:
|
true |
| EnableSsl |
boolean |
No |
Specifies whether to enable the SSL-VPN feature. Valid values:
|
false |
| SslConnections |
integer |
No |
The maximum number of concurrent SSL-VPN connections. Valid values: 5 (default), 10, 20, 50, 100, 200, 500, and 1000. |
5 |
| VSwitchId |
string |
No |
The ID of the vSwitch to which the VPN gateway is connected.
|
vsw-bp1j5miw2bae9s2vt**** |
| VpnType |
string |
No |
The type of the VPN gateway. Valid values:
|
Normal |
| ClientToken |
string |
No |
The client token that is used to ensure the idempotence of the request. You can use the client to generate the value, but you must ensure that it is unique among different requests. The client token can contain only ASCII characters. Note
If you do not specify this parameter, the system automatically uses the RequestId of the API request as the ClientToken. The RequestId of each API request is unique. |
02fb3da4**** |
| NetworkType |
string |
No |
The network type of the VPN gateway. Valid values:
|
public |
| DisasterRecoveryVSwitchId |
string |
No |
The ID of the secondary vSwitch associated with the VPN gateway instance.
For more information about the regions and zones that support IPsec-VPN connections in dual-tunnel mode, see Upgrade an IPsec-VPN connection to dual-tunnel mode. |
vsw-p0wiz7obm0tbimu4r**** |
| ResourceGroupId |
string |
No |
The ID of the resource group to which the VPN gateway belongs.
|
rg-acfmzs372yg**** |
Response elements
|
Element |
Type |
Description |
Example |
|
object |
The response structure. |
||
| VpnGatewayId |
string |
The VPN gateway instance ID. |
vpn-uf68lxhgr7ftbqr3p**** |
| RequestId |
string |
The ID of the request. |
EB2C156A-41F8-49CC-A756-D55AFC8BFD69 |
| Name |
string |
The name of the VPN gateway. |
MYVPN |
| OrderId |
integer |
The ID of the order. If you did not enable automatic payment for the VPN gateway, go to the Expenses and Costs console to complete the payment. |
208240895400460 |
Examples
Success response
JSON format
{
"VpnGatewayId": "vpn-uf68lxhgr7ftbqr3p****",
"RequestId": "EB2C156A-41F8-49CC-A756-D55AFC8BFD69",
"Name": "MYVPN",
"OrderId": 208240895400460
}
Error codes
|
HTTP status code |
Error code |
Error message |
Description |
|---|---|---|---|
| 400 | InvalidVpcId.NotFound | The specified VPC id does not exist in our records. | |
| 400 | InvalidName | The specified value of Name not supported. | |
| 400 | InvalidSpec.NotFound | The specified Spec does not exist in our records. | |
| 400 | InvalidPeriod | The specified period is not valid | |
| 400 | ChargeType.NotSupport | The specified charge type is not support. | |
| 400 | InventoryNotEnough | The inventory is not enough. | |
| 400 | UnnecessarySslConnection | The SSL connection is unnecessary for ssl vpn disabled. | |
| 400 | InvalidVpnEnable | Either IPsec or SSL VPN must be set enable. | |
| 400 | Resource.QuotaFull | The quota of resource is full | |
| 400 | InvalidVSwitchId.NotFound | The specified vswitchId is not found. | |
| 400 | OperationFailed.InventoryNotEnough | No enough available resource. Try another vswitch with different available zone. | |
| 400 | Forbidden.OperateShareResource | Operating shared resources is forbidden. | |
| 400 | OperationFailed.IpNotEnough | Operation failed because private ip address of the virtual switch is not enough. | |
| 400 | Forbidden.NoSLRPermission | User not authorized to create service linked role. | |
| 400 | OperationFailed.VSwitchConflict | The vswitch can't create vpn. Try another vswitch. | |
| 400 | OperationFailed.AzNotSupport | Current available zone can't create vpn. Try another vswitch with different available zone. | |
| 400 | OperationFailed.NetworkTypeNotMatch | Create NationalStandard vpn with private networkType is unsupported. | |
| 400 | OperationFailed.SslNotSupport | Enable ssl vpn with private networkType is unsupported. | You cannot enable the SSL feature for a private VPN gateway. |
| 400 | Forbidden.TagKey.Duplicated | The specified tag key already exists. | The tag resources are duplicate. |
| 400 | SizeLimitExceeded.TagNum | The maximum number of tags is exceeded. | The number of tags has reached the upper limit. |
| 400 | InvalidParameter.TagValue | The specified parameter TagValue is invalid. | The error message returned because the specified tag value is invalid. |
| 400 | InvalidParameter.TagKey | The specified parameter TagKey is invalid. | The error message returned because the specified tag key is invalid. |
| 400 | Duplicated.TagKey | The specified parameter TagKey is duplicated. | The error message returned because the specified tag key already exists. |
| 400 | InternalError | The request processing has failed due to some unknown error, exception or failure. | |
| 400 | InvalidVSwitchId.FirstVswitchNotSupport | The available zone of vswitch1 not supported. | The zone where the primary vSwitch is located is not supported. |
| 400 | InvalidVSwitchId.VswitchIdShouldDifferent | The VSwitch ids should be different. | The primary zone cannot be the same as the secondary zone. |
| 400 | InvalidVSwitchId.FirstVswitchIpNotEnough | The ip of vswitch1 not enough. | Insufficient number of available IPs in primary vSwitch. |
| 400 | InvalidVSwitchId.SecondVswitchIpNotEnough | The ip of vswitch2 not enough. | Insufficient IP addresses are available in the standby vSwitch. |
| 400 | InvalidVSwitchId.ZoneIdShouldDifferent | Two vSwitches should belong to different Availability Zones. | When you create a dual-tunnel VPN gateway, the two vSwitches that you specify must belong to different zones. |
| 400 | MissingParam.VSwitchId | The parameter VSwitchId is missing. | The parameter VSwitchId is missing. |
| 400 | MissingParam.DisasterRecoveryVSwitchId | The parameter DisasterRecoveryVSwitchId is missing. | The parameter DisasterRecoveryVSwitchId is missing. |
| 400 | InvalidDisasterRecoveryVSwitchId.NotFound | The specified DisasterRecoveryVSwitchId does not exist in the specified region. | The specified DisasterRecoveryVSwitchId does not exist in the specified region. |
| 400 | InvalidVSwitchId.SecondVswitchNotSupport | The zone of the DisasterRecoveryVSwitch does not support creating a ha-tunnel VPN. | The zone of the DisasterRecoveryVSwitch does not support creating a ha-tunnel VPN. |
| 404 | InvalidRegionId.NotFound | The specified region is not found during access authentication. | The specified area is not found during authentication. |
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.