Serverless-offline: Multiple serverless.yml sharing same ApiGateway

Created on 1 Feb 2019  路  4Comments  路  Source: dherault/serverless-offline

Hi!

I already used this plugin on multiple projects, but now, I have an issue!

Previously, my projects was organize on a single folder, with one serverless.yml, it was easy!

But now, we have a folder containing multiple sub-folder with each a serverless.yml, we got one who create an ApiGateway with an empty lambda and the others use the restApiId and restApiRootResourceId to share the same ApiGateway. Like this :

./src

  • ./apigateway/serverless.yml (the root one)
  • ./service1/serverless.yml (use restApiId && restApiRootResourceId)
  • ./service2/serverless.yml (use restApiId && restApiRootResourceId)

Everything works on ApiGateway, and the isolation is great!

How can I use serverless-offline with this kind of scenario?

I really want to continue to work with the same workflow, it was great! 馃槃

I'm thinking of an ultra dirty solution with a script who gonna create a server on one localhost url and re-route every request to differents ports of serverless-offline instances... desperate times call for desperate measures! 馃槂

Thx!

Most helpful comment

I have the exact same issue. I'm running a monorepo setup where I have multiple services (+multiple serverless.yml) files and I want to run them all at once..

All 4 comments

Hi @davidroman0O
At the moment serverless-offline does not support multiple serverless.yml files.
The only option is to start a server with a different port for each serverless folder.
Of course we'd gladly accept a PR fixing this.
Thanks for the issue,

Oh ok !

I'll take a look ! :D

Thx for taking the time to answer me :)

@davidroman0O

I only have a vague idea on your scenario. one thing which should work for sure is to merge your serverless.yml files with a custom script into a single one. that should be fairly straight forward.

you'll have a watcher, like nodemon , watching your sub-directories. when anything changes (code or yml) nodemon runs the merge script you provide, and re-starts serverless-offline from the specific merge location. you'd have to likely something similar with your code.

I have the exact same issue. I'm running a monorepo setup where I have multiple services (+multiple serverless.yml) files and I want to run them all at once..

Was this page helpful?
0 / 5 - 0 ratings

Related issues

conradoramalho picture conradoramalho  路  3Comments

ozbillwang picture ozbillwang  路  4Comments

MEGApixel23 picture MEGApixel23  路  4Comments

aldofunes picture aldofunes  路  3Comments

dnalborczyk picture dnalborczyk  路  3Comments