# Serverless
# Plugins
Serverless Plugin (opens new window) 实际上是一个函数的管理工具,无论针对 AWS 还是腾讯云,Plugin 的目标都是对函数进行管理。
以下为 serverless.yml 基本配置示例:
service: aws-python-api
frameworkVersion: '3'
provider:
name: aws
runtime: python3.7
functions:
api:
handler: wsgi_handler.handler
events:
- httpApi: '*'
# serverless-python-requirements
serverless-python-requirements (opens new window) 用于自动捆绑 requirements.txt 中的依赖项并使其在您的 PYTHONPATH 中可用。
serverless plugin install -n serverless-python-requirements
当运行 sls deploy 时,该插件将捆绑在 requirements.txt 或 Pipfile 中指定的 python 依赖项。
最后上传到云函数 SCF 的包,包内文件的修改时间可能导致部署失败。
# serverless-wsgi
serverless-wsgi (opens new window) 用于使用无服务器构建部署 Python WSGI 应用程序。
sls plugin install -n serverless-wsgi
# 腾讯云
腾讯云 SCF (opens new window) 支持 Python (opens new window)、Node.js、Golang、PHP、Java 等语言,可选地区列表可参考支持地域 (opens new window)。
SCF 将在函数接收到触发请求时执行函数,SCF 平台负责所有函数的生命周期 (opens new window)。
API 网关触发器将下线 (opens new window),替代方案为函数 URL (opens new window)。