This document describes how to use the SCF component provided by Serverless Framework to quickly create and deploy an SCF project.
You have installed Serverless Framework as instructed in Installing Serverless Framework.
tencent-scfas an example):
mkdir tencent-scf && cd tencent-scf
serverless create --template-url https://github.com/serverless-components/tencent-scf/tree/v2/example
After the application is created successfully, its directory structure is as follows
|- src | └── index.py └── serverless.yml
serverless.ymlis and run the following command to deploy the function:
If you want to view more information on the deployment process, you can run the
sls deploy --debugcommand to view the real-time log information during the deployment process (
slsis an abbreviation for the
The SCF component supports "zero" configuration deployment, that is, it can be deployed directly with the default values in the configuration file. Nonetheless, you can also modify more optional configuration items as needed to further customize the project to be deployed.
The following is the description of the SCF component configuration file
serverless.yml. For more information, please see Full Configuration and Configuration Description.
# serverless.yml component: scf # Name of the imported component, which is required. The `tencent-scf` component is used in this example name: scfdemo # Name of the instance created by this component, which is required org: test # Organization information, which is optional. The default value is the `appid` of your Tencent Cloud account app: scfApp # SCF application name, which is optional stage: dev # Information for identifying environment, which is optional. The default value is `dev` inputs: name: scfFunctionName src: ./src runtime: Nodejs10.15 # Runtime environment of function. Valid values: Python2.7, Python3.6, Nodejs6.10, Nodejs8.9, Nodejs10.15, Nodejs12.16, PHP5, PHP7, Golang1, Java8 region: ap-guangzhou handler: index.main_handler events: - apigw: name: serverless_api parameters: protocols: - http - https serviceName: description: The service of Serverless Framework environment: release endpoints: - path: /index method: GET
After updating the fields in the configuration file, run the
serverless deploy or
serverless command again to update the configuration to the cloud.
After deploying the function, you can use the development and debugging capabilities provided by the component to re-develop the project into a production-ready application.
Contact our sales team or business advisors to help your business.
Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.
Was this page helpful?