serverless / compose

Orchestrate Serverless Framework in monorepos
https://serverless.com/framework/docs/guides/compose
MIT License
111 stars 15 forks source link

[RFC] Filtering services to deploy #35

Open m-radzikowski opened 2 years ago

m-radzikowski commented 2 years ago

Problem

As part of the development environment, I have stacks named mock-api, mock-something, etc. I want to deploy them only on dev environments, not production.

Right now I'm deploying my monorepo stacks with Lerna:

    "deploy": "lerna run deploy --stream --",
    "deploy:prod": "lerna run deploy --stream --ignore 'mock-*' -- --stage prod",

The deploy command is deploying everything. The deploy:prod is used in CI for deployment to the prod stage, and does not deploy packages (services) with names starting with mock-.

Proposal

Introduce --include and --exclude params to serverless-compose. Such flags are popular across different tools.

--include would make the serverless-compose deploy only explicitly listed services

--exclude would make the serverless-compose deploy all services apart from the ones listed

Using both --include and --exclude would make slsc deploy all services listed in the "include" except for the ones listed in the "exclude".

Both params should accept multiple comma-separated service names and allow simple matching with *.

Usage examples:

Deploy all services which names do not start with mock-:

slsc deploy --exclude mock-*

Deploy only api and resources services:

slsc deploy --include api,resources

Deploy all services starting with api- apart from the ones ending with -mock:

slsc deploy --include api-* --exclude *-mock