All Products
Search
Document Center

Elastic IP Address:AssociateEipAddress

最終更新日:Nov 14, 2024

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

Operation description

  • You can associate an EIP with an Elastic Compute Service (ECS) instance, a Classic Load Balancer (CLB) instance, a secondary elastic network interface (ENI), a NAT gateway, or a high-availability virtual IP address (HAVIP) in the same region. The ECS instance and CLB instance must be deployed in a virtual private cloud (VPC).

  • AssociateEipAddress is an asynchronous operation. After you send a request, the system returns a request ID and runs the task in the background. You can call the DescribeEipAddresses operation to query the status of the task.

    • If the EIP is in the Associating state, the EIP is being associated. In this state, you can only query the EIP and cannot perform other operations.
    • If the EIP is in the InUse state, the EIP is associated.
  • You cannot call the AssociateEipAddress operation to associate an EIP with multiple instances at a time.

Debugging

You can run this interface directly in OpenAPI Explorer, saving you the trouble of calculating signatures. After running successfully, OpenAPI Explorer can automatically generate SDK code samples.

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:AssociateEipAddressupdate
  • 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

ParameterTypeRequiredDescriptionExample
RegionIdstringYes

The ID of the region to which the EIP belongs.

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

cn-hangzhou
AllocationIdstringYes

The ID of the EIP that you want to associate with an instance.

eip-2zeerraiwb7ujsxdc****
InstanceIdstringYes

The ID of the instance with which you want to associate the EIP.

You can enter the ID of a NAT gateway, CLB instance, ECS instance, secondary ENI, HAVIP, or IP address.

i-2zebb08phyczzawe****
InstanceTypestringNo

The type of the instance with which you want to associate the EIP. Valid values:

  • Nat: NAT gateway
  • SlbInstance: CLB instance
  • EcsInstance (default): ECS instance
  • NetworkInterface: secondary ENI
  • HaVip: HAVIP
  • IpAddress: IP address
Note The default value is EcsInstance. If the instance with which you want to associate the EIP is not an ECS instance, this parameter is required.
EcsInstance
InstanceRegionIdstringNo

The ID of the region in which the instance with which you want to associate the EIP resides.

Note This parameter is required only when the EIP is added to a shared Global Accelerator (GA) instance.
cn-hangzhou
PrivateIpAddressstringNo

The IP address in the CIDR block of the vSwitch.

If you leave this parameter empty, the system allocates a private IP address based on the VPC ID and vSwitch ID.

192.168.XX.XX
ModestringNo

The association mode. Valid values:

  • NAT (default): NAT mode
  • MULTI_BINDED: multi-EIP-to-ENI mode
  • BINDED: cut-network interface controller mode
Note This parameter is required only when InstanceType is set to NetworkInterface.
NAT
VpcIdstringNo

The ID of the VPC in which an IPv4 gateway is created. The VPC and the EIP must be in the same region.

When you associate an EIP with an IP address, the system can enable the IP address to access the Internet based on VPC route configurations.

Note This parameter is required if InstanceType is set to IpAddress, which indicates that the EIP is to be associated with an IP address.
vpc-257gqcdfvx6n****
ClientTokenstringNo

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

You can use the client to generate a 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 request ID as the client token. The request ID may be different for each request.
0c593ea1-3bea-11e9-b96b-88e9fe63****

Response parameters

ParameterTypeDescriptionExample
object

The response parameters.

RequestIdstring

The request ID.

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

Examples

Sample success responses

JSONformat

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

Error codes

HTTP status codeError codeError messageDescription
400InvalidAssociation.DuplicatedSpecified instance already is associated.An EIP or a GA instance is already associated with the specified instance. You must disassociate the EIP or GA instance from the specified instance before you can perform the operation.
400OperationDeniedSpecified instance is not in VPC.The specified instance does not exist in the VPC.
400InvalidParameter.MismatchSpecified elastic IP address and ECS instance are not in the same region.The EIP and ECS instance do not belong to the same region.
400IncorrectEipStatusCurrent elastic IP status does not support this operationThe status of the EIP does not support the operation.
400IncorrectInstanceStatusCurrent instance status does not support this operation.This operation cannot be performed while the instance is in the current state.
400InvalidInstanceType.ValueNotSupportedThe specified value of InstanceType is not supported.InstanceType is set to an invalid value.
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.
400InvalidParameterThe specified parameter is not valid.The parameter is set to an invalid value.
400OperationDeniedEip of default vpc not allow this operationThe operation is not supported by EIPs in a default VPC.
400TaskConflictThe eip operate too frequent, TaskConflict.Operations are too frequent and tasks conflict with each other.
400InvalidBindingStatusThe eip binding status invalid.The EIP is in an invalid state.
400BIND_INSTANCE_HAVE_PORTMAP_OR_BIND_EIPThe instance may have portMap or already bind eip.A port forwarding rule is configured for the ECS instance. Delete the port forwarding rule and try again.
400EIP_CAN_NOT_ASSOCIATE_WITH_PUBLIC_IPinstance already bind natpublicip,cannot bind eip.-
400BIND_INSTANCE_OWENER_ERRORCannot operate the eip.You are unauthorized to manage the specified EIP.
400NATGATEWAY_FINANCIALLOCKEDThe NatGateway has expire, cannot do bind operation.-
400InvalidParameter.InstanceTypeNotSupportThe specified instance type is not support.-
400QuotaExceeded.NumberOfTrafficEipThe number of traffic eip on natgw exceed limitation.-
400QuotaExceeded.NumberOfEipBinded eip Quota exceed on this NatGw.The number of EIPs associated with the NAT gateway exceeds the upper limit.
400Forbidden.EipCanNotBindGatgwEip can not bind on natgw.-
400InvalidAction.DeniedAction is denied due to unfinished Eip configuration modification.The EIP configurations are not complete and the operation is denied.
400InstanceType.NotSupportThe instance type is invalid.-
400InvalidParams.NotFoundinstance not foundThe specified instance does not exist.
400BindInstance.NotSupportedbind instance type %s is not supported.-
400Forbidden.InstanceBandwidthNotZeroEip can not bind with instance when it's bandwidth is not zero.-
400INSTANCE_TYPE_NOT_SUPPORTThe instance type is invalid.-
400ServerRegion.InvalidEip bind remote server region invalid.-
400Eni.AttachedThe 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.
400Eni.HasSubIpEni has sub ip can not bind direct eip.-
400Invalid.DirectEip.BindTypeThe direct eip can be only associated with eni.-
400InvalidStatus.EcsStatusNotSupportThe special instance status is not support operate-
400Invalid.Function.NotSupportedMulti-IP function is under test, the region or uid is not supported.-
400InvalidStatus.EniStatusNotSupport%s-
400InvalidParameter.EniInstanceId%s-
400InvalidNexthop.DirectEniThe direct Eni cannot be nexthop.An ENI in cut-through mode cannot be specified as a next hop.
400Mode.ConflictThe eni can bind only one mode of eip.-
400Mode.NotSupportThe user cannot use multi direct eip.-
400QuotaExceed.MultiBindedEipThe number of multi binded eip is over limit.-
400InvalidEIPStatus.BizDisabledThe EIP has been locked.The error message returned because the EIP is locked.
400OperationFailed.EniSubIpEni has sub ip can not bind direct eip.-
400InvalidEip.EipQuotaExceededThe specified eni assigned eip is more than privateIp.-
400OperationFailed.QueryCommodityInfoOperation failed because quey commodity info error.-
400OperationUnsupported.MultiIpMulti ip function is not support.-
400InvalidNicOrVm.NotFoundBind nic or vm not exist.The bound NIC or VM does not exist.
400OperationUnsupported.EipBindModelThe instance type of ecs does not support MULTI_BINDED model Eip.-
400IncorrectStatus.NatGateway%s-
400EipBindRemote.BackendRegionMustBeSingleeip bind remote instance, backend region must be single-
400InvalidParameter.BindingInstanceRegionThe specified BindingInstanceRegion is not supported.-
400OperationFailed.HavipBoundPortmap%s-
400IllegalParam.Mode%s-
400InvalidStatus.NotAllowBind instance status invalidThe status of the associated instance is invalid.
400InvalidInstance.NotExistBind instance data not exist-
400InvalidBandwidthPackageId.NotFoundThe specified BandwidthPackageId not exist.-
400ResourceQueryErrorThe specified resource is queried error.An error occurred while querying the specified resource.
400InvalidStatus.InstanceHasBandWidthThe specified instance bandwidth invalid.-
400OperationDenied.CloudBoxResourceExistThe 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.
400OperationDenied.CloudBoxVSwitchExistThe 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.
400OperationDenied.NoAvailablePrivateIpThe operation is failed because of vSwitch has not availalbe private ipThe vSwitch does not have sufficient private IP addresses.
400UnsupportedRegion%s-
400ResourceAlreadyAssociated.IpAddress%s-
400OperationFailed.Ipv4GatewayNotOpenedInVpcThe 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.
400OperationFailed.Ipv4GatewayNotActivatedInVpcThe operation is failed because Ipv4Gateway is not activated in Vpc.-
400OperationDenied.L2EipBindIpAddress%s-
400ForbiddenThe eip instance owner errorThe EIP does not belong to your account. Check whether you are authorized to perform the operation on the EIP.
400Forbidden.FinancialLockedThe ip business status is invalid.The error message returned because the instance has overdue payments.
400UnsupportedFeature.EipBindIpAddressThe feature of EipBindIpAddress is not supported.The error message returned because the EIP does not support the IpAddress parameter.
400OperationFailed.InstanceNotExistThe 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.
400OperationDenied.Ipv4GatewayExistThe operation is not allowed because of Ipv4GatewayExist.The EIP failed to be associated because IPv4 gateways exist in the VPC.
400OperationFailed.EipBindModeConflictEips can not bind Eni with NAT mode and MULTI_BINDED mode at the same time.The error message returned because you cannot associate an EIP with an ENI in NAT mode and multi-EIP-to-ENI mode at the same time.
400OperationFailed.EcsMigratingThe operation is failed because of ECS is migrating.The error message returned because the ECS instance is being migrated.
400OperationFailed.IpPrefixConflictThe operation failed due to the IP prefix of the ENI.The operation conflicts with the IP address prefix of the ENI.
400UnsupportedFeature.EipBindPrefixIpThe feature of EipBindPrefixIp is not supported.You cannot associate an EIP with a prefix list in the current region.
400OperationDenied.UnsupportedEipBindModeThe 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.
400OperationDenied.UnauthorizedThe operation is not allowed because the user is not in the whitelist.The operation is not allowed because you are not in the whitelist.
400OperationFailed.SystemBusyOperation failed because system is busy.The error message returned because the system is busy. Try again later.
404InvalidAllocationId.NotFoundSpecified allocation ID is not found.The error message returned because the specified EIP does not exist. Check whether the value of the parameter is valid.
404InvalidInstanId.NotFoundSpecified instance does not exist.The specified instance does not exist.
404InvalidRegionId.NotFoundSpecified value of InstanceRegionId is not supported.-
404InvalidAllocationId.NotFoundSpecified allocation ID is not foundThe specified EIP does not exist. Check whether the specified value is valid.
404Forbidden.RegionNotFoundSpecified instance is not found during access authentication.The error message returned because the region is not supported.
404OperationDenied.VpcIpv4GatewayEnabledThe 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.
503ServiceUnavailableThe request has failed due to a temporary failure of the server.The request failed due to a temporary server error.

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

Change history

Change timeSummary of changesOperation
2024-09-25The Error code has changedView Change Details
2023-12-13The Error code has changedView Change Details
2023-08-24API Description Update. The Error code has changedView Change Details
2023-06-26The Error code has changedView Change Details
2023-03-23The Error code has changedView Change Details