This topic provides answers to some frequently asked questions about Elastic Compute Service (ECS) API operations.
How do I configure sequential instance names or hostnames when I create multiple ECS instances?
How do I assign a public IP address to an ECS instance by calling an API operation?
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 assign a public IP address to an ECS instance by calling an API operation?
Method 1: Automatically assign a static public IP address (also called system-assigned or auto-assigned public IP address) to an ECS instance when the instance is created.
Call the RunInstances operation and set the InternetMaxBandwidthOut parameter to a value that is greater than 0 to create an ECS instance. The created ECS instance is automatically assigned a static public IP address.
Method 2: Assign a static public IP address to an ECS instance after the instance is created.
To assign a static public IP address to an existing ECS instance that does not have a static public IP address, call the ModifyInstanceNetworkSpec operation to change the value of the InternetMaxBandwidthOut parameter to a value that is greater than 0. The ECS instance is assigned a static public IP address by the system. For a pay-as-you-go (PostPaid) ECS instance, set the
AllocatePublicIp
parameter totrue
to allow the system to assign a static public IP address to the instance.Method 3: Create an elastic IP address (EIP) and associate the EIP with an ECS instance
Call the AssociateEipAddress operation to associate an EIP with an ECS instance.
For more information about how to enable public bandwidth for ECS instances, see Enable public bandwidth.
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 are classified based on the network interface controller (NIC) type (NicType). The public NIC type (internet) and the internal NIC type (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. In this case, only the security group rules related to public NICs in the queried security group are returned.
aliyun ecs DescribeSecurityGroupAttribute --SecurityGroupId <TheSecurityGroupId> --RegionId <TheRegionId>
If you want to query the security group rules related to internal NICs 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, set the NicType parameter to intranet.
aliyun ecs DescribeSecurityGroupAttribute --SecurityGroupId <TheSecurityGroupId> --RegionId <TheRegionId> --NicType intranet
Why are only 10 entries returned when I initiate a request by calling an ECS API operation or by using an ECS SDK or an Alibaba Cloud CLI command?
Specific API operations support pagination query. If you do not specify pagination information when you initiate a request, 10 entries are returned by default. To return more entries, specify the PageNumber and PageSize parameters to configure pagination query.
Parameter | Type | Required | Description |
PageNumber | Integer | No | The page number. ECS API operations whose name prefix is Pages start from page 1. Default value: 1. |
PageSize | Integer | No | The number of entries per page. Valid values: 1 to 100. Default value: 10. Note The maximum value of the PageSize parameter is 100. If more than 100 entries are returned after an API operation is called, you can set the PageNumber parameter to a value starting from 1, such as 1, 2, or 3, and call the operation multiple times to obtain all entries in the response. If you use SDK for Java, you can specify the number of pages to return by using the setPageNumber() method. |