All Products
Search
Document Center

Elastic Compute Service:API FAQ

Last Updated:Dec 17, 2024

This topic provides answers to some frequently asked questions about Elastic Compute Service (ECS) API operations.

What is an ECS API operation?

ECS API operations are open source remote procedure call (RPC) API operations that provide API services for Alibaba Cloud users. You can use ECS API operations to manage and use ECS instances. The following figure shows the forwarding path of a request when an API operation is called. For information about how to call an ECS API operation, see Developer Reference.什么是ECS API

What do I do if the InvalidDataDiskCategory.NotSupported error code is returned when I create an ECS instance?

Problem description: When you call the RunInstances operation to create an ECS instance, the following error is returned:

{
    "Code": "InvalidDataDiskCategory.NotSupported",
    "Message": "Specified disk category is not supported."
}

Cause: The error occurs because disks of the specified category cannot be created in the specified zone.

Solution: We recommend that you call the DescribeAvailableResource operation to query the resources available in the zone where you want to create the ECS instance and make sure that the resources in the zone are sufficient. You can also call the RunInstances operation again with ZoneId set to a different value to create an ECS instance.

aliyun ecs RunInstances --ImageId win2008_64_ent_r2_cn_40G_alibase_20150429.vhd --InstanceType ecs.g5.large --SecurityGroupId <TheSecurityGroupId> --SystemDiskCategory cloud_efficiency --ZoneId cn-hangzhou-c

How do I configure sequential instance names or hostnames when I create multiple ECS instances?

To create multiple ECS instances whose instance names or hostnames are sequentially configured, we recommend that you call the RunInstances operation. This operation contains the InstanceName and HostName parameters. You can specify values that comply with the naming conventions for the two parameters. For more information, see Batch configure sequential names or hostnames for multiple instances.

How do I create an ECS instance that is assigned a public IP address?

Method 1: Call the RunInstances operation with InternetMaxBandwidthOut set to a value greater than 0 to create an ECS instance. The ECS instance is automatically assigned a public IP address.

Method 2: Call the CreateInstance operation to create an ECS instance. Then, call the AllocatePublicIpAddress operation to assign a public IP address to the instance.

What do I do if the public IP address of an ECS instance cannot be pinged after I create the instance by calling an ECS API operation?

Problem description: The ECS instance that you created by calling an ECS API operation cannot connect to the Internet, and the public IP address of the instance cannot be pinged.

Cause: The security group to which the instance belongs does not have a rule that allows Internet access.

Solution: Call the AuthorizeSecurityGroup operation to add an inbound rule to the security group to allow Internet access. For example, you can send the following request with IpProtocol set to ICMP to call the AuthorizeSecurityGroup operation and add an inbound rule that allows the public IP address of this instance to be pinged from the 10.0.0.0/8 CIDR block:

Important

For security purposes, we recommend that you configure security group rules based on your business requirements and the principle of least privilege. Exercise caution when you specify 0.0.0.0/0 or ::/0 in a request to allow access from all IPv4 or IPv6 addresses.

https://ecs.aliyuncs.com/?Action=AuthorizeSecurityGroup
&SecurityGroupId=sg-bp15ed6xe1yxeycg7***
&SourceCidrIp=10.0.0.0/8
&IpProtocol=ICMP
&PortRange=-1/-1
&<Common request parameters>

What do I do if the "The specified IP is already in use" error message is returned when I call an ECS API operation to assign a public IP address to an ECS instance?

Problem description: When you call the AllocatePublicIpAddress operation to assign a public IP address specified by IpAddress to an ECS instance, the following error is returned:

{
    "Code": "IpInUse",
    "Message": "The specified IP is already in use."
}

Cause: The specified IP address is already in use.

Solution: Check whether the IP address is already in use. If the IP address is available, reassign the IP address to the instance. If the IP address is already in use, assign a different IP address to the instance. You can also leave IpAddress empty to allow the system to assign a random IP address to the instance.

When I modify the public bandwidth configurations of an instance by calling an ECS API operation, can I specify an effective period for the new bandwidth configurations?

You can call the ModifyInstanceNetworkSpec operation to modify the public bandwidth configurations of an ECS instance. The new bandwidth configurations take effect on the instance immediately after the modification. If you want to temporarily modify the bandwidth configurations of your instance, set StartTime and EndTime to specify an effective period.

Note

If you associated an elastic IP address (EIP) with the instance, you can call the ModifyEipAddressAttribute operation to modify the public bandwidth configurations but you cannot specify an effective period.

What do I do if only specific security group rules are displayed when I call an API operation or use an ECS SDK to query the rules of a security group?

Security group rules can be distinguished by the network interface controller (NIC) type of the security group. Public NIC (internet), and private NIC (intranet) are supported. When you call the DescribeSecurityGroupAttribute operation to query the rules of a security group, the NicType parameter is optional. If you do not specify this parameter, the default value internet is used. Therefore, when you run the following command to call the DescribeSecurityGroupAttribute operation in Alibaba Cloud CLI, only the public security group rules in the queried security group are displayed:

aliyun ecs DescribeSecurityGroupAttribute --SecurityGroupId <TheSecurityGroupId> --RegionId <TheRegionId>

If you want to query the internal security group rules in a security group, such as internal security group rules that allow access across internal networks or are configured for the VPN firewall of Finance Cloud, run the following command and set NicType to intranet:

aliyun ecs DescribeSecurityGroupAttribute --SecurityGroupId <TheSecurityGroupId> --RegionId <TheRegionId> --NicType intranet

Why are only 10 entries returned for a request made by using an ECS API operation, an ECS SDK, or an Alibaba Cloud CLI command?

Some API operations support pagination. When pagination information is not set, by default ten entries are returned. To show more entries in responses, you can set the PageSize and PageNumber parameters to customize the query pages.

Parameter

Type

Required

Description

PageNumber

Integer

No

The number of the page to return. ECS API operations whose name prefix is Describe are used to query information. For more information, see List of operations by function.

Pages start from page 1.

Default value: 1.

PageSize

Integer

No

The number of entries to return on each page.

Maximum value: 100.

Default value: 10.

Note

The maximum value of PageSize is 100. If more than 100 entries are returned after an API operation is called, you can set PageNumber to a value starting from 1 (such as 1, 2, or 3) at a time and call the operation multiple times to obtain all the entries in the response. If you are using the SDK for Java, you can specify the page number to return by using setPageNumber().