You need to enable JavaScript to run this app.
导航

ModifyInstanceVpcAttribute

最近更新时间2023.11.20 10:48:37

首次发布时间2023.07.19 15:23:09

调用 ModifyInstanceVpcAttribute 接口修改一台实例的VPC、子网或安全组。

说明

调用该接口时,目标实例与VPC需满足的条件请参见更换ECS的VPC

请求参数

名称类型是否必填示例值描述
ActionStringModifyInstanceVpcAttribute要执行的操作,取值:ModifyInstanceVpcAttribute。
VersionString2020-04-01API的版本,取值:2020-04-01。
InstanceIdStringi-bp1iudwa5b1tqag1****实例ID。

VpcId

String

vpc-33gf6af3mgpvk1pz2ijlf****

目标VPC ID,您可以调用DescribeVpcs查询与实例处于同一地域的可用VPC。

说明

不传入该参数则表示在同一VPC下更换子网,此时SecurityGroupIds.N也必须为空。

SubnetId

String

subnet-33gf6b2rztdkw1pz2ijvq****

新的子网ID,您可以调用DescribeSubnets查询目标VPC下与原子网处于同一可用区的子网ID。

说明

  • 不支持传入实例当前所在子网ID。

  • 传入新的子网ID且VpcId为空时,新旧子网必须属于同一可用区、同一VPC。

  • VpcId不为空时,该参数传入的子网ID必须属于该VPC,并且和原子网属于同一可用区。

SecurityGroupIds.N

String

SecurityGroupIds.1=sg-33gf6al0psvsw1pz2ij8e****&SecurityGroupIds.2=sg-o6w9l8bc8dgmkw87****

实例修改VPC后加入的安全组ID,您可以调用DescribeSecurityGroups查询安全组ID。

  • 参数 - N:表示安全组的序号,取值范围:1~5。

  • 多个安全组 ID之间用&分隔。

说明

当且仅当传入VpcId参数时,需要同时传入该参数。

PrimaryIpAddress

String

172.17.XX.XX

新的主私网IP地址,必须在子网网段中。您可以调用DescribeNetworkInterfaceAttributes查询网卡的主私网IP地址。

说明

不传入该参数时,将从子网网段中随机分配。

ClientToken

String

333456899ff****

保证请求幂等性。由客户端自动生成一个参数值,确保不同请求间该参数值唯一,避免当调用API超时或服务器内部错误时,客户端多次重试导致重复性操作。
取值:仅支持ASCII字符,且不能超过64个字符。

返回数据

名称类型示例值描述
NetworkInterfaceIdStringeni-3tiu4lmhwq4e8i4q****新创建的网卡ID。

请求示例

GET /?Action=ModifyInstanceVpcAttribute&Version=2020-04-01&InstanceId=i-ybuweywu4xk2c1x5****&SubnetId=subnet-33gf6b2rztdkw1pz2ijvq****&SecurityGroupIds.1=sg-33gf6al0psvsw1pz2ij8e****&VpcId=vpc-33gf6af3mgpvk1pz2ijlf**** HTTP/1.1
Host: open.volcengineapi.com
Region: cn-beijing
ServiceName: ecs

返回示例

{
    "ResponseMetadata": {
        "RequestId": "2021062415303301022514515207C4****",
        "Action": "ModifyInstanceVpcAttribute",
        "Version": "2020-04-01",
        "Service": "ecs",
        "Region": "cn-beijing"
    },
    "Result": {
        "NetworkInterfaceId": "eni-3tiu4lmhwq4e8i4q****"
    }
}

错误码

HttpCode错误码错误信息描述
400InvalidArgumentThe specified argument is invalid.指定的参数不合法。

400

InvalidInstanceStatus

The status of the specified instance does not support this request.

当前实例的状态不支持此操作。

400MissingParameter.InstanceIdThe required parameter InstanceId is not supplied.实例ID不能为空。
400MissingParameter.SecurityGroupIdsThe required parameter SecurityGroupIds is not supplied.安全组ID不能为空。
400MissingParameter.SubnetIdThe required parameter SubnetId is not supplied.子网ID不能为空。

400

LimitExceeded.MaximumSubnetIps

The number of specified subnet IP addresses exceeds the maximum limit.

指定子网的IP地址数量已经达到最大限制。

400QuotaExceeded.MaximumSecurityGroupsYou've reached the limit on the number of SecurityGroups that you can create, please submit ticket to request an increase in quota.安全组配额不足,请提工单申请提高配额。
400InvalidIpThe specified ip is not valid, is unsupported, or cannot be used.指定的IP地址不合法。

400

InvalidSecurityGroupType.Malformed

The specified SecurityGroupType is malformed.

指定的安全组类型不合法。

400QuotaExceeded.MaximumSecurityGroupNetworkInterfacesYou've reached the limit on the number of SecurityGroupEnis that you can create, please submit ticket to request an increase in quota.安全组关联的网卡数配额不足,请提工单申请提高配额。
400InvalidSubnet.VpcMismatchThe specified subnet is not in the specified VPC.指定的子网不在指定的VPC中。

400

IdempotentParameterMismatch

The request uses the same client token as a previous, but non-identical request. Do not reuse a client token with different requests, unless the requests are identical.

幂等参数不一致。

400InvalidClientToken.MalformedThe specified ClientToken is malformed.指定的ClientToken不合法。
404InvalidVpc.NotFoundThe specified VPC does not exist.指定的VPC不存在。

404

InvalidInstance.NotFound

The specified instance does not exist.

指定的实例不存在。

404InvalidInstance.EniNotFoundThe specified instance ENI not found.指定的实例网卡不存在。
404InvalidSecurityGroup.NotFoundThe specified SecurityGroup does not exist.指定的安全组不存在。
404InvalidSubnet.NotFoundThe specified subnet does not exist.指定的子网不存在。

409

InvalidSecurityGroupId.Conflict

The specified security group is duplicated with another security group associated with the same elastic network interface.

指定的安全组已关联至该网卡,无法重复绑定。

409

InvalidSubnet.Conflict

The specified instance already in target subnet.

指定的实例已在目标子网中。

409InvalidPrimaryIpAddress.ConflictThe specified PrimaryIpAddress already exists.指定的私网IP地址已存在。
412OperationDenied.ResourceLockedThe specified operation is denied as your resource is locked for another operation.指定的操作被拒绝,因为您的资源已被其他操作锁定。
412InvalidSecurityGroup.SubnetMismatchThe specified SecurityGroup and Subnet do not match.安全组与子网的私有网络不匹配。
412InvalidInstance.DependenceHaVipExistThe specified instance has a dependency on HaVip.指定的实例与高可用虚拟IP有依赖,无法响应该请求。
412InvalidInstance.DependenceRouteEntryExistThe specified instance has a dependency on custom route entry.指定的实例与自定义路由条目有依赖,无法响应该请求。
412InvalidInstance.DependenceEniExistThe specified instance has a dependency on elastic network interface.指定的实例与弹性网卡有依赖,无法响应该请求。

412

InvalidInstance.DependenceMultiPrivateIpExist

The specified instance has a dependency on private IP address.

指定的实例与多个私网IP有依赖,无法响应该请求。

412InvalidInstance.DependenceIpv6ExitThe specified instance has a dependency on IPv6 address.指定的实例与IPv6地址有依赖,无法响应该请求。
412InvalidInstance.DependenceClbExitThe specified instance has a dependency on CLB.指定的实例与CLB有依赖,无法响应该请求。
412InvalidInstance.DependenceEipExitThe specified instance has a dependency on elastic ip address in binded mode.指定的实例与EIP可见模式有依赖,无法响应该请求。
412InvalidSubnet.ZoneMismatchThe specified subnet and instance are in different Availability Zones.指定的子网与实例不属于同一可用区。
412InvalidInstance.DependenceAnycastEipExitThe specified instance has a dependency on anycast elastic IP.指定的实例与任播公网IP有依赖,无法响应该请求。
412IdempotentProcessingThe request uses the same client token as a previous one that is still in process.先前的幂等请求仍在处理中,请稍后重试。

500

InternalError

An internal error has occurred.

内部错误,请重试。如果多次尝试失败,请提交工单。