The FC component is a Serverless Devs-based CLI tool for Function Compute. Use it to call the Function Compute API directly from your terminal.
Prerequisites
Before you begin, ensure that you have:
Create a service
Synopsis
sudo s cli fc api CreateService
--region <region-id>
[--access <access-name>]
[--apiVersion <20210416|20160815>]
--body '{"serviceName": "<service-name>"
[,"description": "<description>"]
[,"internetAccess": true|false]
[,"logConfig": "<log-config>"]
[,"nasConfig": "<nas-config>"]
[,"role": "<ram-role>"]
[,"vpcConfig": "<vpc-config>"]
[,"tracingConfig": "Enable"|"Disable"]}'Parameters
| Parameter | Required | Description |
|---|---|---|
--region | Yes | Region where you want to deploy the service |
--access / -a | No | Alias of the key to use |
--apiVersion | No | API version. Valid values: 20210416, 20160815 |
serviceName (body) | Yes | Service name |
description (body) | No | Service description |
internetAccess (body) | No | Specifies whether the function can access the internet. Valid values: true, false |
logConfig (body) | No | Log configuration. Specifies the Logstore to store function logs |
nasConfig (body) | No | File Storage NAS (NAS) configuration. Specifies the NAS file system for the function to access |
role (body) | No | Resource Access Management (RAM) role |
vpcConfig (body) | No | Virtual Private Cloud (VPC) configuration. Specifies the VPC the function can access |
tracingConfig (body) | No | Specifies whether to enable Managed Service for OpenTelemetry. Valid values: Enable, Disable |
Example
sudo s cli fc api CreateService --region cn-hangzhou --access default --body '{"description": "mytest","serviceName": "mytest"}'For the full API reference, see CreateService.
Delete a service
Synopsis
sudo s cli fc api DeleteService
--region <region-id>
[--access <access-name>]
[--apiVersion <20210416|20160815>]
--path '{"serviceName": "<service-name>"}'
[--header '{"If-Match": "<etag>"}']Parameters
| Parameter | Required | Description |
|---|---|---|
--region | Yes | Region where the service is deployed |
--access / -a | No | Alias of the key to use |
--apiVersion | No | API version. Valid values: 20210416, 20160815 |
serviceName (path) | Yes | Service name |
If-Match (header) | No | Ensures that the changed resource is the resource that you want to change |
Example
sudo s cli fc api DeleteService --region cn-hangzhou --access default --path '{"serviceName": "mytest"}'For the full API reference, see DeleteService.
Update a service
Synopsis
sudo s cli fc api UpdateService
--region <region-id>
[--access <access-name>]
[--apiVersion <20210416|20160815>]
--path '{"serviceName": "<service-name>"}'
[--body '{"description": "<description>"
[,"internetAccess": true|false]
[,"role": "<ram-role>"]
[,"logConfig": "<log-config>"]
[,"nasConfig": "<nas-config>"]
[,"vpcConfig": "<vpc-config>"]
[,"tracingConfig": "Enable"|"Disable"]}']
[--header '{"If-Match": "<etag>"}']Parameters
| Parameter | Required | Description |
|---|---|---|
--region | Yes | Region where the service is deployed |
--access / -a | No | Alias of the key to use |
--apiVersion | No | API version. Valid values: 20210416, 20160815 |
serviceName (path) | Yes | Service name |
description (body) | No | Service description |
internetAccess (body) | No | Specifies whether the function can access the internet. Valid values: true, false |
role (body) | No | RAM role |
logConfig (body) | No | Log configuration. Specifies the Logstore to store function logs |
nasConfig (body) | No | File Storage NAS (NAS) configuration. Specifies the NAS file system for the function to access |
vpcConfig (body) | No | VPC configuration. Specifies the VPC the function can access |
tracingConfig (body) | No | Specifies whether to enable Managed Service for OpenTelemetry. Valid values: Enable, Disable |
If-Match (header) | No | Ensures that the changed resource is the resource that you want to change |
Example
sudo s cli fc api UpdateService --region cn-hangzhou --access default --path '{"serviceName": "mytest"}' --body '{"internetAccess": false}'For the full API reference, see UpdateService.
Get service configurations
Synopsis
sudo s cli fc api GetService
--region <region-id>
[--access <access-name>]
[--apiVersion <20210416|20160815>]
--path '{"serviceName": "<service-name>"
[,"qualifier": "<version-or-alias>"]}'Parameters
| Parameter | Required | Description |
|---|---|---|
--region | Yes | Region where the service is deployed |
--access / -a | No | Alias of the key to use |
--apiVersion | No | API version. Valid values: 20210416, 20160815 |
serviceName (path) | Yes | Service name |
qualifier (path) | No | Service version or alias |
Example
sudo s cli fc api GetService --region cn-hangzhou --access default --path '{"serviceName": "mytest","qualifier": "LATEST"}'For the full API reference, see GetService.
List services
ListServices is a paginated operation. Use limit to control the page size and nextToken to retrieve subsequent pages. Omit nextToken on the first call; include the token returned in each response to get the next page.
Synopsis
sudo s cli fc api ListServices
--region <region-id>
[--access <access-name>]
[--apiVersion <20210416|20160815>]
[--query '{"limit": "<count>"
[,"nextToken": "<token>"]
[,"prefix": "<name-prefix>"]
[,"startKey": "<start-key>"]}']Parameters
| Parameter | Required | Description |
|---|---|---|
--region | Yes | Region to query |
--access / -a | No | Alias of the key to use |
--apiVersion | No | API version. Valid values: 20210416, 20160815 |
limit (query) | No | Maximum number of services to return per page |
nextToken (query) | No | Pagination token from the previous response. Omit on the first call |
prefix (query) | No | Filters results to services whose names start with this prefix |
startKey (query) | No | Returns services alphabetically starting from (and including) this key |
Example
sudo s cli fc api ListServices --region cn-hangzhou --access default --query '{"limit": "10","prefix": "my"}'For the full API reference, see ListServices.