.yml File Specification

Last updated: 2021-01-15 15:30:52

    Serverless Framework uses the project configuration file serverless.yml to identify the application type and configure the resources. After you develop a project locally, you must configure the .yml file first before you can deploy the project in the cloud by running the sls deploy command to pass the configuration information in serverless.yml and the specified parameters or code directory in inputs to the Serverless Components deployment engine.

    Basic Information

    The first-level field in a basic serverless.yml file is configured as follows:

    # Organization information (optional)
    org: '' # Organization name. If it is left empty, your `APPID` will be used by default
    app: '' # Application name. If it is left empty, the instance name of the current component will be used by default
    stage: '' # Environment name. The default value is `dev`. We recommend you use the `${env.STAGE}` variable to define the environment name
    
    # Component information
    component: scf # Component name, which is required. It is `scf` in this example
    name: scfdemo # Component instance name, which is required
    
    # Component parameter configuration, which configures specific resource information for each component
    inputs:
    

    Detailed Configuration

    In the inputs field, the corresponding information will be configured for the resources created by each component in the cloud. The SCF Component is taken as an example here. The second-level directory in the input field is as follows:

    inputs:
      name: xxx # Function name, which is `${name}-${stage}-${app}` by default
      src: ./src # Project code path in the default format. Create a specifically named COS bucket and upload it
      handler: index.main_handler # Entry
      runtime: Nodejs10.15 # Runtime environment, which is Nodejs10.15 by default
      region: ap-guangzhou # Function region
      description: This is a function in ${app} application.
      environment: # Environment variable
        variables: # Environment variable object
          TEST: value
      layers: # Layer configuration
        - name: scfLayer # Layer name
          version: 1 # Version
      events: # Trigger configuration
        - timer: # Scheduled trigger
            parameters:
              cronExpression: '*/5 * * * * * *' # Trigger once every 5 seconds
              enable: true

    Full Configuration List

    Below is the list of full configuration information for each component of Serverless Framework:

    Basic components

    Framework components

    Was this page helpful?

    Was this page helpful?

    • Not at all
    • Not very helpful
    • Somewhat helpful
    • Very helpful
    • Extremely helpful
    Send Feedback
    Help