You must configure Serverless Devs before you use it. In the example of this topic, an Alibaba Cloud AccessKey pair is added to Serverless Devs. You can run s config commands to add, query, and remove keys used by Serverless Devs.

Add a key

  1. Run the following command to query the cloud service providers that can be selected:
    s config add
    The following output is returned:
    > Alibaba Cloud (alibaba)
      AWS (aws)
      Azure (azure)
      Baidu Cloud (baidu)
      Google Cloud (google)
      Huawei Cloud (huawei)
      Tencent Cloud (tencent)
    (Move up and down to reveal more choices)
  2. Select a cloud service provider as required and press the Enter key. In this example, Alibaba Cloud (alibaba) is selected.
  3. Set the AccountID, AccessKey ID, AccessKey Secret and aliasName parameters as prompted.
    You can obtain the ID and AccessKey pair of your Alibaba Cloud account in the Common Info section of the Overview page in the Function Compute console. Function Compute console_AccessKey pair
    Serverless Devs also allows you to add keys by running commands. For example, you can run the following command to add an AccessKey pair:
    s config add --AccessKeyID LTAI4G4cwJkK4Rza6xd9**** --AccessKeySecret  eCc0GxSpzfq1DVspnqqd6nmYNN**** --AccountID 188077086902**** --aliasName ***
    Notice Serverless Devs allows you to manage multiple keys. When you add a key, you can specify the feature of the key by setting the aliasName parameter. Scenarios:
    • You want to isolate environments. In this case, you can set different aliases for the keys of different accounts and deploy resources by account. For example, you can use Account A in the production environment and use Account B in the staging environment.
    • You want to implement access control. In this case, you can grant different permissions to different keys. Examples:
      • Set the website-access alias for a key that is used for website deployment.
      • Set the fc-access alias for a key that is used for function deployment.

Query keys

To query keys, you need to set the following parameters:
  • -a or --aliasName: the alias of the key that you want to query.
  • -l or --list: specifies to return the key list.
  • -h or -help: specifies to return the guidance.
Run the following command to query the keys added to Serverless Devs:
s config get -l
The following output is returned:
default:
  AccountID: 188077086902****
  AccessKeyID: LTAI4G4cwJkK4Rza6xd9****
  AccessKeySecret: eCc0GxSpzfq1DVspnqqd6nmYNN****
default-1:
  AccountID: 188077086902****
  AccessKeyID: LTAI4FoAC3JPPWKPZDVg****
  AccessKeySecret: gwL7FuveTjmHC7xyvvwOxP6ysI****
Note You can run the s config get -h command to query the detailed information about s config commands.

Remove a key

To remove a key, you need to set the following parameters:
  • -a or --aliasName: the alias of the key that you want to delete.
  • -h or -help: specifies to return the guidance.
Run the following command to delete a key that is identified by the -a parameter:
s config delete -a aliasName