You must configure Funcraft before running fun commands. This topic describes how to configure Funcraft.

Background information

Funcraft has three configuration methods. The priority of the configuration methods supported by Fun increases in the following order:


For example, you use fun config to configure region as cn-beijing, but there is a special project that needs to be deployed to cn-shanghai. Then you can create a separate .env file in this project, and write REGION=cn-shanghai to it. Finally, run the fun deploy command to deploy the project to cn-beijing. In this way, your demand to deploy different projects to different regions is satisfied.

By fun config

  1. Run the following command.
    fun config
  2. Configure the Account ID, AccessKeyId, AccessKeySecret, and Default Region Name as prompted.
    You can obtain the Account ID and AccessKey from the upper-right corner of the Function Compute console.fun_config_accesskey
    After the configuration is completed, Funcraft saves the configuration to the .fcli/config.yaml file.

By environment variables

For different operating systems, environment variables of configuring Funcraft differ:
Note If you configure Funcraft by setting environment variables, configuration items are the same as those of the .env file.
  • Linux and Mac
    • Write one line for environment variables as follows.
      REGION=cn-beijing ACCOUNT_ID=xxx ACCESS_KEY_ID=xxx ACCESS_KEY_SECRET=xxx fun deploy
    • You can also write multiple lines through export as follows.
      export REGION=cn-beijing
      export ACCOUNT_ID=xxx
      export ACCESS_KEY_ID=xxx
      export ACCESS_KEY_SECRET=xxx
      fun deploy
  • Windows
    • In the case of CMD, the environment variable configuration is as follows.
      set REGION=cn-beijing
      set ACCOUNT_ID=xxx 
      set ACCESS_KEY_ID=xxx 
      set ACCESS_KEY_SECRET=xxx 
      fun deploy
    • For PowerShell, the environment variable configuration is as follows.
      fun deploy

By the .env file

  1. In the project directory where the template.yml file is located, create a file named .env.
    Note We recommend that you specify the path of the .env file in the .gitignore file to avoid account information leakage.
  2. In .env file, enter the following configuration.