This document describes how to use the API Gateway component provided by Serverless Framework to quickly create and deploy an API Gateway service/API.
You have installed Serverless Framework.
serverless.yml file locally:
serverless.yml as follows:
# serverless.yml component: apigateway # Component name, which is required. `apigateway` is used in this example name: apigwDemo # Instance name, which is required org: orgDemo # Organization information, which is optional. The default value is the `appid` of your Tencent Cloud account app: appDemo # Next.js application name, which is optional stage: dev # Information for identifying environment, which is optional. The default value is `dev` inputs: region: ap-guangzhou protocols: - http - https serviceName: serverless environment: release endpoints: - path: / protocol: HTTP method: GET apiName: index function: functionName: myFunction
Run the following command to deploy by scanning code:
To grant persistent permission, please see Account Configuration.
You can run the following command to remove the deployed service:
Currently, you can scan a QR code to log in to the CLI by default. If you want to configure persistent environment variables/key information, you can also create a local
touch .env # Tencent Cloud configuration information
Configure Tencent Cloud's
SecretKey information in the
.env file and save it:
# .env TENCENT_SECRET_ID=123 TENCENT_SECRET_KEY=123