Yaml文件
Yaml完整配置
edition: 1.0.0 # 命令行YAML规范版本,遵循语义化版本(Semantic Versioning)规范 name: fg-test # 项目名称 access: "default" # 秘钥别名 vars: # 全局变量 region: "cn-east-3" functionName: "start-fg-event-Nodejs14" services: component-test: # 服务名称 component: fgs # 组件名称 props: region: ${vars.region} function: functionName: ${vars.functionName} # 函数名 handler: index.handler # 函数执行入口 memorySize: 256 # 函数消耗的内存 timeout: 30 # 函数执行超时时间 runtime: Node.js14.18 # 运行时 agencyName: fgs-vpc-test # 委托名称 environmentVariables: # 环境变量 test: test hello: world vpcId: xxx-xxx # 虚拟私有云唯一标识 subnetId: xxx-xxx # 子网编号 concurrency: 10 # 单函数最大实例数 concurrentNum: 10 # 单实例最大并发数 codeType: zip # 函数代码类型 dependVersionList: # 依赖包,取依赖包的ID - xxx-xxx code: # 本地代码地址 codeUri: ./code trigger: triggerTypeCode: TIMER # 触发器类型 status: DISABLED # 触发器状态 eventData: # 触发器配置 name: APIG_test # API名称 groupName: APIGroup_xxx # 分组名称 auth: IAM # 安全认证 protocol: HTTPS # 请求协议 timeout: 5000 # 后端超时时间
参数名 |
必填 |
类型 |
参数描述 |
---|---|---|---|
functionName |
True |
String |
函数名称。 |
handler |
True |
String |
函数执行入口,规则:xx.xx,必须包含“.”。 |
runtime |
True |
String |
函数运行时。 |
package |
False |
String |
函数所属的分组Package,用于用户针对函数的自定义分组,默认为default。 |
memorySize |
True |
Number |
函数消耗的内存,单位M。 取值范围为:128、256、512、768、1024、1280、1536、1792、2048、2560、3072、3584、4096。 |
timeout |
True |
Number |
函数执行超时时间,超时函数将被强行停止,范围3~900秒。 |
Code Type |
True |
String |
函数代码类型。
|
codeUrl |
False |
String |
当CodeType为obs时,该值为函数代码包在OBS上的地址,CodeType为其他值时,该字段为空。 |
environmentVariables |
False |
环境变量。最多定义20个,总长度不超过4KB。 |
|
agencyName |
False |
String |
委托名称,需要IAM支持,并在IAM界面创建委托,当函数需要访问其他服务时,必须提供该字段。 |
vpcId |
False |
String |
虚拟私有云唯一标识。配置时,agencyName必填。虚拟私有云标识请登录虚拟私有云页面查看。 |
subnetId |
False |
String |
子网编号。配置时,agencyName必填。子网编号请登录虚拟私有云子网页面查看。 |
dependVersionList |
False |
List<String> |
依赖包,取依赖包的ID。 |
code |
False |
本地代码地址,当CodeType为zip时必填。 |
|
concurrency |
False |
Number |
单函数最大实例数,取值-1到1000。 -1代表该函数实例数无限制;0代表该函数被禁用。 |
concurrentNum |
False |
Number |
单实例最大并发数,取值-1到1000。 |
description |
False |
String |
function 的简短描述。 |
- Func Code参数说明:
表3 Func Code参数说明 参数名
必填
类型
参数描述
codeUri
True
String
本地代码地址
- Environment Variables参数说明:
当然不推荐通过明文将敏感信息写入到s.yaml。
function: functionName: event-function description: this is a test runtime: Node.js14.18 handler: index.handler memorySize: 128 timeout: 60 code: codeUri: ./code environmentVariables: test: 123 hello: world
triggers字段介绍
Yaml文件中triggers字段说明请参考表4。
参数名 |
必填 |
类型 |
参数描述 |
---|---|---|---|
triggerTypeCode |
True |
String |
触发器类型。 |
status |
False |
Enum |
触发器状态,取值为 ACTIVE、DISABLED,默认为 ACTIVE。 |
eventData |
True |
Struct |
- APIG触发器
表5 APIG参数说明 参数名
必填
类型
参数描述
name
False
String
API名称,默认使用函数名。
groupName
False
String
分组,默认选择当前第一个。
auth
False
Enum
安全认证,默认为 IAM。
protocol
False
Enum
请求协议,默认为 HTTPS。
分为两种类型:
- HTTP
- HTTPS
timeout
False
Number
后端超时时间,单位为毫秒,取值范围为 1 ~ 60000。默认为 5000。
参考案例:trigger: triggerTypeCode: APIG status: ACTIVE eventData: name: APIG_test groupName: APIGroup_xxx auth: IAM protocol: HTTPS timeout: 5000
- TIMER触发器
表6 TIMER参数说明 参数名
必填
类型
参数描述
name
False
String
定时器名称。
scheduleType
True
Enum
触发规则,取值为 Rate、Cron。
schedule
True
String
定时器规则内容。
userEvent
False
String
附加信息,如果用户配置了触发事件,会将该事件填写到TIMER事件源的“user_event”字段。
参考案例:trigger: triggerTypeCode: TIMER status: ACTIVE eventData: name: Timer-xxx scheduleType: Rate schedule: 3m userEvent: xxxx trigger: triggerTypeCode: TIMER status: ACTIVE eventData: name: Timer-xxx scheduleType: Cron schedule: 0 15 2 * * ? userEvent: xxxx