Can we run multiple yml files using serverless offline plugins

Viewed 768

I have multiple yml files in different folder then how I run locally all those files using serverless offline plugins?

1 Answers

If I'm understanding your question correctly, you have a structure something like this:

./
serverless.yml
/more-yml
 /functions
  lambda-x.yml
  lambda-y.yml
  lambda-z.yml
 /resources
  resource-a.yml
  resource-b.yml

You can write a script which parses all these files, runs any validations you may want on the items within, and returns a file for serverless.yml to use, so that your serverless.yml might look like this:

service: your-service
provider:
  ...
resources: ${file(./scripts/serverless/join-resources.js)}
functions: ${file(./scripts/serverless/join-lambda-functions.js)}

All this scripts (or scripts) need to do is loop over a given directory, load the yml, concat each file's yml to a temp file, then resolve with that temp file!

Related