-
Notifications
You must be signed in to change notification settings - Fork 15
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
Root serverless stage overrides provider.stage in sub-service #154
Comments
Hi, this is intentional that the stage is overridden from the root when using Compose. Could you clarify what you are trying to achieve and what you would expect to happen? |
Before I tried to use compose, I had my provider:
stage: ${file(./serverless-stage.js)} Where the module.exports = async ({ _, resolveVariable }) => {
const stage = await resolveVariable("opt:stage,'dev'");
if (stage == "dev") {
const user = process.env.USERNAME || process.env.USER || "undefined_user";
return user.replace(/[^a-zA-Z0-9_\-]/g, "").toLowerCase();
}
return stage;
}; The idea is to automatically detect what stage was requested (default to In any case, when I tried using this in a sub-service of serverless compose, it stopped working. I added some printouts to debug it and it seems that while the JS file is still being called, and it does return the correct stage (the username), the Can you explain the reasoning behind having compose override the provider stage? Shouldn't compose honor the specific settings of each sub-service? |
Related: I'd like Compose to use a new "dev2" stage as the default stage (instead of "dev"). I thought updating Is there a way to set the default stage for Compose @mnapoli? |
Hi both, I see what you mean. Unfortunately for now the default stage is hardcoded to Line 108 in d145ecc
Full transparency, I am no longer at Serverless Inc. and no longer a maintainer on this repository, so I cannot really help with new features. Sorry about that! |
Oh no! I'll miss interacting with you here. Great work on Compose, it has been a huge boost for our team. And thanks for confirming that the default stage is hardcoded. We'll just get in the habit of always specifying the Is there a new primary maintainer on this repository that we should get in contact with for future requests? |
Thank you :) Unfortunately I don't know. |
Are you certain it's a bug?
Are you using the latest version?
Is there an existing issue for this?
Issue description
If the sub-project
serverless.yml
has an explicitprovider.stage
setting, then:serverless
from the sub-project directory uses that stage, regardless of the stage command line optionserverless
from the root whereserverless-compose.yml
exists uses whatever stage was provided in the command line, ignoring the setting in the sub-projectserverless.yml
file.Explicitly specifying provider.stage is useful when we want to deduce the stage based on various inputs. For example, we use it to automatically create a stage per developer when working locally. This works nicely when serverless is executed in the sub-project, but not in serverless compose. Since we can't include the same stage-deduction logic in
serverless-compose.yml
, there is also no workaround.This can be verified by specifying a provider.stage that is different from "dev" in
serverless.yml
and then runningserverless <service>:print
orserverless <service>:package
in the root.Service configuration (serverless-compose.yml) content
N/A
Command name and used flags
serverless :print
Command output
The text was updated successfully, but these errors were encountered: