Invokes a Function Compute (FC) 3.0 function.
Syntax
{
"Type": "ALIYUN::FC3::FunctionInvoker",
"Properties": {
"FunctionName": String,
"Async": Boolean,
"CheckError": Boolean,
"CheckAsyncInvocation": Map,
"ExecuteVersion": Integer,
"Event": String,
"Qualifier": String,
"ServiceRegionId": String
}
}Properties
Property | Type | Required | Update allowed | Description | Constraints |
FunctionName | String | Yes | Yes | The function name. | None |
Async | Boolean | No | Yes | Enables asynchronous invocation. | Valid values:
|
CheckError | Boolean | No | No | Checks the invocation result. | Valid values:
|
CheckAsyncInvocation | Map | No | No | The settings for asynchronous invocation checks. | For more information, see CheckAsyncInvocation properties. |
ExecuteVersion | Integer | No | Yes | On resource creation, the function runs only if this parameter is specified. On resource update, the function runs only if this value changes to a new integer. | None |
Event | String | No | Yes | The custom input for the function. | Passed to the function as a UTF-8 encoded string. To pass binary or other encodings, Base64-encode the value first. |
Qualifier | String | No | Yes | The service version. | Valid values:
|
ServiceRegionId | String | No | No | The region of the Function Compute service. | None |
CheckAsyncInvocation syntax
"CheckAsyncInvocation": {
"CheckTimes": Integer,
"CheckInterval": Integer,
"Enabled": Boolean
}CheckAsyncInvocation properties
Property | Type | Required | Update allowed | Description | Constraints |
CheckTimes | Integer | Yes | No | The number of checks for asynchronous invocation results. | Default: 10. |
CheckInterval | Integer | Yes | No | The interval between asynchronous invocation result checks. | Default: 10 seconds. |
Enabled | Boolean | Yes | No | Specifies whether to enable asynchronous invocation result checking. | If set to true and invocation is asynchronous, resource creation waits for completion and checks the result. Default: false. |
Return values
Fn::GetAtt
ResultType: Async invocation result type.
NoResult: Async invocation (Async is true). No return value.
Success: Sync invocation (Async is false) succeeded.
Failure: Sync invocation (Async is false) failed.
Result: Async invocation result.
If ResultType is NoResult, this attribute is empty.
If ResultType is Success, Result is the result returned by the
invoke functionoperation, in the form of a string, and the specific content is defined by the user. The returned result must be a UTF-8 encoded string; otherwise, ROS will consider the function execution to have failed. If you need to return binary data or a string in another encoding, you can encode it with Base64 before returning it.If ResultType is Failure, Result contains the error message.
Events: Async invocation events.
TaskId: Async invocation task ID.
Examples
ROSTemplateFormatVersion: '2015-09-01'
Parameters:
FunctionName:
Type: String
Description:
en: The name of the function.
Required: true
Resources:
FunctionInvoker:
Type: ALIYUN::FC3::FunctionInvoker
Properties:
FunctionName:
Ref: FunctionName
Outputs:
ResultType:
Description: |-
Result type:
NoResult: Async invoke has no result.
Success: Sync invoke succeeds.
Failure: Sync invoke fails.
Value:
Fn::GetAtt:
- FunctionInvoker
- ResultType
Result:
Description: |-
Depends on result type:
NoResult: Async invoke has no result.
Success: The response of the function. The response should be utf-8 encoded string, otherwise ROS will report an error. If the response is binary, encode it via base64 before it is returned.
Failure: Error Message.
Value:
Fn::GetAtt:
- FunctionInvoker
- Result
{
"ROSTemplateFormatVersion": "2015-09-01",
"Parameters": {
"FunctionName": {
"Type": "String",
"Description": {
"en": "The name of the function."
},
"Required": true
}
},
"Resources": {
"FunctionInvoker": {
"Type": "ALIYUN::FC3::FunctionInvoker",
"Properties": {
"FunctionName": {
"Ref": "FunctionName"
}
}
}
},
"Outputs": {
"ResultType": {
"Description": "Result type:\nNoResult: Async invoke has no result.\nSuccess: Sync invoke succeeds.\nFailure: Sync invoke fails.",
"Value": {
"Fn::GetAtt": [
"FunctionInvoker",
"ResultType"
]
}
},
"Result": {
"Description": "Depends on result type:\nNoResult: Async invoke has no result.\nSuccess: The response of the function. The response should be utf-8 encoded string, otherwise ROS will report an error. If the response is binary, encode it via base64 before it is returned.\nFailure: Error Message.",
"Value": {
"Fn::GetAtt": [
"FunctionInvoker",
"Result"
]
}
}
}
}