我读过这样的文档:https://serverless.com/framework/docs/providers/google/guide/services/
users/
serverless.yml # Contains 4 functions that do Users CRUD operations and the Users database
posts/
serverless.yml # Contains 4 functions that do Posts CRUD operations and the Posts database
comments/
serverless.yml # Contains 4 functions that do Comments CRUD operations and the Comments database如何将这些serverless.yml文件组合成单个serverless.yml文件?除了部署每个服务之外,我还可以运行一次serverless deploy来部署所有服务。
发布于 2019-09-13 03:31:03
我在单个serverless.yml文件中定义函数,并在主serverless.yml文件中的函数下包含文件引用,它为我工作,我还将单个yml文件命名为posts sls.yml、users-sls.yml等。
# foo-functions.yml
getFoo:
handler: handler.foo
deleteFoo:
handler: handler.foo
# serverless.yml
---
functions:
- ${file(../foo-functions.yml)}
- ${file(../bar-functions.yml)}在此引用:
https://github.com/serverless/serverless/issues/4218 https://serverless.com/framework/docs/providers/aws/guide/functions/
发布于 2018-10-09 10:27:45
最简单的方法是使用插件(比如这个插件:https://github.com/economysizegeek/serverless-dir-config-plugin)。
如果你想要更多的控制,你也可以自己做。例如,您可以将特定于函数的配置放在每个目录中,然后使用像cat这样的工具将它们与项目的公共配置(例如cat serverless.common.yml users/serverless.yml posts/serverless.yml comments/serverless.yml > serverless.yml)连接起来。虽然您可能需要编写更复杂的东西,如果您想要合并键&c。
https://stackoverflow.com/questions/52717634
复制相似问题