-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
Environment variable in serverless.yml throws "Cannot resolve ..." error #9813
Comments
Hello @tforster 👋 Thanks for reporting, with the new resolver, such definition is not supported. In general, it is discouraged to configure stage behind |
What is "the new resolver"? And is there any documentation about it? Does it affect us in any other ways? I don't understand why we are now discouraging the use of environment variables in serverless.yml. They've been fine for years. While I can switch to Is there an official document on this breaking change? |
Hello again @tforster 👋 In your configuration file you explicitly opt-in to use new resolver via We are not discouraging the use of env variables - quite the contrary, we've been promoting them as a replacement for custom CLI options for example and it is generally a great practice to use them. As for |
Hi @pgrzesik Thanks for the ongoing explanation, much appreciated. Yes, I did add If it's not intended to trigger verbose errors what is it for? Should I remove it? |
Theoretically we can do that. Probably best way would be to require If we agree to that, also then error message will have to be further tuned, to clearly indicate that @tforster old variables resolver didn't have error validation on that, and in such scenarios quite often internals silently worked with not resolved at given point crucial properties as |
Thanks @medikoo - while theoretically, it seems like we could do that, it introduces an additional overhead and adds a bit to the complexity of variable resolution. I would rather avoid introducing such changes, but it's of course up for consideration. |
+1 Our move should probably depend on demand. With strong demand I would do it, otherwise let's not do our logic more complex |
Recognising the incredible effort that everyone already puts into this project, I would offer that an improved description of the resolution process would be extremely valuable. SLS is both powerful and flexible and it is clear to me now that I use and configure my projects differently than others and the resolver attempts to handle all our scenarios. I would love to see a collection of official best-practices snippets for various aspects of SLS. I say official because if it is just a public repo it will be quickly flooded by conflicting patterns because everyone has an opinion. Based on this thread I am considering rearchitecting our project scripts somewhat. They would still use a .env file but I am not sold on .env.dev, .env.stage, etc. Our boilerplate .gitignore includes .env since it contains secrets. But I am concerned about adding additional environment files with inconsistent extensions. To me, that feels as if there is potential to miss something and leak secrets. I am curious, was any consideration given to reversing the naming convention to .dev.env, .stage.env, etc? Thank you @pgrzesik and @medikoo for your responses to this thread. |
@tforster what would that solve exactly? |
Without the .env extension, they are no longer recognised as .env files by the developer's IDE or code editor. It means that a simple |
@tforster that's an interesting suggestion, but I think we'd rather consider dropping support for |
@medikoo I personally would not use |
We will need a bigger discussion on that, as I think many users are used to have different env configs per stage (even though that doesn't seem to be best practice). We can either rename this issue, or create a new one (feel free to open), so feedback is gathered there |
I would say that this issue can be closed as it's not a bug, but behaving by design? |
Yes, that's the case currently, so let me close it. Still if you'd like use to drop support fro |
@tforster due to other requests, we've actually revisited that subject looked into it more deeply, and realized we can provide some sort of compelling solution without introducing either not optimal processing or changes to functionalities. Please track #9880 for that, I believe it should be addressed soon |
@tforster good news! Starting with today's release we will support |
Can you go into detail what this means? I am still struggling with the "configured behind variables which cannot be resolved at this stage" error even after adding the variablesResolutionMode: 20210326. |
@debragail ensure you're relying on latest Framework release. Otherwise provide a reproducible test case (that doesn't involve plugins, and is simplified to minimum) which exposes the issue |
I just updated and my deployment broke, what's the dealio It feels like this is changed for no reason. I saw warnings for a long time but never thought I would have to update... never thought it would happen to me.... |
same as Daniel, still got the error tho |
Do I understand this correctly that also custom plugins with custom variable resolver can't be used for
We wrote custom plugin that reads the microservice version from an external file, with some parsing (version property from node package.json). |
@nicemaker Still, we've proposed a solution that allows to inject into Framework process before the initialization: #9311 and through that, it could be possible |
Ensures that deployment works rather than relying on "invisible" post-merge deployment. Destroys CI stack after run, retrying in case it's in an intermediate state. Unfortunately serverless doesn't support variables in the service name <serverless/serverless#9813>, so we can't have more than one CI environment deployed at any one time.
Ensures that deployment works rather than relying on "invisible" post-merge deployment. Destroys CI stack after run, retrying in case it's in an intermediate state. Unfortunately serverless doesn't support variables in the service name <serverless/serverless#9813>, so we can't have more than one CI environment deployed at any one time. Keep the DynamoDB table only in production.
Ensures that deployment works rather than relying on "invisible" post-merge deployment. Destroys CI stack after run, retrying in case it's in an intermediate state. Unfortunately serverless doesn't support variables in the service name <serverless/serverless#9813>, so we can't have more than one CI environment deployed at any one time. Keep the DynamoDB table only in production.
Ensures that deployment works rather than relying on "invisible" post-merge deployment. Destroys CI stack after run, retrying in case it's in an intermediate state. Unfortunately serverless doesn't support variables in the service name <serverless/serverless#9813>, so we can't have more than one CI environment deployed at any one time. Keep the DynamoDB table only in production.
Ensures that deployment works rather than relying on "invisible" post-merge deployment. Destroys CI stack after run, retrying in case it's in an intermediate state. Unfortunately serverless doesn't support variables in the service name <serverless/serverless#9813>, so we can't have more than one CI environment deployed at any one time. Keep the DynamoDB table only in production.
It should not be the case where a new release cause the app to break in various ways. Why couldn't you guys just deprecate it ? Upgrading serverless is a nightmare. |
@berni-mad what exactly got broken for you? Note all we did in the Framework is we prevented broken configurations to be taken as valid (that created not always visible internal issues, which in many cases produced confusing outcomes) |
Issues with the code:
We were having none of those issues with version 2. Issues with documentation:
Thanks. |
@berni-mad thanks for input
@berni-mad that's definitely not the case. Can you prepare a minimal test case demonstrating what case exactly is not working for you? (ideally if you open a new issue)
This is an issue of a plugin which introduces
Validation schema does not allow CF templates syntax for properties which are not submitted as is to CF template, or play part in internal resolution of other configuration parts. |
Default branch for the examples is
That's indeed a shortcoming of a website. Still all documentation is hosted and versioned in a repository at https://github.com/serverless/serverless/tree/main/docs. |
@medikoo Thanks a lot for your replies! -> I was able to solve all the problems related with environment variables, indeed -> For the other issues, we have a very big serverless project and your observation might indeed be true. The plugin logic gets really entangled with the serverless framework , so some errors might be due to a dependency issue. -> Thanks for the examples. |
Ensures that deployment works rather than relying on "invisible" post-merge deployment. Destroys CI stack after run, retrying in case it's in an intermediate state. Unfortunately serverless doesn't support variables in the service name <serverless/serverless#9813>, so we can't have more than one CI environment deployed at any one time. Keep the DynamoDB table only in production.
#/mydir_py3_11/django_aws_lambda_002/django-aws-lambda/serverless.yaml
#/mydir_py3_11/django_aws_lambda_002/django-aws-lambda/.envl
|
Ensures that deployment works rather than relying on "invisible" post-merge deployment. Destroys CI stack after run, retrying in case it's in an intermediate state. Unfortunately serverless doesn't support variables in the service name <serverless/serverless#9813>, so we can't have more than one CI environment deployed at any one time. Keep the DynamoDB table only in production.
You can remove entries from provider section and pass that as an option while while deploying or offline. See the code snippet below how i achieved it without major changes. provider: custom: Created 3 files for dev, uat and prod.yml and provided --stage option as below sls offline start --stage dev |
The latest version of the serverless framework is no longer working for AWS Lambda deployments and is throwing the following error:
Cannot resolve serverless.yml: “provider.stage” property is not accessible (configured behind variables which cannot be resolved at this stage)
AWS_PROFILE= npx serverless deploy
outputInstalled version
The text was updated successfully, but these errors were encountered: