If an ECS instance in a virtual private cloud (VPC) is not assigned a public IP address, the instance cannot call ActionTrail API operations over the Internet. Call the API operations over a VPC instead.
Prerequisites
An ECS instance in a VPC. API requests are sent from this instance.
Version 4.5.3 or later of the core library of the Java SDK, if you use the Java SDK method.
Limits
You can manage resources only in the same region as the ActionTrail VPC endpoint that you call. Cross-region operations are not supported.
Method 1 (recommended): Call an API operation by using the Java SDK
The Java SDK method applies to Java applications. The following code calls the ActionTrail DescribeRegions operation over a VPC:
DefaultProfile profile = DefaultProfile.getProfile("<RegionId>", "<AccessKeyId>", "<AccessKeySecret>");
IAcsClient client = new DefaultAcsClient(profile);
// A global configuration. For ActionTrail, the product name is Actiontrail.
DefaultProfile.addEndpoint("<RegionId>", "Actiontrail", "<Endpoint>");
// Call the DescribeRegions operation.
DescribeRegionsRequest regionsRequest = new DescribeRegionsRequest();
// A configuration that takes effect only for the current request.
// Set the network. Valid values of the productNetwork parameter: vpc and public.
// vpc: calls the API operation over a VPC. public: calls the API operation over the Internet. This is the default value.
regionsRequest.productNetwork = "vpc";
DescribeRegionsResponse regionsResponse = client.getAcsResponse(regionsRequest);Configure the endpoint at either of the following levels:
Global configuration —
DefaultProfile.addEndpointsets the endpoint globally. For ActionTrail, set the product name toActiontrail. Replace<Endpoint>with the VPC endpoint of the region whose resources you want to manage. For the endpoint of each region, see VPC endpoints.Per-request configuration —
productNetworktakes effect only for the current request. Valid values:vpcandpublic. Set the value tovpcto call the operation over a VPC. The default value,public, calls the operation over the Internet. To set the endpoint for the current request instead, callsetSysEndpoint.
If you set productNetwork to vpc, you do not need to call setSysEndpoint to specify the endpoint for the request.
Method 2: Call an API operation by using Alibaba Cloud CLI
Run the following command to call the DescribeRegions operation over a VPC. The command uses the VPC endpoint of the China (Hangzhou) region:
aliyun actiontrail DescribeRegions --endpoint actiontrail-vpc.cn-hangzhou.aliyuncs.comThe --endpoint option specifies the endpoint that the request is sent to. Replace actiontrail-vpc.cn-hangzhou.aliyuncs.com with the VPC endpoint of the region whose resources you want to manage. For the endpoint of each region, see VPC endpoints.
VPC endpoints
The VPC endpoints of ActionTrail use the format actiontrail-vpc.<region-id>.aliyuncs.com. The following table lists the VPC endpoint of each region.
| Alibaba Cloud region | Region ID | Endpoint |
| China (Hangzhou) | cn-hangzhou | actiontrail-vpc.cn-hangzhou.aliyuncs.com |
| China (Shanghai) | cn-shanghai | actiontrail-vpc.cn-shanghai.aliyuncs.com |
| China (Qingdao) | cn-qingdao | actiontrail-vpc.cn-qingdao.aliyuncs.com |
| China (Beijing) | cn-beijing | actiontrail-vpc.cn-beijing.aliyuncs.com |
| China (Zhangjiakou) | cn-zhangjiakou | actiontrail-vpc.cn-zhangjiakou.aliyuncs.com |
| China (Hohhot) | cn-huhehaote | actiontrail-vpc.cn-huhehaote.aliyuncs.com |
| China (Shenzhen) | cn-shenzhen | actiontrail-vpc.cn-shenzhen.aliyuncs.com |
| China (Heyuan) | cn-heyuan | actiontrail-vpc.cn-heyuan.aliyuncs.com |
| China (Guangzhou) | cn-guangzhou | actiontrail-vpc.cn-guangzhou.aliyuncs.com |
| China (Chengdu) | cn-chengdu | actiontrail-vpc.cn-chengdu.aliyuncs.com |
| China (Hong Kong) | cn-hongkong | actiontrail-vpc.cn-hongkong.aliyuncs.com |
| Singapore | ap-southeast-1 | actiontrail-vpc.ap-southeast-1.aliyuncs.com |
| Malaysia (Kuala Lumpur) | ap-southeast-3 | actiontrail-vpc.ap-southeast-3.aliyuncs.com |
| Indonesia (Jakarta) | ap-southeast-5 | actiontrail-vpc.ap-southeast-5.aliyuncs.com |
| Japan (Tokyo) | ap-northeast-1 | actiontrail-vpc.ap-northeast-1.aliyuncs.com |
| Germany (Frankfurt) | eu-central-1 | actiontrail-vpc.eu-central-1.aliyuncs.com |
| UK (London) | eu-west-1 | actiontrail-vpc.eu-west-1.aliyuncs.com |
| US (Silicon Valley) | us-west-1 | actiontrail-vpc.us-west-1.aliyuncs.com |
| US (Virginia) | us-east-1 | actiontrail-vpc.us-east-1.aliyuncs.com |
| UAE (Dubai) | me-east-1 | actiontrail-vpc.me-east-1.aliyuncs.com |