Creates a trigger.
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
fc:CreateTrigger |
create |
*All Resource
|
None | None |
Request syntax
POST /2021-04-06/services/{serviceName}/functions/{functionName}/triggers HTTP/1.1
Path Parameters
|
Parameter |
Type |
Required |
Description |
Example |
| serviceName |
string |
Yes |
The name of the service. |
demoService |
| functionName |
string |
Yes |
The name of the function. |
demoFunction |
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| body |
object |
No |
The definition of the trigger. |
|
| invocationRole |
string |
No |
The role that the event source (such as OSS) uses to invoke the function. For more information, see Trigger overview. |
acs:ram::1234567890:role/fc-test |
| qualifier |
string |
No |
The version or alias of the service. |
LATEST |
| sourceArn |
string |
No |
The Alibaba Cloud Resource Name (ARN) of the trigger event source. This parameter can be ignored for timer, HTTP, and EventBridge triggers. This parameter is required for other trigger types. For EventBridge triggers, if you specify this field, an existing EventBridge resource is associated with the trigger. Do not configure the same sourceArn for two different EventBridge triggers. Otherwise, the update or delete operations of the triggers affect each other. |
acs:oss:cn-shanghai:12345:mybucket |
| triggerConfig |
string |
Yes |
The trigger configuration, which varies based on the trigger type. For the specific format, refer to the following data structures:
|
{"events": ["oss:ObjectCreated:*"], "filter": {"key": {"prefix": "/prefix", "suffix": ".zip"}}} |
| triggerName |
string |
Yes |
The name of the trigger. The name can contain only letters, digits, underscores (_), and hyphens (-). The name cannot start with a digit or hyphen (-). The name must be 1 to 128 characters in length. |
oss_create_object_demo |
| triggerType |
string |
Yes |
The type of the trigger. Valid values:
Valid values:
|
oss |
| description |
string |
No |
The description of the trigger. |
trigger for test |
| X-Fc-Account-Id |
string |
No |
The ID of your Alibaba Cloud account. |
188077086902**** |
| X-Fc-Date |
string |
No |
The time when the client sends the request. The format is EEE,d MMM yyyy HH:mm:ss GMT. |
Wed, 11 May 2022 09:00:00 GMT |
| X-Fc-Trace-Id |
string |
No |
The custom request ID. |
my-test-trace-id |
Response elements
|
Element |
Type |
Description |
Example |
|
object |
The trigger definition. |
||
| createdTime |
string |
The time when the trigger was created. |
2016-08-15T15:00:00.000+0000 |
| invocationRole |
string |
The ARN of the RAM role that the event source uses to invoke the function. |
acs:ram::1234567890:role/fc-test |
| lastModifiedTime |
string |
The time when the trigger was last modified. |
016-08-15T17:00:00.000+0000 |
| qualifier |
string |
The version of the service. |
LATEST |
| sourceArn |
string |
The Alibaba Cloud Resource Name (ARN) of the event source. |
acs:oss:cn-shanghai:12345:mybucket |
| triggerConfig |
string |
The trigger configuration, which varies based on the trigger type. |
{"events": ["oss:ObjectCreated:*"], "filter": {"key": {"prefix": "/prefix", "suffix": ".zip"}}} |
| triggerName |
string |
The name of the trigger. The name can contain only letters, digits, underscores (_), and hyphens (-). The name cannot start with a digit or hyphen (-). The name must be 1 to 128 characters in length. |
oss_create_object_trigger_demo |
| triggerType |
string |
The type of the trigger, such as oss, log, tablestore, timer, http, cdn_events, mns_topic, or eventbridge. |
oss |
| description |
string |
The description of the trigger. |
trigger for test |
| triggerId |
string |
The unique ID of the trigger. |
3e270f2f-cef2-421a-bc86-ff4e8088**** |
| domainName |
string |
The domain name. You can concatenate the domain name with the Function Compute endpoint to invoke the function of the corresponding version by using the HTTP protocol. Example: |
demo-service-demo-function-jkhksh |
| urlInternet |
string |
The public domain name. You can access the HTTP trigger over the Internet by using the HTTP or HTTPS protocol. |
https://svc-func-xxxxxxxx.cn-hangzhou.fcapp.run |
| urlIntranet |
string |
The private endpoint. You can access the HTTP trigger within a VPC by using the HTTP or HTTPS protocol. |
https://svc-func-xxxxxxxx.cn-hangzhou-vpc.fcapp.run |
Examples
Success response
JSON format
{
"createdTime": "2016-08-15T15:00:00.000+0000",
"invocationRole": "acs:ram::1234567890:role/fc-test",
"lastModifiedTime": "016-08-15T17:00:00.000+0000",
"qualifier": "LATEST",
"sourceArn": "acs:oss:cn-shanghai:12345:mybucket",
"triggerConfig": "{\"events\": [\"oss:ObjectCreated:*\"], \"filter\": {\"key\": {\"prefix\": \"/prefix\", \"suffix\": \".zip\"}}}",
"triggerName": "oss_create_object_trigger_demo",
"triggerType": "oss",
"description": "trigger for test",
"triggerId": "3e270f2f-cef2-421a-bc86-ff4e8088****",
"domainName": "demo-service-demo-function-jkhksh",
"urlInternet": "https://svc-func-xxxxxxxx.cn-hangzhou.fcapp.run",
"urlIntranet": "https://svc-func-xxxxxxxx.cn-hangzhou-vpc.fcapp.run"
}
Error codes
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.