Deploy applications to ECS using Visual Studio Code

更新时间:
复制 MD 格式

If you have an Alibaba Cloud ECS instance, you can use Cloud Toolkit to quickly deploy applications. This topic describes how to use Cloud Toolkit in Visual Studio Code to deploy an application to an ECS instance.

Prerequisites

Precautions

Because of limitations in Alibaba Cloud ECS Cloud Assistant, you can only use the root account for this deployment method. To deploy your application using a different account, use one of the following methods:

Procedure

To deploy an application to an ECS instance from Visual Studio Code:

  1. Open your project in Visual Studio Code.
  2. Click the Cloud Toolkit icon.
  3. In the RUN CONFIGURATIONS section, click the More icon and select Deploy to ECS.
  4. On the Deploy ECS View page, set the deployment parameters and click OK.
    Parameter descriptions:
    • Name: A custom name for the deployment configuration.
    • File: Select one of the following options:
      • npm build: If your project is built with npm, you can build and deploy it directly.
      • Webpack build: If your project is built with Webpack, you can build and deploy it directly.
      • Upload file: If you have a local deployment package, select this option to upload it.
    • Target ECS: From the drop-down list, select a Region, and then select the target ECS instance.
    • Target Directory: The deployment path on the ECS instance. The following code provides example paths:
      ##Deployment path:
      /root/tomcat/webapps
      ##Deployment path:
      /root/springbootdemo
      ##Deployment path:
      /root/go-demo
      ##Deployment path:
      /root/nodejs-demo
    • Command: The command that runs after the application package is deployed. This is typically a start command. The following code provides an example:
      sh /root/restart.sh
      Note For more information about commands, see Command syntax.

Verify the result

After the deployment starts, the deployment log is displayed in the Console section of Visual Studio Code. Check the log to verify the deployment result.