Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add compatibility with serverless-offline #175

Open
1 task done
throrin19 opened this issue Mar 9, 2023 · 5 comments
Open
1 task done

Add compatibility with serverless-offline #175

throrin19 opened this issue Mar 9, 2023 · 5 comments
Labels
enhancement New feature or request needs feedback

Comments

@throrin19
Copy link

Is there an existing issue for this?

  • I have searched existing issues, it hasn't been reported yet

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

@medikoo medikoo added enhancement New feature or request needs feedback labels Mar 9, 2023
@medikoo
Copy link

medikoo commented Mar 9, 2023

@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

@throrin19
Copy link
Author

@medikoo thanks for your response. I understand the problem 😢

@hustlerman
Copy link

+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

@darylteo
Copy link

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.

@calebplum
Copy link

calebplum commented Oct 14, 2023

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 cding 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:

  • Extensible to additional plugins with no modification to the command's logic
  • Doesn't rely on plugins being integrated into serverless-core
  • Shouldn't be too complex from an implementation logic perspective

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request needs feedback
Projects
None yet
Development

No branches or pull requests

5 participants