All Products
Search
Document Center

Virtual Private Cloud:AssociateHaVip

Last Updated:Aug 29, 2024

Associates a high-availability virtual IP address (HAVIP) with an Elastic Compute Service (ECS) instance or an elastic network interface (ENI).

Operation description

When you call this operation, take note of the following limits:

  • An HAVIP immediately takes effect after it is associated. You do not need to restart the ECS instance. However, you must associate the HAVIP with the ENI of the ECS instance.

  • The HAVIP and ECS instance must belong to the same vSwitch.

  • You can associate an HAVIP with at most two ECS instances.

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

  • The HAVIP must be in the Available or InUse state.

  • The AssociateHaVip operation is asynchronous. After you send the request, the system returns a request ID. However, the operation is still being performed in the system background. You can call the DescribeHaVips operation to query the status of an 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.
  • You cannot repeatedly call the AssociateHaVip operation to associate an HAVIP within the specified period of time.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer.

Authorization information

The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:

  • Operation: the value that you can use in the Action element to specify the operation on a resource.
  • Access level: the access level of each operation. The levels are read, write, and list.
  • Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
    • The required resource types are displayed in bold characters.
    • If the permissions cannot be granted at the resource level, All Resources is used in the Resource type column of the operation.
  • Condition Key: the condition key that is defined by the cloud service.
  • Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
OperationAccess levelResource typeCondition keyAssociated operation
vpc:AssociateHaVipcreate
  • Instance
    acs:vpc:{#regionId}:{#accountId}:instance/{#InstanceId}
  • HaVip
    acs:vpc:{#regionId}:{#accountId}:havip/{#HaVipId}
    none
none

Request parameters

ParameterTypeRequiredDescriptionExample
ClientTokenstringNo

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 make sure that it is unique among different requests. The client token can contain only ASCII characters.

Note If you do not set this parameter, the system uses RequestId as ClientToken. The value of RequestId in each API request may be different.
0c593ea1-3bea-11e9-b96b-88e9fe63****
RegionIdstringYes

The ID of the region to which the HAVIP belongs.

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

cn-shanghai
HaVipIdstringYes

The ID of the HAVIP.

havip-2zeo05qre24nhrqpy****
InstanceIdstringYes

The ID of the ECS instance to be associated with the HAVIP.

i-faf344422ffsfad****
InstanceTypestringNo

The type of the instance to be associated with the HAVIP. Valid values:

  • EcsInstance: an ECS instance
  • NetworkInterface: an ENI. If you want to associate the HAVIP with an ENI, this parameter is required.
EcsInstance

Response parameters

ParameterTypeDescriptionExample
object
RequestIdstring

The ID of the request.

C44F62BE-9CE7-4277-B117-69243F3988BF

Examples

Sample success responses

JSONformat

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

Error codes

HTTP status codeError codeError messageDescription
400OperationUnsupported.BindOnFreeNetworkInterfaceThe network interface must be attached to an ECS instance.The ENI must be associated with an ECS instance.
400OperationUnsupported.BindMultipleTypeYou cannot bind HaVip to multiple instance types.You cannot associate the ECS instance and the ENI at the same time.
400OperationUnsupported.BindOnMultipleVswitchThe bound instance and HaVip must be on the same vSwitch.The instance to be associated and the HAVIP must belong to the same vSwitch.
400InvalidVip.Statusvip invalid status-
400IncorrectHaVipStatusHaVip 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.
400IncorrectInstanceStatusECS instance can be operated by this action only when it?s status is Running or Stopped.-
400CountLimitExceed.HaVipOnInstanceThe amount of HaVip associated with the specified Instance reach its limits.The number of HAVIPs has reached the upper limit.
400CountLimitExceeded.HaVipOnECSInstanceThe amount of Instance associated with the specified HaVip reach its limits.The number of HAVIPs has reached the upper limit.
400OperationFailed.DistibuteLockDistibute lock fail.The operation is locked by another request;
400InvalidNetworkInterfaceId.NotFoundThe network interface is not found.The ENI does not exist.
400OperationFailed.QueryNetworkInterfaceInfoFailed to query network interface information.The system failed to query ENI information.
400IllegalParam.InstanceTypeThe specified instance type is invalid. Only ECS instances and network interface are allowed.The type of the associated instance does not support this operation.
400OperationUnsupported.BindOnSameEcsYou cannot bind two network interfaces on the same ECS instance.You are not allowed to associate two ENIs of the same ECS instance.
400OperationUnsupported.HavipBindTypeYou cannot bind HAVIP to network interface in the specified region.You are not allowed to associate ENIs in the specified region.
400InvalidInstance.NotExistInvalidInstance.NotExist : The specified Instance does not exist in the specified region. i-bp136w25mhx503ptilrh\r\nRequestId : A961CC27-D797-4E16-B1B3-19B9ECBA1495-
400OperationDenied.BindOnSameEcsThe operation is not allowed because networkinterface bind on same instance.-
400Forbidden.HaVipNo 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.
400InvalidInstanceId.NotFoundThe specified Instance does not exist in the specified region.The instance does not exist in the region.
400ResourceNotFound.EcsInstanceThe specified resource of ECS instance is not found.-
404InvalidHaVip.ExisthaVip already bind exist.-
404InvalidRegionId.NotFoundThe RegionId provided does not exist in our records.The RegionId parameter is set to an invalid value. Specify a valid value and try again.
404InvalidHaVipId.NotFoundThe 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.
404QuotaExceeded.HaVipBindInstanceThe amount of instance associated with the specified haVip reach its limits.-

For a list of error codes, visit the Service error codes.

Change history

Change timeSummary of changesOperation
2023-11-20The Error code has changedView Change Details
2023-09-25The Error code has changedView Change Details
2023-08-03API Description Update. The Error code has changedView Change Details
2023-07-10The Error code has changedView Change Details