If you are familiar with using Alibaba Cloud CLI commands to manage Alibaba Cloud resources, you can use CLI commands to create Elastic Compute Service (ECS) instances in the Cloud Shell console.
Log on to the Cloud Shell console
Preparations
Before you create an ECS instance, you must create a virtual private cloud (VPC) and a security group.
Create an ECS instance
Create a subscription ECS instance.
API | Parameter | Example |
---|---|---|
RunInstances | RegionId | The region ID of the instance. Example: cn-hangzhou. |
ImageId | The ID of the image. We recommend that you select the aliyun_2_1903_x64_20G_alibase_20200324.vhd Alibaba Cloud Linux image. | |
InstanceType | The instance type.
|
|
SecurityGroupId | The ID of the security group. Set the value to the SecurityGroupId value returned
by the CreateSecurityGroup operation.
Example: sg-bp18z2q1jg4gq95t****. |
|
VSwitchId | The ID of the vSwitch. Set the value to the VSwitchId value returned by the CreateVSwitch operation.
Example: vsw-bp11hf5r945gewysp****. |
|
InstanceName | The name of the instance.
Example: ecs_cli_demo. |
|
InstanceChargeType | The billing method of the instance. To create a subscription instance, set the value
to PrePaid.
Note Make sure that you have sufficient balance in your account.
|
|
PeriodUnit | The unit of the billing cycle. Example: Month. | |
Period | The duration of the billing cycle. Example: 1. | |
InternetMaxBandwidthOut | The maximum outbound public bandwidth. Example: 1. | |
Password | The logon password of the instance: <yourPassword>.
Note You must specify a complex password to ensure instance security.
|
Run the following command to create a subscription instance:
aliyun ecs RunInstances \
--RegionId cn-hangzhou \
--ImageId aliyun_2_1903_x64_20G_alibase_20200324.vhd \
--InstanceType ecs.s6-c1m2.small \
--SecurityGroupId sg-bp18z2q1jg4gq95t**** \
--VSwitchId vsw-bp11hf5r945gewys**** \
--InstanceName ecs_cli_demo \
--InstanceChargeType PrePaid \
--PeriodUnit Month \
--Period 1 \
--InternetMaxBandwidthOut 1 \
--Password <yourPassword>
The following command output is returned:
{
"InstanceIdSets": {
"InstanceIdSet": [
"i-bp1ducce5hs1jm98****"
]
},
"RequestId": "7F0166F9-9466-4AE1-8799-E68D6514****",
"TradePrice": ****
}
Connect to the ECS instance
This section describes how to connect to a Linux instance by using Cloud Shell. For information about how to connect to a Windows instance, see Connect to a Windows instance from a local client.
Release an ECS instance
You can manually release a subscription instance after it expires. If you do not renew the instance after it expires, the instance is automatically released.