I am using the Serverless Framework for my AWS-powered application. I've been writing a super-long serverless.yml
file so far, which contains all my lambda code, resources, IAM roles, and State Machines. T find it very hard to manage this big file. How can I work around this? Is there any way to split my serverless.yml
file into smaller, manageable chunks? It'd be awesome if I can get one yml
per lambda
. Thanks in advance
How can I split up my serverless.yml file into multiple files?
Asked Answered
After a lot of Googling, I've finally found something useful!
https://www.serverless.com/blog/structuring-a-real-world-serverless-app
You can have one file per lambda, just follow the official serverless docs, scroll down to the word "separate" (or, here is my copy-paste , docs from 2024):
# serverless.yml
---
functions:
- ${file(./foo-functions.yml)}
- ${file(./bar-functions.yml)}
and "lambda" file:
# foo-functions.yml
getFoo:
handler: handler.foo
deleteFoo:
handler: handler.foo
I've been looking for this on google and found this post. Also I find a youtube video that explain really well how to split a serverless file.
I hope it really helps to someone who looks for this in the future.
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center. –
Rugging
While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review –
Mortarboard
be careful - the link is a 10min youtube video (I didn't expect it here). Please, share the answer after watching it, thanks! –
Steiermark
I think that you could separate your project into services. Then, inside of each service, you can define one serverless.yml
. You can see the best explanation here:
© 2022 - 2024 — McMap. All rights reserved.