All Products
Search
Document Center

Elastic Compute Service:Call API operations over the internal network

Last Updated:Nov 14, 2024

You cannot call API operations on VPC-type ECS instances that do not have public IP addresses. This topic describes how to call API operations on VPC-type ECS instances over the Alibaba Cloud internal network.

Background information

ECS provides public endpoints. If your ECS instance does not have a public bandwidth or a public IP address, you cannot make API requests by using tools such as Alibaba Cloud CLI or SDKs. You can use one of the following methods to call API operations over the Alibaba Cloud internal network:

  • SDK: Use the SDK for Java core library v4.5.3 or later to call API operations over the internal network in a VPC.

  • CLI: Use CLI to call API operations over the internal network by specifying the endpoint of a specific region.

Take note of the following items:

  • These methods are applicable only in regions where VPC-type ECS instances are deployed. The endpoint of a region can be used to manage resources only within that region. Cross-region operations are not supported.

  • We recommend that you use custom images that have Alibaba Cloud CLI or SDKs deployed to create ECS instances. The ECS instances must load related dependencies with access to the Internet.

The following table describes the endpoints that support API calls over the internal network. Make sure that you use an endpoint listed in the table.

Alibaba Cloud region

Region ID

Endpoint

China (Hangzhou)

cn-hangzhou

ecs-vpc.cn-hangzhou.aliyuncs.com

China (Shanghai)

cn-shanghai

ecs-vpc.cn-shanghai.aliyuncs.com

China (Nanjing - Local Region)

cn-nanjing

ecs-vpc.cn-nanjing.aliyuncs.com

China (Fuzhou - Local Region)

cn-fuzhou

ecs-vpc.cn-fuzhou.aliyuncs.com

China (Qingdao)

cn-qingdao

ecs-vpc.cn-qingdao.aliyuncs.com

China (Beijing)

cn-beijing

ecs-vpc.cn-beijing.aliyuncs.com

China (Zhangjiakou)

cn-zhangjiakou

ecs-vpc.cn-zhangjiakou.aliyuncs.com

China (Hohhot)

cn-huhehaote

ecs-vpc.cn-huhehaote.aliyuncs.com

China (Ulanqab)

cn-wulanchabu

ecs-vpc.cn-wulanchabu.aliyuncs.com

China (Shenzhen)

cn-shenzhen

ecs-vpc.cn-shenzhen.aliyuncs.com

China (Heyuan)

cn-heyuan

ecs-vpc.cn-heyuan.aliyuncs.com

China (Guangzhou)

cn-guangzhou

ecs-vpc.cn-guangzhou.aliyuncs.com

China (Chengdu)

cn-chengdu

ecs-vpc.cn-chengdu.aliyuncs.com

China (Hong Kong)

cn-hongkong

ecs-vpc.cn-hongkong.aliyuncs.com

Singapore

ap-southeast-1

ecs-vpc.ap-southeast-1.aliyuncs.com

Malaysia (Kuala Lumpur)

ap-southeast-3

ecs-vpc.ap-southeast-3.aliyuncs.com

Indonesia (Jakarta)

ap-southeast-5

ecs-vpc.ap-southeast-5.aliyuncs.com

Philippines (Manila)

ap-southeast-6

ecs-vpc.ap-southeast-6.aliyuncs.com

Thailand (Bangkok)

ap-southeast-7

ecs-vpc.ap-southeast-7.aliyuncs.com

Japan (Tokyo)

ap-northeast-1

ecs-vpc.ap-northeast-1.aliyuncs.com

South Korea (Seoul)

ap-northeast-2

ecs-vpc.ap-northeast-2.aliyuncs.com

Germany (Frankfurt)

eu-central-1

ecs-vpc.eu-central-1.aliyuncs.com

UK (London)

eu-west-1

ecs-vpc.eu-west-1.aliyuncs.com

US (Silicon Valley)

us-west-1

ecs-vpc.us-west-1.aliyuncs.com

US (Virginia)

us-east-1

ecs-vpc.us-east-1.aliyuncs.com

UAE (Dubai)

me-east-1

ecs-vpc.me-east-1.aliyuncs.com

Method 1: (Recommended) Use SDKs to call API operations over the internal network

Simple configurations are required when you use SDKs to call API operations over the internal network. The following code provides an example on how to use SDK for Java to call an API operation over the internal network:

DefaultProfile profile = DefaultProfile.getProfile("<RegionId>", "System.getenv("ALIBABA_CLOUD_ACCESS_KEY_ID")", "System.getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET")");
IAcsClient client = new DefaultAcsClient(profile);

// Configure parameters that take effect globally. In the configuration, <product> indicates the service name. For example, you can enter Ecs for ECS. 
DefaultProfile.addEndpoint("<RegionId>", "<product>", "<Endpoint>");

// Configure parameters that take effect only for the request. For example, when you call the DescribeRegions operation, you can make the following configurations: 
DescribeRegionsRequest regionsRequest = new DescribeRegionsRequest();
// If you configure the productNetwork parameter, you do not need to configure the SysEndpoint parameter. 
regionsRequest.setSysEndpoint("<Endpoint>");
// Configure the network. Valid values of the productNetwork parameter: vpc and public. Default value: public. 
// If you want to call the DescribeRegions operation over the internal network, set the parameter to vpc. If you want to call this operation over the Internet, set the parameter to public. 
regionsRequest.productNetwork = "vpc";
DescribeRegionsResponse regionsResponse = client.getAcsResponse(regionsRequest);

Method 2: Use CLI to call API operations over the internal network

The DescribeRegions operation is used in this example. Sample command:

aliyun ecs DescribeRegions --endpoint ecs-vpc.cn-hangzhou.aliyuncs.com