When you use toolkit-maven-plugin to deploy applications, you must provide the AccessKey ID and the AccessKey secret of your Alibaba Cloud account that is used for the deployment. The plug-in supports multiple configuration methods. If duplicate configurations exist, the configuration method that has a higher priority overrides the configuration method that has a lower priority.

The following list describes the configuration methods that are sorted by priority in descending order:

  1. Specify the AccessKey ID and the AccessKey secret in the command-line interface (CLI). You can use one of the following methods to specify the AccessKey ID and the AccessKey secret:
    • When you run Maven commands to build packages, use -Daccess_key_id=xx -Daccess_key_secret=xx to specify the AccessKey ID and the AccessKey secret.
    • When you configure the plug-in in the pom.xml file, use the following sample code for reference to specify the AccessKey ID and the AccessKey secret:
      <plugin>
         <groupId>com.alibaba.cloud</groupId>
         <artifactId>toolkit-maven-plugin</artifactId>
         <version>1.0.3</version>
      <configuration>
        <accessKeyId>abc</accessKeyId>
        <accessKeySecret>1234567890</accessKeySecret>
      </configuration>
      </plugin>                            
  2. Specify the account file in the CLI (recommended). When you run Maven commands to build packages, use -Daccess_key_file={Account file path to specify the account file in the YAML format, as shown in the following example:
    access_key_id: abc
    access_key_secret: 1234567890                    
  3. Use the default Alibaba Cloud account file. If you do not use the preceding two methods to specify the account, the plug-in uses the Alibaba Cloud account that you previously specified to deploy the application.
    • aliyuncli: If you have used the latest Alibaba Cloud CLI and configured your Alibaba Cloud account, the Alibaba Cloud CLI generates the .aliyuncli directory in the current Home directory. The Alibaba Cloud CLI also creates the credentials file in the .aliyuncli directory to store your account information. Assume that the macOS system is used and the system user is jack. In this case, the following account 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 the account that is specified by this account file to deploy the application.

    • aliyun: If you have used an earlier version of the aliyun tool and configured your Alibaba Cloud account, the tool generates the .aliyun directory in the current Home directory. The tool also creates the config.json file in the .aliyun directory to store your account information. Assume that the macOS system is used and the system user is jack. In this case, the following account information is stored in the /Users/jack/.aliyun/config.json file:
      {
          "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: Then, the plug-in attempts to retrieve the values of access_key_id and access_key_secret from system environment variables. This means that the plug-in retrieves the values from System.getenv("access_key_id") and System.getenv("access_key_secret") in your Java code.