Updated on 2025-03-14 GMT+08:00

YAML File

Complete YAML Configuration

The YAML fields of Huawei Cloud FunctionGraph component are as follows:
edition: 1.0.0 #  YAML specifications version for the command line, which complies with the Semantic Versioning specifications.
name: fg-test #  Project name
access: "default" #  Key alias

vars: # Global variables
    region: "cn-east-3"
    functionName: "start-fg-event-nodejs14"

services:
    component-test: #  Service name
        component: fgs # Component name
        props:
            region: ${vars.region}
            function:
                functionName: ${vars.functionName} # Function name
                handler: index.handler # Handler
                memorySize: 256 # Memory required for the function
                timeout: 30 # Timeout for executing the function
                runtime: Node.js14.18 # Runtime
                agencyName: fgs-vpc-test # Agency name
                environmentVariables: # Environment variables
                    test: test
                    hello: world
                vpcId: xxx-xxx # Unique ID of a Virtual Private Cloud (VPC)
                subnetId: xxx-xxx # Subnet ID
                concurrency: 10 # Maximum number of instances for the function
                concurrentNum: 10 # Maximum number of concurrent requests per instance
                codeType: zip # Function code type
                dependVersionList: # Dependency ID
                    - xxx-xxx
                code: # Local code address
                    codeUri: ./code
            trigger:
                triggerTypeCode: TIMER # Trigger type
                status: DISABLED # Trigger status
                eventData: # Trigger configuration 
                    name: APIG_test  # API name
                    groupName: APIGroup_xxx # Group name
                    auth: IAM # Security authentication
                    protocol: HTTPS # Request protocol
                    timeout: 5000 # Backend timeout duration
Table 1 Parameter description

Parameter

Required

Type

Description

region

True

Enum

Region

function

True

Struct

Function

triggers

False

Struct

Triggers

Description of function Fields

The function fields in the YAML file are described in Table 2.

Table 2 Description of function fields

Parameter Name

Required

Type

Description

functionName

True

String

Function name.

handler

True

String

Handler of the function in the format of "xx.xx". It must contain a period (.).

runtime

True

String

Runtime of the function.

Currently, the the following runtimes are supported:

  • Node.js 14.18, Node.js 12.13, Node.js 10.16, Node.js 8.10, Node.js 6, Node.js 4.4
  • Python 3.9, Python 3.6, Python 2.7
  • Java 11, Java 8
  • Go 1.x, Go 1.8
  • PHP 7.3
  • HTTP
  • Custom

package

False

String

Package (or group) to which the function belongs. The default value is default.

memorySize

True

Number

Memory size (MB) allocated to the function. The options include 128, 256, 512, 768, 1024, 1280, 1536, 1792, 2048, 2560, 3072, 3584, and 4096.

timeout

True

Number

Maximum duration the function can be executed. Value range: 3s–900s.

Code Type

True

String

Function code type. Options:

  • inline: inline code
  • zip: ZIP file
  • obs: function code stored in an OBS bucket
  • jar: JAR file, mainly for Java functions

codeUrl

False

String

If CodeType is set to obs, enter the OBS URL of the function code package. If CodeType is not set to obs, leave this parameter blank.

environmentVariables

False

Struct

Environment variable. A maximum of 20 environment variables can be defined. The total length cannot exceed 4 KB.

agencyName

False

String

Name of an agency created in IAM. This is required when the function needs to access other services.

vpcId

False

String

Unique ID of a VPC. agencyName is required if you set this parameter. Log in to the VPC Console to view the VPC ID.

subnetId

False

String

Subnet ID. agencyName is required if you set this parameter. To obtain the subnet ID, log in to the VPC Subnet page.

dependVersionList

False

List<String>

Dependency package IDs.

code

False

Struct

Local code address, which is required if CodeType is set to zip.

concurrency

False

Number

Maximum number of instances in which a function can run. Range: –1 to 1,000. –1: The function can run in any number of instances. 0: The function is disabled.

concurrentNum

False

Number

Maximum number of concurrent requests per instance. Range: –1 to 1,000.

description

False

String

Brief description of function.

  • Func Code parameters
    Table 3 Func Code parameters

    Parameter Name

    Required

    Type

    Description

    codeUri

    True

    String

    Local code address

  • Environment variables
    Object format. For example:
    DB_connection: jdbc:mysql://ip:port/dbname

    Do not write sensitive information to s.yaml in plaintext.

Example
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

Description of triggers Fields

The triggers fields in the YAML file are described in Table 4.

Table 4 trigger parameter description

Parameter Name

Required

Type

Description

triggerTypeCode

True

String

Trigger type

status

False

Enum

Trigger status. Options: ACTIVE (default) and DISABLED

eventData

True

Struct

Trigger configurations, including APIG and timer triggers

  • APIG trigger
    Table 5 APIG trigger parameters

    Parameter Name

    Required

    Type

    Description

    name

    False

    String

    API name. The function name is used by default.

    groupName

    False

    String

    Group. The first one is selected by default.

    auth

    False

    Enum

    Authentication mode. Default: IAM.

    API authentication mode. Options:
    • App: AppKey and AppSecret high security authentication. This authentication mode is recommended. For details, see App Authentication.
    • IAM: IAM authentication. Only IAM users are allowed to access the system. The security level is medium. For details, see IAM Authentication.
    • None: No authentication. This mode grants access permissions to all users.

    protocol

    False

    Enum

    Request protocol. Default: HTTPS.

    Options:

    • HTTP
    • HTTPS

    timeout

    False

    Number

    Backend timeout in milliseconds. Range: 1–60,000. Default: 5000.

    Example:
    trigger:
        triggerTypeCode: APIG
        status: ACTIVE
        eventData:
            name: APIG_test
            groupName: APIGroup_xxx
            auth: IAM
            protocol: HTTPS
            timeout: 5000
  • Timer trigger
    Table 6 Timer trigger parameter description

    Parameter Name

    Required

    Type

    Description

    name

    False

    String

    Timer name.

    scheduleType

    True

    Enum

    Trigger rule. The value can be Rate or Cron.

    schedule

    True

    String

    Timer rule content.

    userEvent

    False

    String

    Additional information, which will be put into the user_event field of the timer event source.

    Example:
    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