gpt4 book ai didi

serverless-framework - 如何将多个 serverless.yml 文件合并为单个 serverless.yml 文件?

转载 作者:行者123 更新时间:2023-12-04 12:13:34 27 4
gpt4 key购买 nike

我阅读了这个文档: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一次也部署所有服务。

最佳答案

我在单个 serverless.yml 文件中定义函数,并在主 serverless.yml 文件中的函数下包含文件引用,它对我有用,我还将单个 yml 文件命名为 post-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/

关于serverless-framework - 如何将多个 serverless.yml 文件合并为单个 serverless.yml 文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52717634/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com