The FC component is a Serverless Devs-based CLI tool for Function Compute that lets you run interactive commands to manage service aliases. All commands call the Function Compute API directly using the prefix sudo s cli fc api.
Prerequisites
Before you begin, ensure that you have:
Create an alias
Syntax
sudo s cli fc api CreateAlias
--region <region-id>
[--access <access-name>]
[--apiVersion <20210416|20160815>]
--path '{"serviceName": "<service-name>"}'
[--body '{"aliasName": "<alias-name>",
"versionId": "<version-id>",
"additionalVersionWeight": <weight-config>,
"description": "<description>"}']Parameters
| Parameter | Required | Description |
|---|---|---|
--region | Yes | The region where the service is deployed. |
--access / -a | No | The alias of the AccessKey to use. |
--apiVersion | No | The API version. Valid values: 20210416, 20160815. |
--path.serviceName | Yes | The name of the service. |
--body.aliasName | No | The name of the alias. |
--body.versionId | No | The version that the alias points to. |
--body.additionalVersionWeight | No | The canary release version and its traffic weight. For example, {"2": 0.05} routes 5% of traffic to version 2. |
--body.description | No | The description of the alias. |
Example
Create alias aliastest pointing to version 1 of service mytest in the cn-hangzhou region:
sudo s cli fc api CreateAlias --region cn-hangzhou --access default --path '{"serviceName": "mytest"}' --body '{"aliasName": "aliastest","versionId": "1"}'For more information, see CreateAlias.
Delete an alias
Syntax
sudo s cli fc api DeleteAlias
--region <region-id>
[--access <access-name>]
[--apiVersion <20210416|20160815>]
--path '{"serviceName": "<service-name>", "aliasName": "<alias-name>"}'Parameters
| Parameter | Required | Description |
|---|---|---|
--region | Yes | The region where the service is deployed. |
--access / -a | No | The alias of the AccessKey to use. |
--apiVersion | No | The API version. Valid values: 20210416, 20160815. |
--path.serviceName | Yes | The name of the service. |
--path.aliasName | Yes | The name of the alias to delete. |
Example
Delete alias aliastest from service mytest:
sudo s cli fc api DeleteAlias --region cn-hangzhou --access default --path '{"serviceName": "mytest","aliasName": "aliastest"}'For more information, see DeleteAlias.
Update an alias
Syntax
sudo s cli fc api UpdateAlias
--region <region-id>
[--access <access-name>]
[--apiVersion <20210416|20160815>]
--path '{"serviceName": "<service-name>", "aliasName": "<alias-name>"}'
[--body '{"versionId": "<version-id>",
"additionalVersionWeight": <weight-config>,
"description": "<description>"}']Parameters
| Parameter | Required | Description |
|---|---|---|
--region | Yes | The region where the service is deployed. |
--access / -a | No | The alias of the AccessKey to use. |
--apiVersion | No | The API version. Valid values: 20210416, 20160815. |
--path.serviceName | Yes | The name of the service. |
--path.aliasName | Yes | The name of the alias to update. |
--body.versionId | No | The version that the alias points to. |
--body.additionalVersionWeight | No | The canary release version and its traffic weight. For example, {"2": 0.05} routes 5% of traffic to version 2. |
--body.description | No | The description of the alias. |
Example
Route 5% of traffic to version 2 as a canary release, keeping 95% on the current stable version:
sudo s cli fc api UpdateAlias --region cn-hangzhou --access default --path '{"serviceName": "mytest","aliasName": "aliastest"}' --body '{"additionalVersionWeight": {"2":0.05}}'For more information, see UpdateAlias.
Get an alias
Syntax
sudo s cli fc api GetAlias
--region <region-id>
[--access <access-name>]
[--apiVersion <20210416|20160815>]
--path '{"serviceName": "<service-name>", "aliasName": "<alias-name>"}'Parameters
| Parameter | Required | Description |
|---|---|---|
--region | Yes | The region where the service is deployed. |
--access / -a | No | The alias of the AccessKey to use. |
--apiVersion | No | The API version. Valid values: 20210416, 20160815. |
--path.serviceName | Yes | The name of the service. |
--path.aliasName | Yes | The name of the alias to query. |
Example
Get details for alias aliastest in service mytest:
sudo s cli fc api GetAlias --region cn-hangzhou --access default --path '{"serviceName": "mytest","aliasName": "aliastest"}'For more information, see GetAlias.
List aliases
Syntax
sudo s cli fc api ListAliases
--region <region-id>
[--access <access-name>]
[--apiVersion <20210416|20160815>]
--path '{"serviceName": "<service-name>"}'
[--query '{"limit": "<count>",
"nextToken": "<token>",
"prefix": "<name-prefix>",
"startKey": "<start-key>"}']Parameters
| Parameter | Required | Description |
|---|---|---|
--region | Yes | The region where the service is deployed. |
--access / -a | No | The alias of the AccessKey to use. |
--apiVersion | No | The API version. Valid values: 20210416, 20160815. |
--path.serviceName | Yes | The name of the service. |
--query.limit | No | The maximum number of aliases to return. |
--query.nextToken | No | The pagination token from the previous response. Include this parameter to retrieve the next page of results. Omit it on the first call. |
--query.prefix | No | Filters results to aliases whose names start with this prefix. |
--query.startKey | No | Returns aliases in alphabetical order starting from (and including) this key. |
Example
List up to 3 aliases in service mytest:
sudo s cli fc api ListAliases --region cn-hangzhou --access default --path '{"serviceName": "mytest"}' --query '{"limit": "3"}'For more information, see ListAliases.