compose icon indicating copy to clipboard operation
compose copied to clipboard

[Bug][Compose]

Open darylteo opened this issue 3 years ago • 5 comments

Are you certain it's a bug?

  • [X] Yes, it looks like a bug

Is the issue caused by a plugin?

  • [X] It is not a plugin issue

Are you using the latest v3 release?

  • [X] Yes, I'm using the latest v3 release

Is there an existing issue for this?

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

Issue description

In serverless-compose.yml, param placeholders do not have the same "default value" functionality that is available in the general serverless.yml

https://github.com/darylteo/serverless-compose-bug-repro

In this reproduction repo, I have 2 services - 1 for the api functions, another for Cloudformation StackSet. I need to pass the RoleARN from the schema service over to the api service. This works once running sls deploy but in environments where I cannot do this (developer environments without access keys to remote AWS accounts), it fails to retrieve the ARN as the ARN does not exist yet.

I definitely do not want to make it a requirement for every developer to have to do a deploy before they can perform any changes. So I expected to be able to use the default value template pattern to solve this but it seems that serverless-compose.yml does not support this, and insteads just passes the entire placeholder as is.

As is, I cannot run the service offline using serverless-offline, and I cannot run any offline unit tests, without actually doing a deploy first.

I understand this is a beta, and I may have missed something perhaps. If so please let me know!

Appreciate the package.

Service configuration (serverless.yml) content

serverless-compose.yml

services:
  api:
    path: api
    params:
      # does not work - default value does not pass through
      LambdaRoleArn: ${schema.LambdaRoleArn, ''} # runs but entire placeholder is treated as string
      
      # does not run - The variable "${schema.LambdaRoleArn}" cannot be resolved: the referenced output does not exist. 
      # LambdaRoleArn: ${schema.LambdaRoleArn} 
      

      # here to show that params are working
      PassedParam: "Hello World"


  schema:
    path: schema

Command name and used flags

sls api:invoke local --function hello

Command output

{
    "statusCode": 200,
    "body": "{\n  \"message\": \"Value: ${schema.LambdaRoleArn, ''} and param is Hello World\",\n  \"input\": \"\"\n}"
}

Environment information

> sls --version
Running "serverless" from node_modules
Framework Core: 3.21.0 (local) 3.21.0 (global)
Plugin: 6.2.2
SDK: 4.3.2

darylteo avatar Jul 21 '22 12:07 darylteo

Hey @darylteo - thanks a lot for reporting and sorry you've run into trouble.

That's true, currently default fallback is not supported for Compose params - they work a bit differently than params in individual services. It's definitely something to consider moving forward

cc @mnapoli

I'm going to transfer the issue to compose repo, let's continue discussion there

pgrzesik avatar Jul 21 '22 13:07 pgrzesik

👍 that sounds like a reasonable improvement indeed. @pgrzesik do you think that would be easy to implement?

Also I'm curious:

I understand this is a beta

Compose is no longer in beta, would you be able to tell us what made you think that? Maybe we have some piece of documentation that we need to update.

mnapoli avatar Jul 21 '22 13:07 mnapoli

I think that should be possible to implement without too much effort

pgrzesik avatar Jul 21 '22 15:07 pgrzesik

@mnapoli I'm not... actually sure why I thought it was beta. But I know it was released in April so perhaps I assumed you were still working out the kinks :)

@pgrzesik sounds great. Thank you!

darylteo avatar Jul 23 '22 03:07 darylteo

Hi Team, wondering what happened with this? Is this still something that could be added in the future? 🙏

darylteo avatar Aug 08 '23 01:08 darylteo