AllocatePublicIpAddress

Last Updated: Sep 13, 2017

Description

This operation allows you to assign an available Internet IP address to a given instance. When allocating Internet IP addresses, consider the following:

  • For the APIs for Elastic IP (EIP) addresses, refer to Query the list of EIPs.
  • This interface can only be invoked when the instance is in Running or Stopped status.
  • The allocated IP address only takes effect after the instance is started or restarted.
  • You can only assign an IP, not an IP segment.
  • Only one IP address can be allocated to one instance. If the instance already has an Internet IP address, when the interface is invoked, the original IP address is directly returned.
  • If OperationLocks of the instance indicates LockReason: security, the Internet IP address cannot be assigned.

Request parameters

Name Type Required Description
Action String Yes To allocate and Internet IP. Value: AllocatePublicIpAddress.
InstanceId String Yes Indicates the ID of the instance to be assigned an Internet IP address.

Return parameters

Name Type Description
IpAddress String Indicates the assigned Internet IP address.

Error code

Error code Description HTTP status codeHttp Meaning
MissingParameter The input parameter InstanceId that is mandatory for processing this request is not supplied. 400 The InstanceId value is missing.
AllocatedAlready There is an IpAddress allocated already for the specified instance. 403 When the user attempts to bind the specified IP address, it is found that another IP address has been assigned to the instance.
IncorrectInstanceStatus The current status of the resource does not support this operation. 403 The current status of the resource does not support this operation.
InstanceExpiredOrInArrears The specified operation is denied as your prepay instance is expired (prepay mode) or in arrears (afterpay mode). 403 The instance expires (on a yearly or monthly basis) or is in overdue payment (based on traffic).
InstanceLockedForSecurity The specified operation is denied as your instance is locked for security reasons. 403 The operation is denied because the resource is locked for security reasons.
IpInUse The specified IP is already in use. 403 When the user attempts to bind the specified IP address, it is found that the specified IP address is already in use elsewhere.
InvalidInstanceId.NotFound The specified InstanceId does not exist. 404 The specified InstanceId does not exist.

Examples

Request example

  1. https://ecs.aliyuncs.com/?Action=AllocatePublicIpAddress
  2. &InstanceId=i-instance1
  3. &<Public Request Parameters>

Return example

XML format

  1. <AllocatePublicIpAddressResponse>
  2. <RequestId>F2EF6A3B-E345-46B9-931E-0EA094818567</RequestId>
  3. <IpAddress>10.1.149.159</IpAddress>
  4. </AllocatePublicIpAddressResponse>

JSON format

  1. {
  2. "RequestId": "F2EF6A3B-E345-46B9-931E-0EA094818567",
  3. "IpAddress": "10.1.149.159"
  4. }
Thank you! We've received your feedback.