ALIYUN::FC::FunctionInvoker

更新时间:
复制 MD 格式

Invokes a Function Compute function.

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

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:

  • true

  • false (default)

Event

String

No

Yes

The event payload passed to the function.

The value is encoded as a UTF-8 string and passed to the function during execution. To pass a binary or non-UTF-8 encoded string, encode the value in Base64 first.

Qualifier

String

No

Yes

The service version or alias.

Valid values:

  • versionId

  • aliasName

ExecuteVersion

Integer

No

Yes

The invocation trigger version. If you specify this property when you create the resource, the function is invoked. Otherwise, the function is not invoked.

If you change this property to a new integer value when you update the resource, the function is invoked. Otherwise, the function is not invoked.

None.

CheckError

Boolean

No

No

Specifies whether to check the invocation result.

Valid values:

  • true

    Note

    If this property is set to true and the invocation fails, the resource fails to be created.

  • false (default)

ServiceRegionId

String

No

No

The region ID of the function service.

None.

CheckAsyncInvocation

Map

No

No

The check configurations for asynchronous invocations.

For more information, see CheckAsyncInvocation properties in this topic.

CheckAsyncInvocation syntax

"CheckAsyncInvocation": {
  "Enabled": Boolean,
  "CheckInterval": Integer,
  "CheckTimes": Integer
}

CheckAsyncInvocation properties

Property

Type

Required

Editable

Description

Constraint

Enabled

Boolean

Yes

No

Specifies whether to check the asynchronous invocation result.

If both this property and Async are set to true, the resource is created only after the asynchronous invocation completes and the result is checked.

Default value: false.

CheckInterval

Integer

Yes

No

The interval between consecutive checks on the asynchronous invocation result.

Default value: 10. Unit: seconds.

CheckTimes

Integer

Yes

No

The number of checks on the asynchronous invocation result.

Default value: 10.

Return values

Fn::GetAtt

  • ResultType:

    • If Async is set to true and ResultType is set to NoResult, no result is returned.

    • If Async is set to false and ResultType is set to Success, the invocation is successful.

    • If Async is set to false and ResultType is set to Failure, the invocation fails.

  • Result:

    • If ResultType is set to NoResult, the value of Result is null.

    • If ResultType is set to Success, the value of Result is the function invocation result. The returned result must be a UTF-8 encoded string. Otherwise, the invocation fails. To return a binary or non-UTF-8 encoded string, encode the result in Base64 first.

    • If ResultType is set to Failure, an error message is returned for Result.

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": {
  }
}