The ALIYUN::FC::FunctionInvoker type enables you to actively execute functions.
Syntax
{
"Type": "ALIYUN::FC::FunctionInvoker",
"Properties": {
"Qualifier": String,
"ServiceName": String,
"ExecuteVersion": Integer,
"Async": Boolean,
"Event": String,
"FunctionName": String,
"CheckError": Boolean,
"ServiceRegionId": String,
"CheckAsyncInvocation": Map
}
}
Properties
Property name | Type | Required | Editable | Description | Constraint |
ServiceName | String | Yes | Yes | The name of the service. | The name must be 1 to 128 characters in length. |
FunctionName | String | Yes | Yes | The name of the function. | None |
Async | Boolean | No | Yes | Specifies whether to invoke the function asynchronously. | Valid values:
|
Event | String | No | Yes | The custom input parameter of the function. | This parameter is encoded as a UTF-8 string and passed to the function during execution. If you need to pass binary or strings in other encodings, you can first encode them using Base64 before passing them to this parameter. |
Qualifier | String | No | Yes | The version of the service. | Valid values:
|
ExecuteVersion | Integer | No | Yes | When creating this resource, if this parameter is not specified, the function will not be invoked. Otherwise, the function will be invoked. When updating this resource, if this parameter changes and the new value is an integer, the function will be invoked. Otherwise, the function will not be invoked. | None |
CheckError | Boolean | No | No | Specifies whether to check the invocation result. | Valid values:
|
ServiceRegionId | String | No | No | The region to which the function service belongs. | None |
CheckAsyncInvocation | Map | No | No | The settings for checking asynchronous invocation. | For more information, see the CheckAsyncInvocation properties. |
CheckAsyncInvocation syntax
"CheckAsyncInvocation": {
"Enabled": Boolean,
"CheckInterval": Integer,
"CheckTimes": Integer
}
CheckAsyncInvocation properties
Property name | Type | Required | Editable | Description | Constraint |
Enabled | Boolean | Yes | No | Specifies whether to check the asynchronous invocation result. | If set to true and the function invocation type is asynchronous, the resource creation will wait for the invocation to complete and check the result. The default value is false. |
CheckInterval | Integer | Yes | No | The interval for checking the asynchronous invocation result. | Default value: 10. Unit: seconds. |
CheckTimes | Integer | Yes | No | The number of times to check the asynchronous invocation result. | Default value: 10. |
Return values
Fn::GetAtt
ResultType:
When Async is true and ResultType is NoResult, it indicates that there is no invocation result.
When Async is false and ResultType is Success, it indicates that the execution was successful.
When Async is false and ResultType is Failure, it indicates that the execution failed.
Result:
When ResultType is NoResult, Result is empty.
When ResultType is Success, Result is the result returned by the invoke function (string), and the specific content is interpreted by the user. The returned result must be a UTF-8 encoded string, otherwise ROS will consider the function execution as failed. If you need to return binary or strings in other encodings, you can encode them using Base64 before returning.
When ResultType is Failure, Result is the error message.
Examples
ROSTemplateFormatVersion: '2015-09-01'
Parameters: {}
Resources:
FunctionInvoker:
Type: ALIYUN::FC::FunctionInvoker
Properties:
ServiceName: mytest
FunctionName: PythonFunc
ExecuteVersion: 1
Outputs: {}
{
"ROSTemplateFormatVersion": "2015-09-01",
"Parameters": {
},
"Resources": {
"FunctionInvoker": {
"Type": "ALIYUN::FC::FunctionInvoker",
"Properties": {
"ServiceName": "mytest",
"FunctionName": "PythonFunc",
"ExecuteVersion": 1.0
}
}
},
"Outputs": {
}
}