Deploy your application to EDAS using the Cloud Toolkit Maven plugin

This article will show you how to deploy your application to ** Alibaba Cloud EDAS ** using the Cloud Toolkit Maven plugin.

If you are an EDAS developer and you are using a WAR or JAR package to deploy your application, you can use the Cloud Toolkit Maven plugin to deploy your application to Alibaba Cloud EDAS.

Step 1: Add Maven dependency

Add the following <build> dependency to your project's pom.xml file.

<build>
 <plugins>
     <plugin>
         <groupId>com.alibaba.cloud</groupId>
         <artifactId>toolkit-maven-plugin</artifactId>
         <version>1.0.0</version>
     </plugin>
 </plugins>
</build>

From Maven's official central repository, click Update. ](Https://search.maven.org/search?spm=a2c65.11461447.0.0.42466f51X6M4KV&q=g:com.alibaba.cloud%20AND%20a:toolkit-maven-plugin)

Step 2: Set up Yaml file

Create an edas_config.yaml file under your project's root directory. If the packaged project is a Maven submodule, create a file in the submodule directory. The file contains the following:

env:
  region_id: cn-beijing
app:
  app_id: eb20dc8a-0000-567-1234-5f6a54550453

Of the above setting items, region_id indicates the region ID of the application instance, and app_id indicates the application ID. The values of the above setting items are examples. Replace with the actual application value. For other setting items, refer to "Other setting items".

Step 3: Link with EDAS account

Create an account file and set the access key ID and access key secret in yaml format. To view your Access Key ID and Access Key Secret, log on to Alibaba Cloud's user information management system. A setting example is shown below.

access_key_id: 123456
access_key_secret: 7891011

Step 4: Completion of placement

Go to the root directory (or the submodule directory if you are using multiple Maven modules) and run this packaging command.

mvn package toolkit:deploy --proudct=edas -Daccess_key_file= {Account file path}

image.png

When this command is executed, the following message will be displayed, indicating that the application has been successfully deployed to EDAS.

Other setting items

The setting items for deploying the application are classified as follows.

--Basic environment (env) --Application configuration (app) --Storage Configuration (OSS) The table below shows the currently supported setting items.

image.png

Setting example 1: Specify the version of the group and deployment package

For example, an application with ID eb20dc8a-e6ee-4f6d-a36f-5f6a54550453 is deployed in Beijing. The group ID is 06923bb9-8c5f-4508-94d8-517b692f30b9 and the deployment package version is 1.2. The settings in this case are as follows.

env:
  region_id: cn-beijing
app:
  app_id: eb20dc8a-e6ee-4f6d-a36f-5f6a54550453
  package_version: 1.2
  group_id: 06923bb9-8c5f-4508-94d8-517b692f30b9

Setting example 2: Specifying the OSS storage space

For example, suppose you deploy an application with ID eb20dc8a-e6ee-4f6d-a36f-5f6a54550453 and you want to upload the deployment package to your bucket named release-pkg in Beijing. The file object name is my.war, the OSS account ID is ABC, and the OSS account key is 1234567890. The settings in this case are as follows.

env:
  region_id: cn-beijing
app:
  app_id: eb20dc8a-e6ee-4f6d-a36f-5f6a54550453
oss:
  region_id: cn-beijing
  bucket: release-pkg
  key: my.war  
  access_key_id: ABC
  access_key_secret: 1234567890

Specifying the configuration file

--If no configuration file is specified, this plugin will use the .edas_config.yaml file in the root directory of the package project as the configuration file. If the packaged project is a submodule of a Maven project, the configuration file is under the root directory of the submodule by default, but not under the root directory of the entire Maven project. --You can also specify a configuration file by setting the -Dedas_config = xxx parameter. --If a default config file exists while another config file is specified, the plugin will use the latter config file.

Account settings and priority description

When deploying an application using this plugin, you need to provide Alibaba Cloud Access Key for application deployment. Currently, plugins support multiple configuration methods. If there are duplicate configuration methods, the higher priority configuration method takes precedence over the lower priority configuration method. The configuration methods are shown in descending order of priority.

--AK / SK parameters specified on the command line. The access_key_id and access_key_secret can be specified in one of the following ways: --When you run the Maven command to package your project, specify both parameters with -Daccess_key_id = xx -Daccess_key_secret = xx. --When setting this plugin in the pom file, set the AK and SK parameters as follows.

<plugin>
  <groupId>com.aliyun</groupId>
  <artifactId>edas-maven-plugin</artifactId>
  <version>2.30.0</version>
  <configuration>
      <accessKeyId>abc</accessKeyId>
      <accessKeySecret>1234567890</accessKeySecret>
  </configuration>
</plugin>

--Specify the account file on the command line (recommended). When you run the Maven command to package your project, specify the account file in yaml format with -Daccess_key_file = {account file path}. Example: `Daccess_key_file = {account file path =

access_key_id: abc
access_key_secret: 1234567890

--Use the default Alibaba Cloud account file. If you choose not to specify an account in any of the above methods, the plug-in will deploy your application using the configured Alibaba Cloud account. --aliyuncli: If you set up your Alibaba Cloud account using the latest ʻaliyuncli tool, Alibaba Cloud will create a .aliyuncli subdirectory under your current home directory to store your account information. Create a credential file in the aliyuncli subdirectory. Here, taking a Mac system as an example, assuming that the system user is "jack", the following information is stored in the /Users/jack/.aliyuncli/credentials file.

[default]
aliyun_access_key_secret = 1234567890
aliyun_access_key_id = abc

The plug-in uses this account file as the account for deploying the application.

--aliyun: If you set up Alibaba Cloud account using legacy Aliyun tool, Aliyun tool will generate .aliyun subdirectory under the current home directory and config.json in that .aliyun subdirectory. Create a file. Taking a Mac system as an example, we assume that the system user is "jack", so the account information is stored in /Users/jack/.aliyun/config.json.

{
  "current": "",
  "profiles": [{
      "name": "default",
      "mode": "AK",
      "access_key_id": "",
      "access_key_secret": "",
      "sts_token": "",
      "ram_role_name": "",
      "ram_role_arn": "",
      "ram_session_name": "",
      "private_key": "",
      "key_pair_name": "",
      "expired_seconds": 0,
      "verified": "",
      "region_id": "",
      "output_format": "json",
      "language": "en",
      "site": "",
      "retry_timeout": 0,
      "retry_count": 0
  }, {
      "name": "",
      "mode": "AK",
      "access_key_id": "abc",
      "access_key_secret": "xxx",
      "sts_token": "",
      "ram_role_name": "",
      "ram_role_arn": "",
      "ram_session_name": "",
      "private_key": "",
      "key_pair_name": "",
      "expired_seconds": 0,
      "verified": "",
      "region_id": "cn-hangzhou",
      "output_format": "json",
      "language": "en",
      "site": "",
      "retry_timeout": 0,
      "retry_count": 0
  }],
  "meta_path": ""
}

--System environment variables: Finally, the plugin will try to get the values of access_key_id and access_key_secret from the system environment variables. That is, the plugin gets these values from the Java code System.getenv ("access_key_id ") and System.getenv ("access_key_secret ").

Recommended Posts

Deploy your application to EDAS using the Cloud Toolkit Maven plugin
Guide: Deploy your application using the Alibaba Cloud Toolkit plugin
Deploy a Node.js application to an ECS instance using the Cloud Toolkit
Deploy your application to WildFly
How to deploy Java application to Alibaba Cloud EDAS in Eclipse
Deploy a Java application developed locally with the Cloud Toolkit to an Alibaba Cloud ECS instance
I tried using the Migration Toolkit for Application Binaries
Deploy Spring Boot applications to Heroku without using the Heroku CLI
[Java] Deploy the Spring Boot application to Azure App Service
Deploy the application created by Spring Boot to Heroku (public) ②
How to deploy jQuery in your Rails app using Webpacker
Deploy the application created by Spring Boot to Heroku (public) ①
I tried using the cache function of Application Container Cloud Service
Connect IoT devices to the cloud using gateway and subdevice scenarios
Deploy SpringBoot application to AWS EC2
Deploy the WEB application by Spring Boot to Tomcat server as WAR