If the Elastic Compute Service (ECS) instance in a virtual private cloud (VPC) cannot access the Internet, you cannot call API operations on the ECS instance over the Internet. This topic describes how to call API operations over a VPC by modifying the endpoint field.

Background

VPC endpoints use public service addresses. If the ECS instance in your VPC cannot access the Internet, you cannot call API operations by using Alibaba Cloud CLI or SDKs. For more information about VPC endpoints, see Call VPC APIs.

You can call API operations over a VPC by modifying the endpoint field. The following table lists the available endpoints when you call API operations over a VPC. Make sure that you use an endpoint listed in the table.
Note To call API operations over a VPC, the region of the VPC-connected ECS instance must be the same as that of the endpoint. Cross-region operations are not supported.
Alibaba Cloud region Region ID Endpoint
China (Hangzhou) cn-hangzhou vpc-vpc.cn-hangzhou.aliyuncs.com
China (Shanghai) cn-shanghai vpc-vpc.cn-shanghai.aliyuncs.com
China (Qingdao) cn-qingdao vpc-vpc.cn-qingdao.aliyuncs.com
China (Beijing) cn-beijing vpc-vpc.cn-beijing.aliyuncs.com
China (Zhangjiakou-Beijing Winter Olympic) cn-zhangjiakou vpc-vpc.cn-zhangjiakou.aliyuncs.com
China (Hohhot) cn-huhehaote vpc-vpc.cn-huhehaote.aliyuncs.com
China (Ulanqab) cn-wulanchabu vpc-vpc.cn-wulanchabu.aliyuncs.com
China (Shenzhen) cn-shenzhen vpc-vpc.cn-shenzhen.aliyuncs.com
China (Heyuan) cn-heyuan vpc-vpc.cn-heyuan.aliyuncs.com
China (Chengdu) cn-chengdu vpc-vpc.cn-chengdu.aliyuncs.com
China (Hong Kong) cn-hongkong vpc-vpc.cn-hongkong.aliyuncs.com
Singapore (Singapore) ap-southeast-1 vpc-vpc.ap-southeast-1.aliyuncs.com
Australia (Sydney) ap-southeast-2 vpc-vpc.ap-southeast-2.aliyuncs.com
Malaysia (Kuala Lumpur) ap-southeast-3 vpc-vpc.ap-southeast-3.aliyuncs.com
Indonesia (Jakarta) ap-southeast-5 vpc-vpc.ap-southeast-5.aliyuncs.com
Japan (Tokyo) ap-northeast-1 vpc-vpc.ap-northeast-1.aliyuncs.com
Germany (Frankfurt) eu-central-1 vpc-vpc.eu-central-1.aliyuncs.com
UK (London) eu-west-1 vpc-vpc.eu-west-1.aliyuncs.com
US (Silicon Valley) us-west-1 vpc-vpc.us-west-1.aliyuncs.com
US (Virginia) us-east-1 vpc-vpc.us-east-1.aliyuncs.com
India (Mumbai) ap-south-1 vpc-vpc.ap-south-1.aliyuncs.com
UAE (Dubai) me-east-1 vpc-vpc.me-east-1.aliyuncs.com

Call an operation over a VPC by using Alibaba Cloud CLI

To call an operation over a VPC by using Alibaba Cloud CLI, set the Endpoint field to the corresponding endpoint of a specific region. Example:
aliyun vpc DescribeRegions --endpoint vpc-vpc.cn-hangzhou.aliyuncs.com

Call an operation over a VPC by using Alibaba Cloud SDKs

To call an operation over a VPC by using Alibaba Cloud SDKs, set the Endpoint field to the corresponding endpoint of a specific region. Example in Java:

DefaultProfile profile = DefaultProfile.getProfile("cn-hangzhou", "<AccessKeyId>", "<AccessKeySecret>");
IAcsClient client = new DefaultAcsClient(profile);

// The configuration takes effect globally. where:
// <product> specifies the service name and Vpc is used in this example. <Endpoint> specifies the endpoint of the specific region.
DefaultProfile.addEndpoint("cn-hangzhou", "vpc", "vpc-vpc.cn-hangzhou.aliyuncs.com");

// The configuration takes effect only for this request. For example, when you call the DescribeRegions operation:
DescribeRegionsRequest regionsRequest = new DescribeRegionsRequest();
// If you set productNetwork, you do not need to set SysEndpoint.
regionsRequest.setSysEndpoint("<Endpoint>");
// Configure the network. Valid values of productNetwork: vpc and public.
// Set the parameter to vpc when you call the operation over a VPC. Set the parameter to public when you call the operation over the Internet. Default value: public.
regionsRequest.productNetwork = "vpc";
DescribeRegionsResponse regionsResponse = client.getAcsResponse(regionsRequest);