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.serverless.yml
file is configured as follows:# Organization information (optional)app: '' # Application name. If it is left empty, the instance name of the current component will be used by defaultstage: '' # Environment name. The default value is `dev`. We recommend you use the `${env.STAGE}` variable to define the environment name# Component informationcomponent: scf # Component name, which is required. It is `scf` in this examplename: scfdemo # Component instance name, which is required# Component parameter configuration, which configures specific resource information for each componentinputs:
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 defaultsrc: ./src # Project code path in the default format. Create a specifically named COS bucket and upload ithandler: index.main_handler # Entryruntime: Nodejs10.15 # Runtime environment, which is Nodejs10.15 by defaultregion: ap-guangzhou # Function regiondescription: This is a function in ${app} application.environment: # Environment variablevariables: # Environment variable objectTEST: valuelayers: # Layer configuration- name: scfLayer # Layer nameversion: 1 # Versionevents: # Trigger configuration- timer: # Scheduled triggerparameters:cronExpression: '*/5 * * * * * *' # Trigger once every 5 secondsenable: true
Component | Full Configuration |
SCF | |
Website | |
API Gateway | |
VPC | |
COS | |
PostgreSQL | |
CynosDB | |
CDN | |
Layer |
Component | Full Configuration |
Express | |
Koa | |
Egg | |
Next.js | |
Nuxt.js | |
Flask | |
Django | |
Laravel | |
ThinkPHP |
Was this page helpful?