-
Notifications
You must be signed in to change notification settings - Fork 3
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
Values are no longer properly resolving based on input stage #17
Comments
@cnnranderson Thanks for reporting the issue. I'll dig into it and see if I can find a resolution |
Hey @chris-feist , any update on the topic? |
@whisller I looked into it and it's going to take a serious effort to make this compatible with the latest serverless. Serverless now supports dotenv type environment variable files, which is a good workaround in the meantime. The major downside is that it doesn't support merging of those files. Here are the docs: https://www.serverless.com/framework/docs/environment-variables/ |
@chris-feist thank you for the update! |
Could you provide an example of the workaround to upgrade a project that has X stages and X variables files please? |
You have to use the stage-specific # .env - This is the default when no staging .env file specified
DATABASE_NAME=dev-db
DATABASE_SERVICE=mongodb # .env.prod - This is the prod stage .env file
DATABASE_NAME=prod-db
# Note that we have to define all env vars since merging files/values is not supported by the serverless implementation
DATABASE_SERVICE=mongodb Then you can reference the environment variables in any of your configuration files (serverless.yml, variables.yml, etc) using environment:
DATABASE_NAME: ${env:DATABASE_NAME} Any environment variables for the process will override the You can still use a separate variables file like my repo sets up automatically, but you would have to reference the environment variables: # serverless.yml
custom: ${file(./variables.yml)} # variables.yml
dbConnection: "https://${env:DATABASE_SERVICE}.com/${env:DATABASE_NAME}" |
It looks like it may be easier to reintroduce compatibility once the serverless extensions work is finished 🤞 |
There were apparently breaking changes in the way Serverless loads environment variables recently and this plugin no longer properly resolves the values expected for the stage.
See a similar thread here from serverless-dotenv plugin:
https://www.npmjs.com/package/serverless-dotenv-plugin
serverless>=3.0.0 introduces changes that significantly impacts this plugin. See the discussion thread or the FAQ below for details on the impact of how env vars are loaded with serverless>=2.26.0 and serverless>=3.0.0.
The text was updated successfully, but these errors were encountered: