更新时间:2023-04-20 GMT+08:00
分享

FGS.Function

模型说明

FGS.Function用于创建函数工作流服务的函数资源。

模型属性

表1 模型定义属性说明

属性

是否必选

描述

code

函数代码

参数类型:string

取值说明:当codeType为inline时,该字段必选,且代码大小不超过10K;当codeType为obs时,该字段为空。在模板中直接编辑函数代码块,使用特殊符号'|'保留函数代码块中的回车和空格。YAML书写规范请参考:http://yaml.org/spec/1.2/spec.html

默认值:""

取值约束:如果采用在线编辑的方式上传函数代码,代码大小不能超过10K。若代码较大,建议obs的方式,将代码上传至OBS桶,然后配置codeUrl属性

使用建议:将编辑完成的正确函数代码通过复制粘贴的方式填入该字段

description

函数的描述信息

参数类型:string

取值说明:描述信息大小不超过512个字符

取值约束:{u'min_length': 0, u'max_length': 512}

使用建议:将该字段通过get_input函数传入,在AOS界面创建资源栈填写输入参数时可获取

memorySize

函数消耗的内存

参数类型:integer

取值说明:单位MB。取值为128的倍数

默认值:128

取值约束:有效值为128, 256, 512, 768, 1024, 1280, 1536

使用建议:将该字段通过get_input函数传入,在AOS界面创建资源栈填写输入参数时可获取

environment

环境变量

参数类型:FGS.Environment

取值说明:用户自定义的key/value 环境变量信息,在函数中使用的参数。举例:如函数要访问某个主机,可以设置环境变量:Host:192.168.1.1。 环境变量不超过20组,总长度不超过2048个字符,为避免信息泄露,请不要在环境变量中输入账号、密码等敏感信息。

默认值:{u'variables': {}}

dependencyPkg

函数依赖代码包的地址

参数类型:string

取值说明:该字段可选,配置该字段前请将函数依赖的第三方软件包上传到obs服务上,多个第三方软件打包到同一个zip文件中

使用建议:该字段通过get_input函数传入,在AOS界面创建资源栈填写输入参数时可获取

handler

函数执行入口

参数类型:string

取值说明:规则:xx.xx,必须包含.。举例:对于node.js函数:myfunction.handler,则表示函数的文件名为 myfunction.js,执行的入口函数名为handler

默认值:index.handler

使用建议:该字段通过get_input函数传入,在AOS界面创建资源栈填写输入参数时可获取

role

函数使用的权限委托名称

参数类型:string

取值说明:需要IAM 支持,并在IAM 界面创建委托,当函数需要访问其他服务时,必须提供该字段

timeout

函数的超时时间

参数类型:integer

取值说明:超时函数将被强行停止

默认值:3

取值约束:范围3~300秒

使用建议:将该字段通过get_input函数传入,在AOS界面创建资源栈填写输入参数时可获取

codeType

函数代码上传的类型

参数类型:string

取值说明:支持inline和obs。inline类型表示在线编辑函数代码,obs类型需将函数代码预先上传至OBS桶,然后配置codeUrl属性

取值约束:只能是如下取值 "inline" | "obs"

使用建议:将该字段通过get_input函数传入,在AOS界面创建资源栈填写输入参数时可获取

runtime

函数的执行环境

参数类型:string

取值说明:支持Node.js6.10、Node.js8.10、Python2.7、Python3.6、Java8、Go1.8、 C#(.NET Core 2.0)、 C#(.NET Core 2.1)

取值约束:只能是如下取值 "Node.js6.10" | "Python2.7" | "Python3.6" | "Java8" | "Go1.8" | "Node.js8.10" | "C#(.NET Core 2.0" | "C#(.NET Core 2.1"

使用建议:将该字段通过get_input函数传入,在AOS界面创建资源栈填写输入参数时可获取

codeUrl

函数代码包在OBS上的地址

参数类型:string

取值说明:当CodeType为obs时,该字段必选。该字段的值为函数代码包在OBS上的地址,CodeType为inline时,该字段为空

默认值:""

使用建议:将该字段通过get_input函数传入,在AOS界面创建资源栈填写输入参数时可获取

name

函数名称

参数类型:string

取值说明:用户自定义

取值约束:只能以大小写字母开头,且只能包含字母、数字、下划线和中划线,以字母或者数字结尾

使用建议:将该字段通过get_input函数传入,在AOS界面创建资源栈填写输入参数时可自动获取

关联关系

输出

属性

参数类型

描述

refID

string

函数 ID

blueprint样例

tosca_definitions_version: huaweicloud_tosca_version_1_0
inputs:
  codeUrl:
    description: >-
      The address of the function code package on OBS. You need to upload the
      function code to OBS barrel in advance.
    label: Function
    type: string
  handler:
    default: index.handler
    description: >-
      The Execution Entry of the function. Default value is index. handler. It
      can be configured independently by code file name and entry function name.
    label: Function
    type: string
  memorySize:
    constraints:
      valid_values:
        - 128
        - 256
        - 512
        - 768
        - 1024
        - 1280
        - 1536
    default: 128
    description: The memory size of the function.
    label: Function
    type: integer
  name:
    constraints:
      regex: '^[a-zA-Z]([a-zA-Z0-9_-]*[a-zA-Z0-9])?$'
    default: image_watermark
    description: The name of the function.
    label: Function
    type: string
  runtime:
    constraints:
      valid_values:
        - Node.js6.10
        - Python2.7
        - Python3.6
        - Java8
        - Go1.8
        - Node.js8.10
    description: The runtime of the function.
    label: Function
    type: string
  timeout:
    constraints:
      in_range:
        - 3
        - 300
    default: 3
    description: The timeout of the function. The effective range is 3~300.
    label: Function
    type: integer
  xrole:
    description: The agency of the function. It should be created in advance.
    label: Function
    type: string
node_templates:
  fgsf36en:
    properties:
      codeUrl:
        get_input: codeUrl
      handler:
        get_input: handler
      memorySize:
        get_input: memorySize
      name:
        get_input: name
      role:
        get_input: xrole
      runtime:
        get_input: runtime
      timeout:
        get_input: timeout
      code: ''
      codeType: obs
      environment:
        variables:
          key1: value1
          key2: value2
    type: HuaweiCloud.FGS.Function
outputs:
  function-urn:
    description: function URN
    value:
      get_attribute:
        - fgsf36en
        - refID
分享:

    相关文档

    相关产品