Serverless Framework 无服务器部署
Serverless Framework 用 serverless.yml 描述函数、事件和资源,支持 AWS、Azure、GCP 等。它通过插件扩展能力,命令是 serverless 或 sls。
serverless create --template aws-nodejs --path app
serverless package
serverless deploy --stage prod --region ap-southeast-1
serverless deploy function -f hello
serverless invoke -f hello -d '{"name":"world"}'
serverless invoke local -f hello -d '{"name":"world"}'
serverless logs -f hello --tail
serverless info
serverless remove
serverless plugin install -n serverless-offline
stage 和 region 决定资源命名;不同 stage 可能创建整套独立资源。node_modules;用排除规则控制体积。invoke local 只模拟运行时;环境变量和 IAM 与线上不同。remove 会删除栈和资源;确认没有需要保留的数据。aws-sam — AWS 原生无服务器aws-cdk — 编程式 IaCaws — AWS CLI