All Products
Search
Document Center

VPN Gateway:CreateVpnGateway

Last Updated:Oct 08, 2026

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 CreateVpnGateway operation 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

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

vpc:CreateVpnGateway

create

*VpnGateway

acs:vpc:{#regionId}:{#accountId}: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 http:// or https://. It must start with a letter and can contain letters, digits, underscores (_), hyphens (-), and periods (.). Other special characters are not supported.

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:

  • true: automatically pays the bill for the VPN gateway.

  • false (default): does not automatically pay the bill for the VPN gateway.

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.

  • If you want to create an Internet-public VPN gateway, valid values are 10, 100, 200, 500, and 1000.

  • If you want to create an internal-public VPN gateway, valid values are 200 and 1000.

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 (default): enables the IPsec-VPN feature.

  • false: disables the IPsec-VPN feature.

true

EnableSsl

boolean

No

Specifies whether to enable the SSL-VPN feature. Valid values:

  • true: enables the SSL-VPN feature.

  • false (default): disables the SSL-VPN feature.

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.

  • In regions that support IPsec-VPN connections in dual-tunnel mode, this parameter is required. You must specify a vSwitch and also specify the DisasterRecoveryVSwitchId parameter.

  • In regions that support IPsec-VPN connections in single-tunnel mode, if you do not specify a vSwitch, the system automatically selects a vSwitch from the VPC.

vsw-bp1j5miw2bae9s2vt****

VpnType

string

No

The type of the VPN gateway. Valid values:

  • Normal (default): standard.

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 (default): Internet-public VPN gateway.

  • private: internal-public VPN gateway.

public

DisasterRecoveryVSwitchId

string

No

The ID of the secondary vSwitch associated with the VPN gateway instance.

  • This parameter is required if the current region supports IPsec-VPN connections in dual-tunnel mode.

  • You must specify two vSwitches that are deployed in different zones within the VPC associated with the VPN gateway instance to implement zone-level disaster recovery for the IPsec-VPN connection.

  • For regions that support only one zone, zone-level disaster recovery is not supported. We recommend that you specify two different vSwitches in the zone to implement high availability for the IPsec-VPN connection. You can also specify the same vSwitch.

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.

  • You can call the ListResourceGroups operation to query resource group IDs.

  • If you do not specify a resource group ID, the VPN gateway belongs to the default resource group after it is created.

  • After the VPN gateway is created, if you create an SSL server, an SSL client certificate, an IPsec server, or an IPsec-VPN connection (applicable to scenarios where the IPsec-VPN connection is associated with the VPN gateway) under the VPN gateway, these resources automatically belong to the resource group of the VPN gateway and cannot be modified.

    If you change the resource group of the VPN gateway, the resource groups of the preceding resources are also changed.

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.