Skip to content

Latest commit

 

History

History
232 lines (224 loc) · 18.3 KB

readme.md

File metadata and controls

232 lines (224 loc) · 18.3 KB
title description position category
Yaml specification
Yaml specification
1
Yaml-Spec

Field parsing

Parameter Name Required Type Parameter Description
region True Enum Region
service True Struct Service
function True Struct function
triggers True Struct Triggers
customDomains True Struct Custom Domain Name

Regions currently supported: cn-beijing, cn-hangzhou, cn-shanghai, cn-qingdao, cn-zhangjiakou, cn-huhehaote, cn-shenzhen, cn-chengdu , cn-hongkong, ap-southeast-1, ap-southeast-2, ap-southeast-3, ap-southeast-5, ap-northeast-1, eu -central-1, eu-west-1, us-west-1, us-east-1, ap-south-1

Yaml complete configuration

The Yaml fields of Alibaba Cloud Function Compute (FC) components are as follows:

edition: 1.0.0     # Command-line YAML specification version, following the Semantic Versioning specification
name: ffmpeg-app   # project name
access: default    # key alias

services:
  fc-deploy-test:          # module name
    component: fc          # component name
    props:                 # property value of the component
      region: cn-qingdao # Region
      service:           # service configuration
        name: fc-deploy-service                         # service name
        description: short description of dem component # Service
        internetAccess: true                            # Set to true to allow the function to access the public network
        role: 'acs:ram::xxx:role/AliyunFcDefaultRole'   # The RAM role that grants the permissions required by function computing. The usage scenarios include 1. Send the log generated by the function to the user's logstore 2. Access other functions for the function during execution Cloud resource generation token
        tracingConfig: Enable                           # Link tracing, possible values: Enable, Disable
        nasConfig:                                      # NAS configuration, the function can access the specified NAS after configuration
          userId: 10003           # userID, default is 10003
          groupId: 10003          # groupID, default is 10003
          mountPoints:            # Directory configuration
            - serverAddr: xxx.cn-qingdao.nas.aliyuncs.com   # NAS server address
              nasDir: /fc-deploy-service                    # NAS directory
              fcDir: /mnt/auto                              # function calculation directory
        vpcConfig:                 # VPC configuration, the function can access the specified VPC after configuration
          vpcId: xxx               # VPC ID
          securityGroupId: xxx     # security group ID
          vswitchIds:              # list of switch IDs
            -vsw-xxx
        logConfig:          # log configuration, the log generated by the function will be written to the logstore configured here
          project: xxx      # The project name in loghub
          logstore: xxx     # logstore name in loghub
          enableRequestMetrics: true    # RequestMetrics switch, value true/false
          enableInstanceMetrics: true   # InstanceMetrics switch, the value is true/false
          logBeginRule: DefaultRegex            # Whether the log is split, the value DefaultRegex/None
        vpcBinding: # Function Invocation only by Specified VPCs
          - vpc-bpxxxxxxxoeoq
          - vpc-bpxxxxxxxxxmw
      function:                     # function configuration
        name: fc-base-service       # function name
        description: 'this is test' # a short description of the function
        codeUri: './code.zip'       # code location
        ossBucket: xxx              # oss bucket where code is stored
        ossKey: xxx                 # If oss code is specified, the corresponding object cannot appear at the same time as codeUri
        handler: 'index.handler'    # The entry for function execution, the specific format is related to the language
        memorySize: 128             # The memory specification of the function
        runtime: nodejs12           # runtime
        timeout: 60                 # The timeout for the function to run
        caPort: 9000                # CustomContainer/Runtime specified port
        customContainerConfig:      # custom image configuration
          image: xxx                # Container image warehouse address
          command: xxx              # Container startup command, example value: '["/code/myserver"]'
          args: xxx                 # Container startup parameters, example value: '["-arg1", "value1"]'
          instanceID: cri-xxxxxx    # The ID of the Container Image Service Enterprise Edition instance. When an enterprise version instance is selected for the container image, you need to add an instance ID to the enterprise version of the container image service. The default resolution of the instance must be the VPC network address where the service is located. PrivateZone product definition domain name resolution is currently not supported
          accelerationType: Default # Mirror acceleration switch, optional values: 'Default', 'None', the former means on, the latter means off
        environmentVariables:       # environment variables
          key: 'value'
        initializationTimeout: 20   # initialization method timeout
        initializer: index.init     # initialization method
        instanceConcurrency: 1      # single instance multiple concurrency
        instanceType: e1            # Function instance type, optional values ​​are: e1 (elastic instance), c1 (performance instance), g1 (gpu instance)
        layers:                     # Function binding layer, supports Nodejs, Python, Java, Php, Golang, .NET and Custom Runtime; the value is the ARN of the layer. Multiple layers will be merged in descending order of array subscripts, if the same file appears in multiple layers, the function uses the version in the layer of smaller array subscript
          - xxx
          - xxx
        instanceLifecycleConfig: # extension function
          preFreeze:             # PreFreeze function
            handler: index.xxx   # function entry
            timeout: 60          # timeout
          preStop:               # PreStop function
            handler: index.xxx   # function entry
            timeout: 60          # timeout
        asyncConfiguration:      # asynchronous configuration
          destination:
            onSuccess: acs:fc:{region}:{uid}:services/{serviceName}.{qualifier}/functions/{functionName} # Asynchronously call the successful target service
            onFailure: acs:fc:{region}:{uid}:services/{serviceName}.{qualifier}/functions/{functionName} # Asynchronous call failed target service
            # onSuccess: acs:fc:::services/{serviceName}.{qualifier}/functions/{functionName}
            # onSuccess: acs:mns:::/queues/{queuesName}/messages # mns/queues
            # onSuccess: acs:mns:::/topics/{topicsName}/messages # mns/topics
          maxAsyncEventAgeInSeconds: 456 # The maximum survival time of the message, the value range is [1,2592000]. Unit: second
          maxAsyncRetryAttempts: 3       # The maximum number of retries after an asynchronous call fails, the default value is 3. Value range [0,8]
          statefulInvocation: true       # Whether to enable stateful asynchronous invocation
        customDNS:              # DNS configuration
          nameServers:          # List of IP addresses of DNS servers
            - 8.8.8.8
            - 114.114.114.114
          searches:             # DNS search domain list
            - default.svc.test.example
            - svc.jqDgWvOo.test.example
          dnsOptions:        # Corresponds to the Options item of resolv.conf DNS configuration
            - name: ndots    # Corresponds to the key of the Options item of the resolv.conf DNS configuration
              value: '6'     # Corresponds to the value of the Options item of the resolv.conf DNS configuration
            - name: edns     # Corresponds to the key of the Options item of the resolv.conf DNS configuration
              value: '7'     # Corresponds to the value of the Options item of the resolv.conf DNS configuration
        customRuntimeConfig: # custom Define runtime startup configuration
            command:         # startup command, example value: ["/code/myserver"]
                - /code/node_modules/ts-node/dist/bin.js
                - server.ts
            args:            # startup arguments, example values: ["-arg1", "value1"]
                - '--args1'
                - args1
      triggers:                # trigger configuration
        - name: httpTrigger    # trigger name
          type: http           # trigger type
          qualifier: xxx       # Trigger the version of the service
          config:              # Trigger configuration, including OSS trigger, Log trigger, Log trigger, Timer trigger, Http trigger, MNS trigger, CDN trigger
            authType: anonymous # Authentication type, optional values: anonymous, function
            disableURLInternet: false # Disable Internet URL
            methods:           # Access methods supported by HTTP triggers, optional values: GET, POST, PUT, DELETE, HEAD
              - GET
        - name: timerTrigger   # trigger name
          type: timer          # trigger type
          qualifier: xxx       # Trigger the version of the service
          config:              # Trigger configuration, including OSS trigger, Log trigger, Log trigger, Timer trigger, Http trigger, MNS trigger, CDN trigger
            cronExpression: '0 0 8 * * *'  # Time trigger expression, supports two settings: @every, cron expression
            enable: true                   # Whether to enable the trigger
            payload: 'awesome-fc'          # Represents the input content of the trigger event itself
        - name: ossTrigger       # trigger name
          type: oss              # trigger type
          role: xxx              # Use the ARN of a RAM role to specify the execution role for the function, the event source will use this role to trigger the function execution, please ensure that the role has the permission to call the function
          sourceArn: xxx         # ARN of the trigger event source
          qualifier: xxx         # Trigger the version of the service
          config:                # Trigger configuration, including OSS trigger, Log trigger, Log trigger, Timer trigger, Http trigger, MNS trigger, CDN trigger
            bucketName: fassdemo # target bucket name in OSS
            events:              # List of events that trigger function execution on the OSS side, refer to the document: https://www.alibabacloud.com/help/en/doc-detail/62922.html#section-mf3-l4l-1nf
              - oss:ObjectCreated:*
              - oss:ObjectRemoved:DeleteObject
            filter:              # trigger condition
              Key:               # key value
                Prefix: source/  # prefix
                Suffix: .png     # suffix
        - name: logTrigger       # trigger name
          type: log              # trigger type
          role: xxx              # Use the ARN of a RAM role to specify the execution role for the function, the event source will use this role to trigger the function execution, please ensure that the role has the permission to call the function
          sourceArn: xxx         # ARN of the trigger event source
          qualifier: xxx         # Trigger the version of the service
          config:                # Trigger configuration, including OSS trigger, Log trigger, Log trigger, Timer trigger, Http trigger, MNS trigger, CDN trigger
            logConfig:           # log configuration
              project: fass-demo # log project name
              logstore: fc-log   # The name of the log warehouse, the log of the log service triggering the function execution process will be recorded in the log warehouse
            jobConfig:           # job configuration
              maxRetryTime: 1     # Indicates the maximum number of attempts allowed if an error is encountered when the log service triggers the function execution, the value range: [0,100]
              triggerInterval: 30 # The time interval at which the log service triggers the function to run, value range: [3,600], unit: second
            sourceConfig:         # source configuration
              logstore: function-log # The trigger will periodically subscribe data from the log warehouse to the function service for custom processing
            functionParameter:       # This parameter will be passed into the function as the Parameter of the function Event. The default value is empty ({})
              key: val
            enable: true      # trigger switch
        - name: mnsTrigger    # trigger name
          type: mns_topic     # trigger type
          role: xxx           # Use the ARN of a RAM role to specify the execution role for the function, the event source will use this role to trigger the function execution, please ensure that the role has the permission to call the function
          sourceArn: xxx      # ARN of the trigger event source
          qualifier: xxx      # Trigger the version of the service
          config:             # Trigger configuration, including OSS trigger, Log trigger, Log trigger, Timer trigger, Http trigger, MNS trigger, CDN trigger
            topicName: test-topic # mns topic name
            region: cn-hangzhou   # The region where the mns topic is located, if not filled, the default is the same region as the function
            notifyContentFormat: 'JSON'     # The format of the input parameter event pushed to the function, optional values: STREAM, JSON
            notifyStrategy: 'BACKOFF_RETRY' # Retry strategy for calling function, optional values: BACKOFF_RETRY, EXPONENTIAL_DECAY_RETRY
            filterTag: abc                  # Describes the tag of message filtering in this subscription (only messages with the same tag will be pushed), a string of no more than 16 characters, message filtering is not performed by default, that is, this field is not filled in by default
        - name: cdnTrigger # trigger name
          type: cdn_events # trigger type
          role: xxx        # Use the ARN of a RAM role to specify the execution role for the function, the event source will use this role to trigger the function execution, please ensure that the role has the permission to call the function
          sourceArn: xxx # ARN of the trigger event source
          qualifier: xxx # Trigger the version of the service
          config:        # Trigger configuration, including OSS trigger, Log trigger, Log trigger, Timer trigger, Http trigger, MNS trigger, CDN trigger
            eventName: LogFileCreated # The event that triggers the function execution on the CDN side, once created, it cannot be changed
            eventVersion: '1.0.0'     # The version of the function execution event triggered by the CDN side, once created, it cannot be changed
            notes: cdn events trigger test # Notes information
            filter:             # filter (requires at least one filter)
              domain:           # filter set of parameter values
                - 'www.taobao.com'
                - 'www.tmall.com'
        - name: tablestoreTrigger # trigger name
          type: tablestore        # trigger type
          role: xxx               # Use the ARN of a RAM role to specify the execution role for the function, the event source will use this role to trigger the function execution, please ensure that the role has the permission to call the function
          sourceArn: xxx          # ARN of the trigger event source
          qualifier: xxx          # trigger service Version
          config:                 # Trigger configuration, including OSS trigger, Log trigger, Log trigger, Timer trigger, Http trigger, MNS trigger, CDN trigger
            instanceName: xxx     # The name of the Tablestore instance
            tableName: xxxs       # The name of the table in the instance
      customDomains:              # custom domain name configuration
        - domainName: auto        # Domain name, if the value is auto, the system will assign the domain name by default
          protocol: HTTP          # Protocol, value: HTTP, HTTPS, HTTP, HTTPS
          routeConfigs:           # route configuration
            - path: /a            # path
              serviceName: fc-depicted # service name
              functionName: function # function name
              qualifier: 1           # version of the service
              rewriteConfig: # The URI rewrite configurations
                equalRules:  # The exact match rules
                  - match: /old  # The matching rule
                    replacement: /new # The replacement rule
                wildcardRules:  # The wildcard match rule
                  - match: /old  # The matching rule
                    replacement: /new # The replacement rule
                regexRules:  # The regex match rule
                  - match: /old  # The matching rule
                    replacement: /new # The replacement rule
          wafConfig:  # The Web Application Firewall (WAF) configuration
            enableWAF: true # Specifies whether to enable Web Application Firewall (WAF)
          certConfig:          # Domain name certificate
            certName: xxx      # certificate name
            certificate: xxx   # Indicates the private key, the content only supports PEM format
            privateKey: xxx    # Indicates the certificate, the content only supports PEM format
          certId: 123          # Domain name certificate Id 

Tips:

  • How to declare multiple functions? In the function computing component of Serverless Devs, by default, there is a one-to-one correspondence between services and functions. If you need to declare multiple functions under one service, you can refer to Common Tips Provided in How to declare and deploy multiple functions document