Serverless Cloud Framework deploys applications based on the Serverless components. There are no mandatory requirements for the local project structure, but for the ease of management and deployment, we recommend you organize your application in the following directory structure: Single-Function Application
For single-function applications, you can place your business code in the src
directory and import this directory in the serverless.yml
configuration file to achieve separate management of the project and the configuration file. Below is an example:
.
├── serverless.yml
├── src
│ ├── package.json
│ └── index.js
└── .env
Multi-Function/Multi-Resource Application
Serverless Cloud Framework not only supports deploying single-function projects, but also can implement unified deployment at the application level for multi-function projects. You should configure the corresponding configuration file for each function; therefore, we recommend the following directory structure:
.
├── package.json
├── function1
│ ├── serverless.yml
│ └── index1.js
├── function2
│ ├── serverless.yml
│ └── index2.js
└── .env
Under this structure, you only need to run scf deploy
in the root directory, and Serverless Cloud Framework will automatically traverse all the .yml
configuration files in the directory to deploy resources.
Meanwhile, if you import the creation of other cloud resources in the function project, you can also use the same directory structure:
.
├── package.json
├── src
│ ├── serverless.yml
│ └── index1.js
├── cos
│ └── serverless.yml
├── db
│ └── serverless.yml
└── .env
Was this page helpful?