AllocatePublicIpAddress_云服务器 ECS_API文档

插件下载了解更多
VS Code 插件
安装插件之前,确保已安装 VS Code安装插件之前,确保已安装 VS Code
Alibaba Cloud Developer Toolkit is a collection of extensions that can help access Alibaba Cloud services in Visual Studio Code.
JetBrains 插件
安装插件之前,确保已安装 JetBrains IDE安装插件之前,确保已安装 JetBrains IDE
The Alibaba Cloud Developer Toolkit for JetBrains makes it easier to access Alibaba Cloud services.

接口说明

使用须知

  • 分配公网 IP 地址之前,实例必须处于运行中Running)或者已停止Stopped)状态。

  • 安全控制的实例的OperationLocks中标记了"LockReason" : "security"时,不能分配公网 IP 地址。

  • 调用该接口时请确保实例带宽大于 0,您可以调用 ModifyInstanceNetworkSpec 接口调整带宽。

注意事项

  • 仅白名单用户支持指定公网 IP 参数IpAddress,若公网带宽大于 0,您可以设置InstanceId进行随机分配;若公网带宽为 0,您需要调用 ModifyInstanceNetworkSpec 调整带宽之后再通过该接口分配。

  • 一台实例只能分配一个公网 IP 地址。如果实例已经拥有一个公网 IP 地址,将返回已绑定的公网 IP 地址IpAddress

  • 重启实例( RebootInstance )或者启动实例( StartInstance )后,新的公网 IP 地址生效。

除分配公网 IP 之外,您还可以给 VPC 类型 ECS 实例绑定弹性公网 IP(EIP)。更多信息,请参见 AssociateEipAddress

流控信息

请求速率为1000/60(s)。

授权信息

如下是此API对应的授权信息,用于RAM权限策略语句的Action元素中,为RAM用户或RAM角色授予调用此API的权限。请通过 RAM 访问控制设置,使用方法可参考访问控制帮助文档

具体说明如下:展开详情

操作访问级别资源类型条件关键字关联操作
ecs:AllocatePublicIpAddress
Create
Instance
acs:ecs:{#regionId}:{#accountId}:instance/{#instanceId}

请求参数

字段名称字段详情
InstanceIdstring

待分配 IP 地址的实例 ID。展开详情

示例值:i-bp1gtjxuuvwj17zr****参考取值来源:
    RunInstances
    StopInstances
    StartInstances
    CreateInstance
    RebootInstances
    DescribeInstances
    ModifyManagedInstance
    RenewReservedInstances
    DetachInstanceRamRole
    AttachInstanceRamRole
    DeregisterManagedInstance
    PurchaseReservedInstancesOffering
IpAddressstring

实例的公网 IP 地址。如果该参数值为空,则默认由系统随机分配 IP 地址。展开详情

示例值:112.124.**.**参考取值来源:
    AssignPrivateIpAddresses
VlanIdstring

实例的 VLAN ID。展开详情

示例值:720

返回参数

字段名称字段详情
IpAddressstring

实例的公网 IP 地址。

示例值:112.124.**.**
RequestIdstring

请求 ID。

示例值:473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E

返回示例

错误返回示例

错误码

全局错误码
HTTP 状态码错误码错误信息操作
400
InvalidOperation.AllocateFailed
The current instance failed to allocate public IP, please try again later.诊断
400
InvalidIpAddress.Malformed
The specified parameter "IpAddress" is not valid.诊断
400
OperationDenied
Specified operation is denied as your instance is in VPC.诊断
400
InsufficientPublicIp
Ip address not found.诊断
400
AllocateIpInvalidInstanceBandwidth
OperationDenied The InternetMaxBandwidthOut of the specified instance cannot be less than 0.诊断
400
OperationDenied.CloudboxNotSupport
This operation is denied, because the specified ECS instance which is in the Cloudbox dose not support PublicIp or Eip.诊断
400
OperationDenied.DedicatedRegionNotSupported
This operation is denied, because the specified ECS instance which is in the dedicated region dose not support PublicIp or Eip.诊断
403
IncorrectInstanceStatus
The current status of the resource does not support this operation.诊断
403
InstanceLockedForSecurity
The specified operation is denied as your instance is locked for security reasons.诊断
403
InstanceExpiredOrInArrears
The specified operation is denied as your prepay instance is expired (prepay mode) or in arrears (afterpay mode).诊断
403
IpInUse
The specified IP is already in use.诊断
403
AllocatedAlready
There is an IpAddress allocated already for the specified instance.诊断
403
AllocateIp.Fail
The specified instance fails to allocate ip, please try again.诊断
403
NAT_PUBLIC_IP_BINDING_FAILED
Binding nat public ip failed.诊断
403
NAT_PUBLIC_IP_ALLOCATE_FAILED
Nat public ip binding failed.诊断
403
InvalidIpAddress.NotPublic
The specified IP is not public address.诊断
404
InvalidInstanceId.NotFound
The specified InstanceId does not exist.诊断
404
InvalidVlanId.NotFound
The VlanId provided does not exist in our records.诊断
404
InvalidIpAddress.NotFound
The specified IP is not in the specified vlan.诊断
500
InternalError
The request processing has failed due to some unknown error.诊断

变更历史

变更时间变更内容概要操作
2023-10-10
变更错误码400
2023-01-04
新增错误码500

相关示例