如何将多个serverless.yml文件合并为单个serverless.yml文件? [英] How to combine multiple serverless.yml files to single serverless.yml file?
本文介绍了如何将多个serverless.yml文件合并为单个serverless.yml文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我阅读了此文档: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文件命名为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/
这篇关于如何将多个serverless.yml文件合并为单个serverless.yml文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文