You can call this operation to connect 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 points:

  • The instance to be connected must be in the Running or Stopped state.
  • The ClassicLink service 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
InstanceId String Yes i-test

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

RegionId String Yes cn-hangzhou

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

VpcId String Yes vpc-test

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

Action String Yes AttachClassicLinkVpc

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

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-test
&VpcId=vpc-test
&<Common request parameters>

Sample success responses

XML format

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

JSON format

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

Error codes

HTTP status code 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 message returned because the instance cannot be connected to a VPC.
403 InvalidParameter.InvalidInstanceIdAndVpcId The parameter InstanceId and VpcId are not allowed to be empty at the same time. The error message returned because InstanceId and VpcId 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 instances do 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 the current state. The expected state is Running or Shutted.
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 the current state. The expected state is Running or Shutted.
403 InvalidInstanceId.NotBelong The specified instance is not belong to you. The error message returned because the specified instance does not exist under 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 a ClassicLink connection cannot be created for the instance due to the region limit.
403 Forbidden.SubUser User not authorized to operate on the specified resource. The error message returned because a RAM user is not authorized to perform operations on this resource.

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