All Products
Document Center

Use CLI to quickly deploy applications in the EDAS consoles

Last Updated: Feb 01, 2019

The command line interface (CLI) was the most widely used user interface before the graphical user interface (GUI) became popular. It usually does not support the use of a mouse to perform operations. Instead, users enter instructions through keyboards, and then their computers receive and execute the instructions.Using the CLI, you can control the system accurately and perform complex operations efficiently and reliably.

The Alibaba Cloud CLI is an open source tool built on Alibaba Cloud’s Go SDK.The Alibaba Cloud CLI can directly access EDAS APIs. Make sure that you have activated EDAS and read Usage of EDAS APIs.

You can use the Alibaba Cloud CLI to quickly create and deploy applications in the EDAS console.The following shows how to use the CLI to quickly deploy a common application.


To perform the steps in this tutorial, you must have completed the following steps:

  1. Activate EDAS.
  2. Create ECS instances.

Install CLI

The Alibaba Cloud CLI is available after being downloaded and decompressed. It is supported on Mac, Linux, and Windows (x64) clients.

Download the corresponding installation package accordingly:

After decompressing the installation package, move the aliyun file to the /usr/local/bin directory, or add it to the $PATH environment variable.

Configure CLI

Before using the Alibaba Cloud CLI, run the aliyun configure command to configure the AccessKey that you use to call APIs, the region where the cloud resource is located, and the language to use.

You can create and view your AccessKey on the Security Management page, or obtain it from your system administrator.

  1. $ aliyun configure
  2. Configuring profile 'default' ...
  3. Aliyun Access Key ID [None]: <Your AccessKey ID>
  4. Aliyun Access Key Secret [None]: <Your AccessKey Secret>
  5. Default Region Id [None]: cn-hangzhou
  6. Default output format [json]: json
  7. Default Language [zh]: zh

Use CLI to quickly create an application

Use the following script to quickly create an application:

  1. #!/bin/bash
  2. # Target region
  3. REGION="cn-beijing"
  4. # ECS instance ID
  5. ECS_ID="i-2z************b6"
  6. # VPC ID of the ECS instance
  7. VPC_ID="vpc-t**********c"
  8. # Namespace (automatically created if none is available)
  9. NAMESPACE="myNamespace"
  10. # Cluster name (automatically created)
  11. CLUSTER_NAME="myCluster"
  12. # Application name
  13. APP_NAME="myApp"
  14. # Step 1: Create a namespace
  15. aliyun edas InsertOrUpdateRegion --RegionTag $REGION:$NAMESPACE --RegionName $NAMESPACE --region $REGION --endpoint "" >> /dev/null
  16. # Step 2: Create a cluster
  17. CLUSTER_ID=`aliyun edas InsertCluster --ClusterName $CLUSTER_NAME --ClusterType 2 --NetworkMode 2 --VpcId $VPC_ID --logicalRegionId $REGION:$NAMESPACE --region $REGION --endpoint "" | sed -E 's/.*"ClusterId":"([a-z0-9-]*)".*/\1/g'`
  18. # Step 3: Perform instance conversion (this takes some time)
  19. aliyun edas TransformClusterMember --InstanceIds $ECS_ID --TargetClusterId $CLUSTER_ID --Password Hello1234 >> /dev/null
  20. for i in `seq 300`
  21. do
  22. OUT=`aliyun edas ListClusterMembers --ClusterId $CLUSTER_ID | grep EcuId` && break
  23. sleep 1
  24. done
  25. ECU_ID=`echo $OUT | sed -E 's/.*"EcuId":"([a-z0-9-]*)".*/\1/g'`
  26. # Step 4: Create an application
  27. APP_ID=`aliyun edas InsertApplication --ApplicationName $APP_NAME --BuildPackId 51 --EcuInfo $ECU_ID --ClusterId $CLUSTER_ID --logicalRegionId $REGION:$NAMESPACE | sed -E 's/.*"AppId":"([a-z0-9-]*)".*/\1/g'`
  28. printf "An application is created by CLI, App ID:"$APP_ID"\n"

Use CLI to quickly deploy an application

Use the Alibaba Cloud CLI to quickly deploy an application based on the following code:

  1. #!/bin/bash
  2. # ID of the target application (created in advance)
  3. APP_ID="87a6*********************4d1"
  4. # Application group ID
  5. GROUP_ID="54b*********************f27"
  6. # ID of the uploaded OSS bucket (public-read)
  7. OSS_BUCKET="eda*****mo"
  8. # Installation package (generated by your CI system)
  9. PACKAGE="hello-edas.war"
  10. # Step 1: Upload the deployment package to OSS
  11. aliyun oss cp -f $PACKAGE oss://$OSS_BUCKET/$PACKAGE >> /dev/null
  12. PKG_URL=`aliyun oss sign oss://$OSS_BUCKET/$PACKAGE|head -1`
  13. # Step 2: Initiate a deployment request
  14. CO_ID=`aliyun edas DeployApplication --AppId $APP_ID --PackageVersion $VERSION --DeployType url --WarUrl "${PKG_URL}" --GroupId $GROUP_ID | sed -E 's/.*"ChangeOrderId":"([a-z0-9-]*)".*/\1/g'`
  15. # Step 3: Wait till the application is deployed
  16. for i in `seq 300`
  17. do
  18. STATUS=`aliyun edas GetChangeOrderInfo --ChangeOrderId $CO_ID | sed -E 's/.*"Status":(.).*/\1/g'`
  19. [ 2 = ${STATUS} ] && break
  20. sleep 1
  21. done

In the above configuration items, APP_ID and GROUP_ID are two application configuration parameters. All parameters in the preceding code are for reference only. Replace them as needed.

Perform the following steps to obtain the values of these parameters:

  1. Log on to the EDAS console.

  2. In the left-side navigation pane, click Application Management. On the Applications page, click the application that you want to deploy. On the Application Management page, click Deploy Application.

  3. On the Deploy Application page, click Generate Maven Plugin Configuration to retrieve the parameter values.