To deploy applications to EDAS using Maven, you need to create and customize configuration and account files. This topic describes the configuration items, how to specify configuration files, the priority of account configurations, and provides usage examples.
Configuration items
The configuration items for deploying applications are divided into three main categories:
- Basic environment (ENV)
- Application configuration (APP)
- Storage configuration (OSS)
The supported configuration items are listed in the following table:
| Type | Key | Required | Description |
| ENV | region_id | Yes | The ID of the region where the application is located. |
| endpoint | No | Used to set the POP gateway endpoint for Apsara Stack. | |
| APP | app_id | Yes | The application ID. |
| package_version | No | The version of the deployment package. The default value is the version from the pom file plus the build time on the current machine. For example: "1.0 (2018-09-27 19:00:00)". | |
| desc | No | The deployment description. | |
| group_id | No | The ID of the deployment group. The default is all groups. | |
| batch | No | The number of deployment batches. The default is 1 and the maximum is 5. | |
| batch_wait_time | No | The waiting time between deployment batches, in minutes. By default, there is no waiting time. | |
| stage_timeout | No | The timeout for displaying the status of each stage in the change flow, in minutes. The default is 5 minutes. If `batch_wait_time` is also set, its value is automatically added to this timeout during calculation. At runtime, the plugin exits if a stage's waiting time exceeds this threshold. | |
| OSS | region_id | No | The ID of the region where the destination bucket is located. By default, the region ID of the application is used. |
| bucket | No | The name of the destination bucket. By default, the free OSS bucket provided by EDAS is used. If you specify an OSS configuration, you must specify the bucket parameter. Otherwise, the free OSS bucket automatically allocated by EDAS is used. | |
| key | No | The custom path in OSS for uploading the application package. By default, the free OSS bucket provided by EDAS is used. If you use a specific OSS bucket, use this parameter to specify the package storage path. You can also use the following variables to parameterize the path configuration: `{region_id}`, `{app_id}`, and `{version}`. For example: `pkgs/petstore/{version}/store.war`. The default path is `{region_id}/{app_id}/{version}`. | |
| access_key_id | No | The custom account ID for uploading the application package to OSS. | |
| access_key_secret | No | The custom account key for uploading the application package to OSS. |
Example 1
If User A has an application with the ID eb20dc8a-xxx in the China (Beijing) region and wants to deploy version 1.2 of the application to the group with the ID 06923bb9-xxx, the configuration file is as follows:
env:
region_id: cn-beijing
app:
app_id: eb20dc8a-xxx
package_version: 1.2
group_id: 06923bb9-xxx
Example 2
User B wants to deploy an application with the ID eb20dc8a-xxx and upload the deployment package as the my.war file to a bucket named release-pkg in the China (Beijing) region. The AccessKey ID for OSS is ABC, and the AccessKey secret is 123456****. The configuration file is as follows:
env:
region_id: cn-beijing
app:
app_id: eb20dc8a-xxx
oss:
region_id: cn-beijing
bucket: release-pkg
key: my.war
access_key_id: ABC
access_key_secret: 123456****
Specify a configuration file
There are two ways to specify a configuration file:
Create a configuration file in any directory and use the
-Dedas_config={configuration_file_path}parameter to specify its path.If you do not specify a configuration file using a parameter, Cloud Toolkit uses the
.edas_config.yamlfile in the root directory of the packaged project by default. If the packaged project is a submodule of a Maven project, Cloud Toolkit uses the.edas_config.yamlfile in the root directory of the submodule by default.
Account configuration and priority
Deploying applications using Cloud Toolkit requires Alibaba Cloud resources. Before you deploy an application, you must configure your Alibaba Cloud account information to ensure that you have the required permissions to use and manage resources and applications. Cloud Toolkit supports multiple configuration methods. The following methods are listed in descending order of priority:
Specify the AccessKey ID and AccessKey secret parameters on the command line. There are two ways to do this.
When you run a Maven packaging command, specify the parameters using
-Daccess_key_id=xx -Daccess_key_secret=xx.When you configure Cloud Toolkit in the pom.xml file, you can insert the AccessKey ID and AccessKey secret parameters. The following example shows the configuration:
<plugin> <groupId>com.aliyun</groupId> <artifactId>edas-maven-plugin</artifactId> <version>2.30.0</version> <configuration> <accessKeyId>abc</accessKeyId> <accessKeySecret>123456****</accessKeySecret> </configuration> </plugin>
Specify an account file from the command line (recommended).
When you run a Maven packaging command, specify the path of the account file in YAML format using
-Daccess_key_file={account_file_path}. The following code provides a sample account file:access_key_id: abc access_key_secret: 123456****
Use the default Alibaba Cloud account file.
If you do not specify an account using the methods described above, Cloud Toolkit uses the Alibaba Cloud account that you previously configured for application deployment.
.aliyunclicredentials.aliyuncli/Users/username/.aliyuncli/credentials[default] aliyun_access_key_secret = 123456**** aliyun_access_key_id = abc.aliyunconfig.json.aliyun/Users/username/.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: If you do not use any of the preceding methods to configure the account, Cloud Toolkit attempts to retrieve the values of access_key_id and access_key_secret from system environment variables by calling
System.getenv("access_key_id")andSystem.getenv("access_key_secret").