Before using Serverless Devs, you must configure it first. This topic uses Alibaba Cloud keys as an example to demonstrate how to use the s config commands to add, obtain, and delete keys.
Prerequisites
Add key information
-
Run the following command to select a cloud provider.
s config addCommand 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) -
Select your target cloud provider and press Enter. This topic uses
Alibaba Cloud (alibaba)as an example. -
Follow the interactive prompts to set your key information.
Please select a provider: Alibaba Cloud (alibaba) Refer to the document for alibaba key: http://config.devsapp.net/account/alibaba AccountID 188077086902**** AccessKeyID yourAccessKeyID AccessKeySecret yourAccessKeySecret Please create alias for key pair. If not, please enter to skip default Alias: default AccountID: 188077086902**** AccessKeyID: yourAccessKeyID AccessKeySecret: yourAccessKeySecret Configuration successfulYou can find your Account ID and AccessKey ID in the Overview page of the Function Compute console under the Common Information section.
Serverless Devs also supports adding keys through commands. For example, run the following command to configure Alibaba Cloud key information:
s config add --AccessKeyID yourAccessKeyID --AccessKeySecret yourAccessKeySecret --AccountID 188077086902**** --access ***ImportantTo manage multiple keys easily, Serverless Devs supports multi-key management. When configuring a key, assign it an alias (aliasName). Then, specify a particular key by its alias when using it for specific tasks. Examples include the following:
-
Separating environments using different aliases for different accounts and deploying resources under different accounts—for example, using Account A for production and Account B for staging.
-
Applying access control to keys so that each key has only the permissions needed for its assigned task. Examples include the following:
-
Configuring a key with the alias website-access for website deployment only.
-
Configuring a key with the alias fc-access for function deployment only.
-
-
Get key information
Parameter description:
-
-a or --access: Specifies the alias name.
-
-h or --help: Displays help information.
Run the following commands to get key information:
-
Get the key information for a specific alias. For example, use -a to specify the alias default:
s config get -a defaultSample output:
default: AccountID: 188077086902**** AccessKeyID: yourAccessKeyID AccessKeySecret: yourAccessKeySecret -
Get all key information:
s config getSample output:
default: AccountID: 188077086902**** AccessKeyID: yourAccessKeyID AccessKeySecret: yourAccessKeySecret default-1: AccountID: 188077086902**** AccessKeyID: yourAccessKeyID AccessKeySecret: yourAccessKeySecret
Run the s config get -h command to get more information about this command.
Delete key information
Parameter description:
-
-a or --access: Specifies the alias name.
-
-h or --help: Displays help information.
Run the following command to delete a key. Use -a to specify the alias.
s config delete -a aliasName