You need to enable JavaScript to run this app.
文档中心
云服务器

云服务器

复制全文
下载 pdf
实例
ModifyInstanceVpcAttribute - 修改实例VPC信息
复制全文
下载 pdf
ModifyInstanceVpcAttribute - 修改实例VPC信息
调用 ModifyInstanceVpcAttribute 接口修改一台实例的VPC、子网或安全组。​
注意事项​
调用该接口时,目标实例与VPC需满足的条件请参见更换私有网络或子网。​
请求说明​
该接口常见操作场景大致如下:​
  • VPC变更场景:VPC变更与子网、安全组更换是强绑定操作,当传入新的VpcId时,必须同时指定子网和安全组参数。​
  • 非VPC变更场景:不传入VpcId则表示不更换私有网络,但可以仅更换子网,或者更换子网和安全组。​
说明​
子网改变的情况下才可以更换安全组,该接口中的SubnetId为必填,且取值必须为新的子网ID。​
调试​
API Explorer
您可以通过 API Explorer 在线发起调用,无需关注签名生成过程,快速获取调用结果。
​
请求参数​
下表仅列出该接口特有的请求参数和部分公共参数。更多信息请见公共参数。​
Action string 必选 示例值:ModifyInstanceVpcAttribute​
要执行的操作,取值:ModifyInstanceVpcAttribute。​
​
Version string 必选 示例值:2020-04-01​
API的版本,取值:2020-04-01。​
​
ClientToken string 可选 示例值:333456899ff****​
保证请求幂等性。由客户端自动生成一个参数值,确保不同请求间该参数值唯一,避免当调用API超时或服务器内部错误时,客户端多次重试导致重复性操作。​
取值:仅支持ASCII字符,且不能超过64个字符。​
​
InstanceId string 必选 示例值:i-bp1iudwa5b1tqag1****​
实例ID。​
​
PrimaryIpAddress string 可选 示例值:172.17.XX.XX​
新的主私网IP地址,必须在子网网段中。​
  • 不传入该参数时,将从子网网段中随机分配。​
​
SecurityGroupIds.N string[] 可选 示例值:SecurityGroupIds.1=sg-33gf6al0psvsw1pz2ij8e****&SecurityGroupIds.2=sg-o6w9l8bc8dgmkw87****​
实例修改VPC后加入的安全组ID。​
  • 参数 - N:表示安全组的序号,取值范围:1~5。​
  • 多个安全组 ID之间用&分隔。​
说明​
  • 当且仅当传入VpcId时,需要同时传入该参数。​
​
SubnetId string 必选 示例值:subnet-33gf6b2rztdkw1pz2ijvq****​
新的子网ID。​
  • 不支持传入实例当前所在子网ID。​
  • VpcId为空时,新的子网与原子网必须属于同一可用区、同一VPC。您可以调用DescribeSubnets查询目标VPC下与原子网处于同一可用区的子网ID。​
  • VpcId不为空时,该参数传入的子网ID必须属于该VPC,并且和原子网属于同一可用区。​
​
VpcId string 可选 示例值:vpc-33gf6af3mgpvk1pz2ijlf****​
目标VPC ID。​
  • 不传入该参数时,表示在同一VPC下更换子网。​
  • 您可以调用DescribeVpcs查询与实例处于同一地域的可用VPC。​
​
​
​
返回参数​
下表仅列出本接口特有的返回参数。更多信息请参见返回结构。​
NetworkInterfaceId string 示例值:eni-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: ecs.cn-beijing.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****"​
}​
}​
​
错误码​
下表为您列举了该接口与业务逻辑相关的错误码。公共错误码请参见公共错误码文档。​
​
状态码​
错误码​
错误信息​
说明​
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.​
幂等参数不一致。​
400​
Insufficient.Balance​
The request is denied due to the lack of balance.​
账户余额不足。​
400​
InvalidArgument​
The specified argument is invalid.​
指定的参数不合法。​
400​
InvalidClientToken.Malformed​
The specified ClientToken is malformed.​
指定的ClientToken不合法。​
400​
InvalidInstanceStatus​
The status of the specified instance does not support this request.​
当前实例的状态不支持此操作。​
400​
InvalidIp​
The specified ip is not valid, is unsupported, or cannot be used.​
指定的IP地址不合法。​
400​
InvalidSecurityGroupType.Malformed​
The specified SecurityGroupType is malformed.​
指定的安全组类型不合法。​
400​
InvalidSubnet.VpcMismatch​
The specified subnet is not in the specified VPC.​
指定的子网不在指定的VPC中。​
400​
LimitExceeded.MaximumSubnetIps​
The number of specified subnet IP addresses exceeds the maximum limit.​
指定子网的IP地址数量已经达到最大限制。​
400​
MissingParameter.InstanceId​
The required parameter InstanceId is not supplied.​
参数实例ID不能为空。​
400​
MissingParameter.SecurityGroupIds​
The required parameter SecurityGroupIds is not supplied.​
安全组ID不能为空。​
400​
MissingParameter.SubnetId​
The required parameter SubnetId is not supplied.​
子网ID不能为空。​
400​
QuotaExceeded.MaximumSecurityGroupNetworkInterfaces​
You've reached the limit on the number of SecurityGroupEnis that you can create, please submit ticket to request an increase in quota.​
安全组关联的网卡数配额不足,请提工单申请提高配额。​
400​
QuotaExceeded.MaximumSecurityGroups​
You've reached the limit on the number of SecurityGroups that you can create, please submit ticket to request an increase in quota.​
安全组配额不足,请提工单申请提高配额。​
404​
InvalidInstance.EniNotFound​
The specified instance ENI not found.​
指定的实例网卡不存在。​
404​
InvalidInstance.NotFound​
The specified instance does not exist.​
指定的实例不存在。​
404​
InvalidSecurityGroup.NotFound​
The specified SecurityGroup does not exist.​
指定的安全组不存在。​
404​
InvalidSubnet.NotFound​
The specified subnet does not exist.​
指定的子网不存在。​
404​
InvalidVpc.NotFound​
The specified VPC does not exist.​
指定的VPC不存在。​
409​
InvalidPrimaryIpAddress.Conflict​
The specified PrimaryIpAddress already exists.​
指定的PrimaryIpAddress已存在。​
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.​
指定实例已在目标子网中。​
412​
IdempotentProcessing​
The request uses the same client token as a previous one that is still in process.​
先前的幂等请求仍在处理中,请稍后重试。​
412​
InvalidInstance.DependenceAnycastEipExit​
The specified instance has a dependency on anycast elastic ip.​
指定的实例与任播公网IP有依赖,无法响应该请求。​
412​
InvalidInstance.DependenceClbExit​
The specified instance has a dependency on CLB.​
指定的实例与CLB有依赖,无法响应该请求。​
412​
InvalidInstance.DependenceEipExit​
The specified instance has a dependency on elastic ip address in binded mode.​
指定的实例与EIP可见模式有依赖,无法响应该请求。​
412​
InvalidInstance.DependenceEniExist​
The specified instance has a dependency on elastic network interface.​
指定的实例与弹性网卡有依赖,无法响应该请求。​
412​
InvalidInstance.DependenceHaVipExist​
The specified instance has a dependency on HaVip.​
指定的实例与高可用虚拟IP有依赖,无法响应该请求。​
412​
InvalidInstance.DependenceIpv6Exit​
The specified instance has a dependency on IPv6 address.​
指定的实例与IPv6地址有依赖,无法响应该请求。​
412​
InvalidInstance.DependenceMultiPrivateIpExist​
The specified instance has a dependency on multiple private IP addresses.​
指定的实例与多个私网IP有依赖,无法响应该请求。​
412​
InvalidInstance.DependenceRouteEntryExist​
The specified instance has a dependency on custom route entry.​
指定的实例与自定义路由条目有依赖,无法响应该请求。​
412​
InvalidSecurityGroup.SubnetMismatch​
The specified SecurityGroup and Subnet do not match.​
安全组与子网的私有网络不匹配。​
412​
InvalidSubnet.ZoneMismatch​
The specified subnet and instance are in different Availability Zones.​
子网与实例不属于同一个可用区。​
412​
OperationDenied.ResourceLocked​
The specified operation is denied as your resource is locked for another operation.​
指定的操作被拒绝,因为您的资源已被其他操作锁定。​
412​
OperationDenied.SpecifiedSecurityGroupNotAuthorized​
You are not authorized to perform operations on the specified security group. The specified security group is a service-managed security group.​
用户无权对指定的安全组执行操作,指定的安全组是服务管理的安全组。​
500​
InternalError​
An internal error has occurred.​
内部错误,请重试。如果多次尝试失败,请提交工单。​
​
​
最近更新时间:2026.05.13 10:11:33
这个页面对您有帮助吗?
有用
有用
无用
无用