Use the FC component — a Serverless Devs-based tool — to manage Function Compute triggers from the command line. All commands follow the same pattern: s cli fc api <Operation>.
Prerequisites
Before you begin, ensure that you have:
(Optional) Created an Object Storage Service (OSS) bucket — required for OSS triggers. The bucket and function must be in the same region.
(Optional) Created a Message Service (MNS) topic — required for MNS triggers.
(Optional) For Tablestore triggers: created a Tablestore instance and created tables
(Optional) For CDN triggers: created an OSS bucket and added a domain name
Create a trigger
Syntax
sudo s cli fc api CreateTrigger \
--region <region-id> \
[--access <access-alias>] \
[--apiVersion <20210416|20160815>] \
--path '{"serviceName": "<service-name>", "functionName": "<function-name>"}' \
--body '{
"triggerName": "<trigger-name>",
"triggerType": "<trigger-type>",
"triggerConfig": <trigger-config>,
"invocationRole": "<role-arn>",
"sourceArn": "<source-arn>",
"qualifier": "<version-or-alias>"
}'Parameters
| Parameter | Required | Description |
|---|---|---|
--region | Yes | Region where your resources are deployed |
--access, -a | No | Alias of the access key to use |
--apiVersion | No | API version. Valid values: 20210416, 20160815 |
--serviceName (in --path) | Yes | Name of the service |
--functionName (in --path) | Yes | Name of the function |
--triggerName (in --body) | Yes | Name of the trigger |
--triggerType (in --body) | Yes | Trigger type. Supported types: OSS event triggers, Simple Log Service triggers, time triggers, HTTP triggers, Tablestore triggers, CDN event triggers, and MNS topic triggers |
--triggerConfig (in --body) | Yes | Trigger configuration in JSON format |
--invocationRole (in --body) | Yes | The role that is required by the trigger to invoke the function |
--sourceArn (in --body) | Yes | ARN of the event source |
--qualifier (in --body) | No | Service version or alias to target |
Example: create a timer trigger that fires every minute
macOS or Linux:
sudo s cli fc api CreateTrigger \
--region cn-hangzhou \
--access default \
--path '{"serviceName": "mytest", "functionName": "mytest"}' \
--body '{"triggerName": "mytrigger", "triggerConfig": {"payload": "", "cronExpression": "@every 1m", "enable": true}, "triggerType": "timer"}'Windows:
s cli fc api CreateTrigger \
--region cn-hangzhou \
--access default \
--path '{"serviceName": "mytest", "functionName": "mytest"}' \
--body '{"triggerName": "mytrigger", "triggerConfig": {\"payload\": \"\", \"cronExpression\": \"@every 1m\", \"enable\": true}, "triggerType": "timer"}'For details about the underlying API operation, see CreateTrigger.
Delete a trigger
Syntax
sudo s cli fc api DeleteTrigger \
--region <region-id> \
[--access <access-alias>] \
[--apiVersion <20210416|20160815>] \
--path '{"serviceName": "<service-name>", "functionName": "<function-name>", "triggerName": "<trigger-name>"}' \
[--header '{"If-Match": "<etag>"}']Parameters
| Parameter | Required | Description |
|---|---|---|
--region | Yes | Region where your resources are deployed |
--access, -a | No | Alias of the access key to use |
--apiVersion | No | API version. Valid values: 20210416, 20160815 |
--serviceName (in --path) | Yes | Name of the service |
--functionName (in --path) | Yes | Name of the function |
--triggerName (in --path) | Yes | Name of the trigger to delete |
--If-Match (in --header) | No | Ensures that the changed resource is the resource that you want to change |
Example
sudo s cli fc api DeleteTrigger \
--region cn-hangzhou \
--access default \
--path '{"serviceName": "mytest", "functionName": "mytest", "triggerName": "mytrigger"}'For details about the underlying API operation, see DeleteTrigger.
Update a trigger
Syntax
sudo s cli fc api UpdateTrigger \
--region <region-id> \
[--access <access-alias>] \
[--apiVersion <20210416|20160815>] \
--path '{"serviceName": "<service-name>", "functionName": "<function-name>", "triggerName": "<trigger-name>"}' \
--body '{
"invocationRole": "<role-arn>",
"qualifier": "<version-or-alias>",
"triggerConfig": <trigger-config>
}' \
[--header '{"If-Match": "<etag>"}']Parameters
| Parameter | Required | Description |
|---|---|---|
--region | Yes | Region where your resources are deployed |
--access, -a | No | Alias of the access key to use |
--apiVersion | No | API version. Valid values: 20210416, 20160815 |
--serviceName (in --path) | Yes | Name of the service |
--functionName (in --path) | Yes | Name of the function |
--triggerName (in --path) | Yes | Name of the trigger to update |
--invocationRole (in --body) | Yes | The role that is required by the trigger to invoke the function |
--qualifier (in --body) | Yes | Service version or alias to target |
--triggerConfig (in --body) | Yes | Updated trigger configuration in JSON format |
--If-Match (in --header) | No | Ensures that the changed resource is the resource that you want to change |
Example: disable a timer trigger
macOS or Linux:
sudo s cli fc api UpdateTrigger \
--region cn-hangzhou \
--access default \
--path '{"serviceName": "mytest", "functionName": "mytest", "triggerName": "mytrigger"}' \
--body '{"triggerConfig": {"payload": "", "cronExpression": "@every 1m", "enable": false}}'Windows:
s cli fc api UpdateTrigger \
--region cn-hangzhou \
--access default \
--path '{"serviceName": "mytest", "functionName": "mytest", "triggerName": "mytrigger"}' \
--body '{"triggerConfig": {\"payload\": \"\", \"cronExpression\": \"@every 1m\", \"enable\": false}}'For details about the underlying API operation, see UpdateTrigger.
Get trigger configuration
Syntax
sudo s cli fc api GetTrigger \
--region <region-id> \
[--access <access-alias>] \
[--apiVersion <20210416|20160815>] \
--path '{"serviceName": "<service-name>", "functionName": "<function-name>", "triggerName": "<trigger-name>"}'Parameters
| Parameter | Required | Description |
|---|---|---|
--region | Yes | Region where your resources are deployed |
--access, -a | No | Alias of the access key to use |
--apiVersion | No | API version. Valid values: 20210416, 20160815 |
--serviceName (in --path) | Yes | Name of the service |
--functionName (in --path) | Yes | Name of the function |
--triggerName (in --path) | Yes | Name of the trigger |
Example
sudo s cli fc api GetTrigger \
--region cn-hangzhou \
--access default \
--path '{"serviceName": "mytest", "functionName": "mytest", "triggerName": "mytrigger"}'For details about the underlying API operation, see GetTrigger.
List triggers
Syntax
sudo s cli fc api ListTriggers \
--region <region-id> \
[--access <access-alias>] \
[--apiVersion <20210416|20160815>] \
--path '{"serviceName": "<service-name>", "functionName": "<function-name>"}' \
[--query '{"limit": "<count>", "nextToken": "<token>", "prefix": "<name-prefix>", "startKey": "<start-key>"}']Parameters
| Parameter | Required | Description |
|---|---|---|
--region | Yes | Region where your resources are deployed |
--access, -a | No | Alias of the access key to use |
--apiVersion | No | API version. Valid values: 20210416, 20160815 |
--serviceName (in --path) | Yes | Name of the service |
--functionName (in --path) | Yes | Name of the function |
--limit (in --query) | No | Maximum number of triggers to return |
--nextToken (in --query) | No | Pagination token from a previous response. Omit this parameter in the first request |
--prefix (in --query) | No | Filter results to triggers whose names start with this prefix |
--startKey (in --query) | No | Return results starting from this key, inclusive, in alphabetical order |
Example
sudo s cli fc api ListTriggers \
--region cn-hangzhou \
--access default \
--path '{"serviceName": "mytest", "functionName": "mytest"}'For details about the underlying API operation, see ListTriggers.