You can use the Alibaba Cloud command-line interface (CLI) to create an Elastic Container Instance (ECI) container group, deploy a Parse Server application to the container group, and enable public network access.
Tutorial overview
The steps and examples in this tutorial are integrated into Alibaba Cloud Shell. You can open the tutorial in Cloud Shell to quickly deploy a Parse Server application using the Alibaba Cloud CLI.
In this tutorial, you will complete the following operations:- Configure the network
- Deploy the application
- Destroy the application
- ECI container group
- Number of containers: 3
- Container specifications: 1 vCPU, 1 GB memory
- Elastic IP Address
- Number of instances: 1
- Billing method: pay-by-traffic
Prerequisites
- Make sure that you have activated the following Alibaba Cloud services:
- Make sure that your account has a balance of more than CNY 100 and has passed identity verification. Otherwise, you cannot create ECI instances.
Network configuration
- Run the following command to navigate to the directory that contains the Terraform template for network configuration.
cd ~/tutorial-eci-parse-server/network - Run the init command to load Alibaba Cloud Providers.
terraform init - Run the following command to deploy the network environment.
After the deployment is successful, the following output is displayed in the console:terraform apply
You can specify the following parameters to customize your network configuration:... Outputs: eip_ip = 106.14.2.** eip_id = eip-uf6n81mgxtwl****** region_id = cn-hangzhou securitygroup_id = sg-uf631pc9pwu****** vpc_id = vpc-uf6rrgi1zrug3znr***** vswitch_id = vsw-uf6jxv84mbf427h***** zone_id = cn-hangzhou-bregion
- The region. The default value is cn-hangzhou.
availability_zone
- The zone. The default value is cn-hangzhou-b.
vpc_cidr
- The VPC CIDR block. The default value is 172.16.0.0/12.
vswitch_cidr
- The vSwitch CIDR block. The default value is 172.16.0.0/21.
- Run the following command to save the network parameters to a temporary file. These parameters are used in subsequent steps.
terraform output > net_conf
Deploy the Parse Server application
This tutorial provides the eci-create.sh script. The script reads the network configuration file that you generated and creates an ECI container group to deploy the Parse Server application. For more information about ECI operations in the CLI, see Manage Elastic Container Instance (ECI) using the Alibaba Cloud CLI.
cd ~/tutorial-eci-parse-server
bash eci-create.sh network/net_confCommand description:- network/net_conf is the configuration file that stores the network parameters generated in the previous step.
- The container group contains three containers. One container runs MongoDB, another runs Parse Server, and the third runs Parse Dashboard.
{
"ContainerGroupId":"eci-uf6fonnghi50val****",
"RequestId":"3061989B-C3D2-41BD-B30F-*****"
}You can now log on to the ECI console to view the container group that you created. Destroy the application
- Run the following command to delete the container group.
In the command, ContainerGroupId is the ID of the container group that you created in the previous step.aliyun eci DeleteContainerGroup \ --RegionId cn-hangzhou \ --ContainerGroupId eci-uf6fonnghi50val**** - Run the following command to navigate to the directory that contains the Terraform template for network configuration.
cd ~/tutorial-eci-parse-server/network - Run the following command to destroy the network resources.
terraform destroy