All Products
Search
Document Center

Virtual Private Cloud:AssociateHaVip

Last Updated:Jun 19, 2026

Invokes the AssociateHaVip operation to attach an HaVip to an ECS instance or a network interface controller (NIC) in a virtual private cloud (VPC).

Operation description

When you call this operation to associate an HaVip, take note of the following items:

  • The HaVip takes effect immediately after it is attached without the need to restart the ECS instance. However, you must configure the HaVip on the elastic network interfaces (ENIs) of the ECS instance.

  • The HaVip and the ECS instance to be associated must belong to the same vSwitch.

  • An HaVip can be attached to up to 10 ECS instances or up to 10 network interface controllers (NICs) at the same time. However, an HaVip cannot be associated with ECS instances and network interface controllers (NICs) simultaneously.

  • The ECS instance to be associated must be in the Running or Stopped state.

  • The HaVip instance must be in the Available or InUse state.

  • The AssociateHaVip operation is asynchronous. After you send a request, the system returns a request ID, but the HaVip association has not been completed. The association task is still running in the background. You can call DescribeHaVips to query the association status of the HaVip:

    • If the HaVip is in the Associating state, the HaVip is being associated.

    • If the HaVip is in the InUse state, the HaVip is associated.

  • The AssociateHaVip operation does not support concurrent association of the same HaVip.

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:AssociateHaVip

create

*Instance

acs:vpc:{#regionId}:{#accountId}:instance/{#InstanceId}

*HaVip

acs:vpc:{#regionId}:{#accountId}:havip/{#HaVipId}

None None

Request parameters

Parameter

Type

Required

Description

Example

ClientToken

string

No

The client token that is used to ensure the idempotence of the request.

You can use the client to generate the token, but you must make sure that the token is unique among different requests. The ClientToken value 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 may be different.

0c593ea1-3bea-11e9-b96b-88e9fe63****

RegionId

string

Yes

The region ID of the HaVip.

You can call the DescribeRegions operation to query the most recent region list.

cn-shanghai

HaVipId

string

Yes

The ID of the HaVip to be associated.

havip-2zeo05qre24nhrqpy****

InstanceId

string

Yes

The instance ID of the ECS instance to attach to the HaVip.

i-faf344422ffsfad****

InstanceType

string

No

The type of the instance to attach to the HaVip. Valid values:

  • EcsInstance: ECS instance.

  • NetworkInterface: network interface controller (NIC) instance. If the instance to attach to the HaVip is a network interface controller (NIC), this parameter is required.

EcsInstance

Response elements

Element

Type

Description

Example

object

RequestId

string

The request ID.

C44F62BE-9CE7-4277-B117-69243F3988BF

Examples

Success response

JSON format

{
  "RequestId": "C44F62BE-9CE7-4277-B117-69243F3988BF"
}

Error codes

HTTP status code

Error code

Error message

Description

400 OperationUnsupported.BindOnFreeNetworkInterface The network interface must be attached to an ECS instance. The ENI must be associated with an ECS instance.
400 OperationUnsupported.BindMultipleType You cannot bind HaVip to multiple instance types. You cannot associate the ECS instance and the ENI at the same time.
400 OperationUnsupported.BindOnMultipleVswitch The bound instance and HaVip must be on the same vSwitch. The instance to be associated and the HAVIP must belong to the same vSwitch.
400 InvalidVip.Status vip invalid status
400 IncorrectHaVipStatus HaVip can be operated by this action only when it's status is Available or InUse. The operation supports only HAVIPs in the Available or InUse state.
400 IncorrectInstanceStatus ECS instance can be operated by this action only when it?s status is Running or Stopped.
400 CountLimitExceed.HaVipOnInstance The amount of HaVip associated with the specified Instance reach its limits. The number of HAVIPs has reached the upper limit.
400 CountLimitExceeded.HaVipOnECSInstance The amount of Instance associated with the specified HaVip reach its limits. The number of HAVIPs has reached the upper limit.
400 OperationFailed.DistibuteLock Distibute lock fail. The operation is locked by another request;
400 InvalidNetworkInterfaceId.NotFound The network interface is not found. The ENI does not exist.
400 OperationFailed.QueryNetworkInterfaceInfo Failed to query network interface information. The system failed to query ENI information.
400 IllegalParam.InstanceType The specified instance type is invalid. Only ECS instances and network interface are allowed. The type of the associated instance does not support this operation.
400 OperationUnsupported.BindOnSameEcs You cannot bind two network interfaces on the same ECS instance. You are not allowed to associate two ENIs of the same ECS instance.
400 OperationUnsupported.HavipBindType You cannot bind HAVIP to network interface in the specified region. You are not allowed to associate ENIs in the specified region.
400 InvalidInstance.NotExist InvalidInstance.NotExist : The specified Instance does not exist in the specified region. i-bp136w25mhx503ptilrh\r\nRequestId : A961CC27-D797-4E16-B1B3-19B9ECBA1495
400 OperationDenied.BindOnSameEcs The operation is not allowed because networkinterface bind on same instance.
400 Forbidden.HaVip No permissions to perform operations on HAVIPs. Please apply for privilege--vpc_privilege_allow_buy_havip_instance. The error message returned because you do not have the permissions to manage the HAVIP. Go to the Quota Center page to acquire the permissions.
400 InvalidInstanceId.NotFound The specified Instance does not exist in the specified region.
400 ResourceNotFound.EcsInstance The specified resource of ECS instance is not found.
400 InvalidStatus.NotAllow Bind instance status invalid The status of the associated instance is invalid.
400 InvalidHaVip.Exist haVip already bind exist.
400 InvalidRegionId.NotFound The RegionId provided does not exist in our records.
400 QuotaExceeded.HaVipBindInstance The amount of instance associated with the specified haVip reach its limits.
404 InvalidHaVipId.NotFound The specified HaVip does not exist in the specified region. The specified HAVIP does not exist in the specified region. Check whether the specified region is correct.
404 InvalidInstanceId.NotFound The specified Instance does not exist in the specified region.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.