You must configure Serverless Devs before you use it. This topic describes how to run s config commands to add, query, and remove keys used by Serverless Devs. In the following examples, Alibaba Cloud AccessKey pairs are used.

Add a key

  1. Run the following command to query the cloud service providers that can be selected:
    s config add
    Command output:
    > 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 parameters for the key that you want to add by following the on-screen instructions.
    Please select a provider: Alibaba Cloud (alibaba)
     Refer to the document for alibaba key:  http://config.devsapp.net/account/alibaba
     AccountID 188077086902****
     AccessKeyID LTAI4G4cwJkK4Rza6xd9****
     AccessKeySecret eCc0GxSpzfq1DVspnqqd6nmYNN****
     Please create alias for key pair. If not, please enter to skip default
    
        Alias: default
        AccountID: 188077086902****
        AccessKeyID: LTAI4G4cwJkK4Rza6xd9****
        AccessKeySecret: eCc0GxSpzfq1DVspnqqd6nmYNN****
    
    Configuration successful
    You can obtain the ID and AccessKey pair of your Alibaba Cloud account in the References section of the Overview page in the Function Compute console. fun_config_accesskey
    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**** --access ***
    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 Account B in the staging environment.
    • You want to manage permissions by key. 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

Parameters:
  • -a or --access: the alias of the key that you want to query.
  • -h or --help: returns help information.
Run the following commands to query the information about keys:
  • Query the information about a key that has a specific alias. For example, set the -a parameter to default.
    s config get -a default
    Sample command output:
    default:
      AccountID: 188077086902****
      AccessKeyID: LTAI4FoAC3JPPWKPZDVg****
      AccessKeySecret: gwL7FuveTjmHC7xyvvwOxP6ysI****
  • Query the information about all keys.
    s config get
    Sample command output:
    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

Parameters:
  • -a or --access: the alias of the key that you want to remove.
  • -h or --help: returns help information.
Run the following command to remove a key that is specified by the -a parameter:
s config delete -a aliasName