getlift / lift

Expanding Serverless Framework beyond functions using the AWS CDK
MIT License
912 stars 109 forks source link

Some command-names are incompatible with serverless-compose #382

Open jimmyorpheus opened 6 months ago

jimmyorpheus commented 6 months ago

Description

When using serverless-compose, serverless commands e.g. sls deploy list --service=slstry need to be executed within the compose folder (the folder that includes the individual service folders and the serverless-compose.yml file) instead of the service folder itself. The --service argument tells serverless-compose which service the command should be applied to.

This works fine for most commands, also some serverless-lift commands like: sls lift eject --service=slstry --verbose

But execution fails when trying to execute commands that include colons in their naming, since serverless-compose seems to replace those colons with spaces.

❯ sls "slstryQueue:failed" --service=slstry --verbose
serverless › Invoking "slstryQueue:failed" on service "slstry"
slstry › Running "serverless slstryQueue failed --verbose --stage dev"
Running "serverless" from node_modules
Environment: darwin, node 18.16.1, framework 3.38.0 (local) 3.38.0v (global), plugin 7.2.0, SDK 4.5.1
Docs:        docs.serverless.com
Support:     forum.serverless.com
Bugs:        github.com/serverless/serverless/issues

Error:
Serverless command "slstryQueue failed" not found. Did you mean "slstryQueue:failed"? Run "serverless help" for a list of all available commands.
Error:

Now one might suggest to avoid serverless-compose by executing the command directly within the folder of the specific service. But that is not always possible, because when using serverless-compose your serverless.yml files might have references to shared outputs of other services, and those might cause an execution error like:

...make sure to run commands via Compose so that all parameters can be resolved,

How to Reproduce

serverless-compose.yml

services:
  slstry:
    path: slstry

serverless.yml

service: slstry
frameworkVersion: '3'

provider:
  name: aws
  runtime: nodejs18.x
  region: eu-central-1
  stage: dev

package:
  individually: true

functions:
  tryit:
    handler: index.handler

plugins:
  - serverless-lift

constructs:
  slstryQueue:
    type: queue
    delay: 5
    maxConcurrency: 10
    maxRetries: 2
    worker:
      handler: worker.work
      timeout: 60

Execute command within compose folder: sls "slstryQueue:failed" --service=slstry --verbose

Additional Information

There is a related issue at the serverless-compose repo https://github.com/serverless/compose/issues/186