Connects a classic network-type instance with a VPC. This way, the instance can communicate with cloud resources in the VPC through the internal network.

Description

When you call this operation, take note of the following items:

  • The instance to be connected must be in the Running state or Stopped state.
  • The ClassicLink feature must be enabled for the target VPC. For more information, see Enable ClassicLink.
  • The instance and the VPC must be in the same region.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes AttachClassicLinkVpc

The operation that you want to perform. Set the value to AttachClassicLinkVpc.

RegionId String Yes cn-hangzhou

The region ID of the instance. You can call the DescribeRegions operation to query the most recent region list.

InstanceId String Yes i-bp1gtjxuuvwj17zr****

The ID of the classic network-type instance. You can call the DescribeInstances operation to query available instances.

VpcId String Yes vpc-bp1j4z1sr8zxu4l8u****

The ID of the VPC for which the ClassicLink feature is enabled. You can call the DescribeVpcs operation to query available VPCs.

Response parameters

Parameter Type Example Description
RequestId String 473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E

The ID of the request.

Examples

Sample requests

https://ecs.aliyuncs.com/?Action=AttachClassicLinkVpc
&RegionId=cn-hangzhou
&InstanceId=i-bp1gtjxuuvwj17zr****
&VpcId=vpc-bp1j4z1sr8zxu4l8u****
&<Common request parameters>

Sample success responses

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<AttachClassicLinkVpcResponse>
    <RequestId>C0003E8B-B930-4F59-ADC0-0E209A9012A8</RequestId>
</AttachClassicLinkVpcResponse>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

{
  "RequestId" : "C0003E8B-B930-4F59-ADC0-0E209A9012A8"
}

Error codes

HttpCode Error code Error message Description
403 InvalidInstanceId.NotFound The InstanceId provided does not exist in our records. The error message returned because the specified InstanceId parameter does not exist. Check whether the instance ID is correct.
403 InvalidRegionId.Malformed The specified parameter ?RegionId? is not valid. The error message returned because the specified RegionId parameter is invalid.
403 InvalidVpcId.Malformed The specified parameter ?VpcId? is not valid. The error message returned because the specified VpcId parameter is invalid.
403 InvalidInstanceId.MalFormed The specified instance is not a classic network instance. The error returned because the specified instance is not in the classic network.
403 OperationDenied The instance does not allow link to vpc. The error returned because the instance is linked to another VPC.
403 InvalidParameter.InvalidInstanceIdAndVpcId The parameter InstanceId and VpcId are not allowed to be empty at the same time. The error message returned because the InstanceId and VpcId parameters cannot be empty at the same time.
403 OperationDenied The specified vpc is disabled attach classic link. The error message returned because ClassicLink cannot be enabled for the specified VPC.
403 InvalidInstanceId.NotFound The specified instance does not exist. The error message returned because the specified InstanceId parameter does not exist. Check whether the instance ID is correct.
403 InvalidStatus.InstanceStatus The specified instance status is not support this operation ,expect status is running or shutted. The error message returned because the operation is not supported while the instance is in its current state. The instance must be in the Running state or Stopped state.
403 InvalidStatus.InstanceStatus The specified instance status is not support this operation, expect status is running or shutted. The error message returned because the operation is not supported while the instance is in its current state. The instance must be in the Running state or Stopped state.
403 InvalidInstanceId.NotBelong The specified instance is not belong to you. The error message returned because the specified instance does not exist in your account.
403 QuotaExceeded The link quota exceeded in this vpc. The error message returned because the maximum number of links that can be created in the specified VPC has been reached.
403 InvalidStatus.InstanceLocked The specified instance is locked,please wait more. The error message returned because the specified instance is locked. Try again when the instance is unlocked.
403 InvalidInstanceId.LimitedRegion The specified instance does not support this operation due to the limitation of its region. The error message returned because ClassicLink connections cannot be established in the specified region due to lack of support.
403 Forbidden.SubUser User not authorized to operate on the specified resource. The error message returned because the RAM user is not authorized to manage the specified resource.

For a list of error codes, visit the API Error Center.