All Products
Search
Document Center

Elastic IP Address:AssociateEipAddress

Last Updated:Jul 10, 2026

Associates an elastic IP address (EIP) with a cloud resource instance in the same region.

Operation description

  • An EIP can be associated with a virtual private cloud (VPC)-type ECS instance, a VPC-type CLB instance, a secondary elastic network interface (ENI), an Internet NAT gateway, or a high-availability virtual IP address (HAVIP) in the same region.

  • The AssociateEipAddress operation is asynchronous. After you send a request, the system returns a request ID, but the association between the EIP and the cloud resource instance is not yet complete. The association task continues to run in the background. You can invoke DescribeEipAddresses to query the status of the EIP:

    • If the EIP is in the Associating state, the EIP is being associated. In this state, you can only execute query operations.

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

  • The AssociateEipAddress operation does not support concurrent requests to associate the same EIP with cloud resource instances.

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

update

*Address

acs:vpc:{#regionId}:{#accountId}:eip/{#AllocationId}

NatGateway

acs:vpc:{#regionId}:{#accountId}:natgateway/{#NatGatewayId}

Instance

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

Association

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

None None

Request parameters

Parameter

Type

Required

Description

Example

RegionId

string

No

The region ID of the EIP to be associated with a cloud resource instance.

You can call the DescribeRegions operation to query the region ID.

cn-hangzhou

AllocationId

string

Yes

The ID of the EIP to be associated with a cloud resource instance.

eip-2zeerraiwb7ujsxdc****

InstanceId

string

Yes

The instance ID of the instance to be associated with the EIP.

You can enter the instance ID of an Internet NAT gateway, a Classic Load Balancer (CLB) instance, an ECS instance, a secondary elastic network interface (ENI), a high-availability virtual IP address (HAVIP), or an IP address.

i-2zebb08phyczzawe****

InstanceType

string

No

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

  • Nat: Internet NAT gateway.

  • SlbInstance: Classic Load Balancer (CLB).

  • EcsInstance (default): Elastic Compute Service (ECS).

  • NetworkInterface: secondary elastic network interface (ENI).

  • HaVip: high-availability virtual IP address.

  • IpAddress: IP address.

Note

The default instance type is EcsInstance. If the instance type is not EcsInstance, this parameter is required.

EcsInstance

InstanceRegionId

string

No

The region ID of the instance to be associated with the EIP.

Note

This parameter is required only after the EIP is added to a shared-bandwidth Alibaba Cloud Global Accelerator (GA) instance.

cn-hangzhou

PrivateIpAddress

string

No

An IP address in the vSwitch CIDR block.

If you do not specify this parameter, the system automatically assigns a private IP address based on the VPC ID and vSwitch ID.

Note

If InstanceType is set to NetworkInterface, this parameter is required. Enter the private IP address to be associated.

192.168.XX.XX

Mode

string

No

The association mode. Valid values:

  • NAT (default): NAT mode (standard mode).

  • MULTI_BINDED: multi-EIP-to-ENI mode.

  • BINDED: EIP-to-ENI mode.

Note

This parameter is required only when InstanceType is set to NetworkInterface.

NAT

VpcId

string

No

The ID of the VPC that has the IPv4 gateway feature enabled and is in the same region as the EIP.

When the EIP is associated with an IP address, the system uses the routing configuration of this VPC to enable public network access for the associated IP address.

Note

This parameter is required when InstanceType is set to IpAddress.

vpc-257gqcdfvx6n****

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 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 may be different for each API request.

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

Response elements

Element

Type

Description

Example

object

The response parameters.

RequestId

string

The request ID.

0ED8D006-F706-4D23-88ED-E11ED28DCAC0

Examples

Success response

JSON format

{
  "RequestId": "0ED8D006-F706-4D23-88ED-E11ED28DCAC0"
}

Error codes

HTTP status code

Error code

Error message

Description

400 InvalidAssociation.Duplicated Specified instance already is associated.
400 OperationDenied Specified instance is not in VPC.
400 InvalidParameter.Mismatch Specified elastic IP address and ECS instance are not in the same region.
400 IncorrectEipStatus Current elastic IP status does not support this operation
400 IncorrectInstanceStatus Current instance status does not support this operation.
400 InvalidInstanceType.ValueNotSupported The specified value of InstanceType is not supported.
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 InvalidParameter The specified parameter is not valid.
400 InvalidBindingStatus The eip binding status invalid.
400 BIND_INSTANCE_HAVE_PORTMAP_OR_BIND_EIP The instance may have portMap or already bind eip. The ECS instance already has a port forwarding rule (DNAT). Delete the corresponding port forwarding rule before performing the operation.
400 EIP_CAN_NOT_ASSOCIATE_WITH_PUBLIC_IP instance already bind natpublicip,cannot bind eip.
400 BIND_INSTANCE_OWENER_ERROR Cannot operate the eip.
400 NATGATEWAY_FINANCIALLOCKED The NatGateway has expire, cannot do bind operation.
400 InvalidParameter.InstanceTypeNotSupport The specified instance type is not support.
400 QuotaExceeded.NumberOfTrafficEip The number of traffic eip on natgw exceed limitation.
400 QuotaExceeded.NumberOfEip Binded eip Quota exceed on this NatGw. The number of EIPs associated with the NAT gateway exceeds the upper limit.
400 Forbidden.EipCanNotBindGatgw Eip can not bind on natgw.
400 InvalidAction.Denied Action is denied due to unfinished Eip configuration modification. The EIP configurations are not complete and the operation is denied.
400 InstanceType.NotSupport The instance type is invalid.
400 InvalidParams.NotFound instance not found
400 BindInstance.NotSupported bind instance type %s is not supported.
400 Forbidden.InstanceBandwidthNotZero Eip can not bind with instance when it's bandwidth is not zero.
400 INSTANCE_TYPE_NOT_SUPPORT The instance type is invalid.
400 ServerRegion.Invalid Eip bind remote server region invalid.
400 Eni.Attached The eni should be detached from ecs when associating with direct eip. If the ENI is associated with an EIP in cut-through mode, you must disassociate the ENI from the ECS instance.
400 Eni.HasSubIp Eni has sub ip can not bind direct eip.
400 Invalid.DirectEip.BindType The direct eip can be only associated with eni.
400 InvalidStatus.EcsStatusNotSupport The special instance status is not support operate
400 Invalid.Function.NotSupported Multi-IP function is under test, the region or uid is not supported.
400 InvalidStatus.EniStatusNotSupport %s
400 InvalidParameter.EniInstanceId %s
400 InvalidNexthop.DirectEni The direct Eni cannot be nexthop. An ENI in cut-through mode cannot be specified as a next hop.
400 Mode.Conflict The eni can bind only one mode of eip.
400 Mode.NotSupport The user cannot use multi direct eip.
400 QuotaExceed.MultiBindedEip The number of multi binded eip is over limit. the number of multi-passthrough mode eips that can be bound exceeds the limit.
400 InvalidEIPStatus.BizDisabled The EIP has been locked. The error message returned because the EIP is locked.
400 OperationFailed.EniSubIp Eni has sub ip can not bind direct eip.
400 InvalidEip.EipQuotaExceeded The specified eni assigned eip is more than privateIp.
400 OperationUnsupported.MultiIp Multi ip function is not support.
400 InvalidNicOrVm.NotFound Bind nic or vm not exist. The bound NIC or VM does not exist.
400 OperationUnsupported.EipBindModel The instance type of ecs does not support MULTI_BINDED model Eip.
400 IncorrectStatus.NatGateway %s
400 EipBindRemote.BackendRegionMustBeSingle eip bind remote instance, backend region must be single
400 InvalidParameter.BindingInstanceRegion The specified BindingInstanceRegion is not supported.
400 OperationFailed.HavipBoundPortmap %s
400 IllegalParam.Mode %s
400 InvalidStatus.NotAllow Bind instance status invalid The status of the associated instance is invalid.
400 InvalidInstance.NotExist Bind instance data not exist
400 InvalidBandwidthPackageId.NotFound The specified BandwidthPackageId not exist.
400 InvalidStatus.InstanceHasBandWidth The specified instance bandwidth invalid.
400 OperationDenied.CloudBoxResourceExist The operation is not allowed because there are resources related to the cloud box in VPC. The operation is not allowed because CloudBox-related resources exist in the VPC.
400 OperationDenied.CloudBoxVSwitchExist The operation is not allowed because a cloud box type vSwitch exists in VPC. The operation is not allowed because vSwitches of the CloudBox type exist in the VPC.
400 OperationDenied.NoAvailablePrivateIp The operation is failed because of vSwitch has not availalbe private ip The vSwitch does not have sufficient private IP addresses.
400 ResourceAlreadyAssociated.IpAddress %s
400 OperationFailed.Ipv4GatewayNotOpenedInVpc The operation is failed because Ipv4Gateway is not opened in Vpc. The error message returned because the VPC does not have IPv4 gateways enabled and the IP address failed to be associated with the EIP.
400 OperationFailed.Ipv4GatewayNotActivatedInVpc The operation is failed because Ipv4Gateway is not activated in Vpc.
400 OperationDenied.L2EipBindIpAddress %s
400 Forbidden The eip instance owner error The EIP does not belong to your account. Check whether you are authorized to perform the operation on the EIP.
400 Forbidden.FinancialLocked The ip business status is invalid. The error message returned because the instance has overdue payments.
400 UnsupportedFeature.EipBindIpAddress The feature of EipBindIpAddress is not supported. The error message returned because the EIP does not support the IpAddress parameter.
400 OperationFailed.InstanceNotExist The ECS instance does not exist, or is not a VPC VM. The EIP failed to be associated with the ECS instance because the ECS instance does not exist or is not a VPC virtual machine.
400 OperationDenied.Ipv4GatewayExist The operation is not allowed because of Ipv4GatewayExist.
400 OperationFailed.EipBindModeConflict Eips can not bind Eni with NAT mode and MULTI_BINDED mode at the same time.
400 OperationFailed.EcsMigrating The operation is failed because of ECS is migrating.
400 OperationFailed.IpPrefixConflict The operation failed due to the IP prefix of the ENI. The operation conflicts with the IP address prefix of the ENI.
400 UnsupportedFeature.EipBindPrefixIp The feature of EipBindPrefixIp is not supported. You cannot associate an EIP with a prefix list in the current region.
400 OperationDenied.UnsupportedEipBindMode The operation is not supported for the NAT gateway due to its EIP binding mode. The operation is not supported by the EIP binding mode of the NAT gateway.
400 OperationDenied.Unauthorized The operation is not allowed because the user is not in the whitelist. The operation is not allowed because you are not in the whitelist.
400 OperationFailed.SystemBusy Operation failed because system is busy. The error message returned because the system is busy. Try again later.
400 OperationFailed.PrivateIpAddressNotExist The operation failed because the PrivateIpAddress is not found. The specified private IP address is invalid.
400 IllegalParamFormat.%s The param format of %s is illegal. The parameter mode is invalid.
400 MissingParam.InstanceId The param of InstanceId can't be null or empty. InstanceId cannot be empty
400 InvalidEniType.SlaveEni The eni type cannot be slave eni. The ENI type cannot be a secondary ENI.
400 IllegalParam.PrivateIpAddress The specified PrivateIpAddress is illegal. The specified PrivateIpAddress is invalid. Check the parameter constraints and try again after modification.
400 OperationFailed.Ipv4GatewayNotAssociatedWithGatewayRouteTable The operation failed because the specified IPv4 gateway of the VPC is not associated with any gateway route table. The operation failed because the specified IPv4 gateway of the VPC is not associated with any gateway route table.
404 InvalidAllocationId.NotFound Specified allocation ID is not found.
404 InvalidInstanId.NotFound Specified instance does not exist.
404 Forbidden.RegionNotFound Specified instance is not found during access authentication. The error message returned because the region is not supported.
404 OperationDenied.VpcIpv4GatewayEnabled The operation is not allowed because of the VPC of the NAT gateway has opened IPv4 Gateway. IPv4 gateways are enabled for the VPC where the NAT gateway resides and the operation is denied.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.