Open throrin19 opened 1 year ago
@throrin19 for that to happen. I believe first this functionality will need to be integrated into Framework core (so it works in realm of the single process) and then eventually new version of serverless offline
plugin could emerge out of that.
Unfortunately at this point, there's no work involved in this feature so I cannot provide any ETA on Framework core integration
@medikoo thanks for your response. I understand the problem 😢
+1, I tried serverless-compose bc Cloudformation/Serverless does not currently support multiple Websocket APIs in the same service. Offline's incompatibility w/ Compose breaks existing workflow. I'll be mirroring my service to a second repo to workaround in the meantime, though I bemoan the code duplication
This doesn't just relate to serverless-offline
, but also many other plugins which might spawn offline test resources like serverless-s3-local
or serverless-dynamodb-local
.
Terragrunt has a run-all
command that can be used to run commands in all of a project's sub-modules. For example, you can run terragrunt run-all plan
or terragrunt run-all apply
to run the plan
or apply
command respectively in sub-modules.
I wonder if we could take a similar approach here instead of integrating all these various plugins into serverless-core. For example, we could implement a new serverless-compose command like serverless run-in-service --service <service> <command>
that runs the supplied command within the context of the specified service, while also fetching and passing in the relevant parameters that are required in that service (and normally supplied by serverless-compose).
A full example of the command would be:
serverless run-in-service --service frontend invoke-local --function search
The equivalent can be achieved by cd
ing into the frontend
service's subdirectory and using the serverless --param
argument, and manually copying and pasting all the parameters that are normally supplied by serverless-compose - but this is obviously tedious and inefficient (especially once the project has grown to use several cross-service parameters). It would be better if serverless-compose could do this automatically.
This is what the above run-in-service
command would look like with this manual approach:
cd frontend
serverless invoke-local --function search --param="<serverless-compose param...>
This approach would provide the following benefits:
Is there an existing issue for this?
Use case description
In a world where projects are becoming more and more complex, a realization following monorepo (lerna, nx, turborepo, workspaces, ...) becomes a prerequisite to facilitate their development.
In this case, we can end up with several modules using the same APIGateway for cost reasons but also to gather everything behind the same domain.
In order to facilitate the development, which can be quite tedious during the build and deployment of the different modules on AWS, it would be more than interesting to make serverless-compose compatible with serverless-offline.
In this way, we end up using the same local server, launching all the routes of the different modules, through a single command.
Using serverless-compose also allows to manage the prioritization of routes according to the dependencies between modules.
Would it be possible to bring compatibility (or use) of serverless-offline through compose?
Proposed solution (optional)
No response