Comments (11)
Oh, yeah, if it helps:
.env.development
STAGE=dev
REGION=us-east-1
SOMEVAL=dev val
HELLO_PATH=hello
.env.production
STAGE=prod
REGION=us-east-1
SOMEVAL=prod val
HELLO_PATH=hello_world
from serverless-dotenv-plugin.
Have the same issue, and it's pretty annoying =(
from serverless-dotenv-plugin.
I have the same issue though it does not seem to be related to serverless-offline
. I fail to run serverless deploy
bash output
> serverless deploy
Serverless Warning --------------------------------------
A valid environment variable to satisfy the declaration 'env:COGNITO_USER_POOL_ARN' could not be found.
Serverless Warning --------------------------------------
A valid environment variable to satisfy the declaration 'env:COGNITO_USER_POOL_ARN' could not be found.
Serverless: DOTENV: Loading environment variables:
Serverless: - COGNITO_USER_POOL_ARN
Serverless: - COGNITO_USER_POOL_ID
Serverless: - MONGODB_URI
Serverless: - MONGODB_DATABASE
Serverless: - SENTRY_DSN
config
plugins:
- serverless-dotenv-plugin
- serverless-webpack
- serverless-offline
custom:
webpack:
webpackConfig: ./webpack.config.js
includeModules: true
dotenv:
path: .env-${self:provider.stage}
provider:
name: aws
runtime: nodejs8.10
stage: ${opt:stage, 'dev'}
region: us-east-1
iamRoleStatements:
- Action:
- cognito-idp:AdminGetUser
Resource: ${env:COGNITO_USER_POOL_ARN}
Effect: Allow
from serverless-dotenv-plugin.
It took me a while to figure out why I couldn't load env vars before the provider config, but then it dawned on me that there's no purpose to using hooks in the first place. Just load the env vars in the plugin constructor. Avoid hooks altogether!
A fix is coming soon.
from serverless-dotenv-plugin.
I published a new version. Go ahead and give it another try. Thanks for your help!
from serverless-dotenv-plugin.
@colynb
Still no luck with version 1.2.0, seems that the env file is not found when pointing out the path to the env file dynamically like this:
custom:
dotenv:
path: .env-${self:provider.stage}
also tried
custom:
dotenv:
path: .env-${opt:stage, 'dev'}
it works when setting it statically:
custom:
dotenv:
path: .env-dev
from serverless-dotenv-plugin.
from serverless-dotenv-plugin.
The problem that I mentioned is introduced in the 1.2.0 release. It worked in 1.1.3. Maybe I should have created a new issue.
from serverless-dotenv-plugin.
@andidev I'm afraid that's a chicken and the egg problem. I may have introduced a breaking change. The question is, should the provider config load before the plugin loads the env vars, so that you can use the stage var to determine the path, or do you load env vars first thing so that you can use those in your provider config. I don't think you can have both.
from serverless-dotenv-plugin.
Shouldn't at least the cli options, e.g. ${opt:stage}
, be available before the plugins load? Feels like there should be some way to achieve this. I would love to help but currently I have no time for this though. Thanks anyway for the fast response.
Seems like others got the same problem now after the latest release.
#19
from serverless-dotenv-plugin.
@colynb That update fixed my issue! Thanks a lot.
from serverless-dotenv-plugin.
Related Issues (20)
- Plugin should throw on error.
- Release GitHub action workflow only works if there is no branch protection. HOT 1
- Warn when incompatible options are set
- Automatic env file resolution is in reverse order of precedence HOT 7
- Create npmignore file
- Release (next)
- Consider how new variables engine in serverless could improve or impact this plugin HOT 2
- Document differences between Serverless's .env resolution and this plugin HOT 1
- NODE_ENV and stage collides to each other HOT 3
- System environment variables (wrongly) take higher precedence than the .env file HOT 7
- Cannot have parameterized `stage` and `region` HOT 2
- Serverless Framework v3: integrating with the new design
- Can't read multi line env variable - v2.62.0 HOT 2
- Not loading env file from stage param HOT 3
- basePath not getting resolve HOT 3
- Allow ability to set default environment name. HOT 2
- Feature Request: Add `envFile` to configuration.
- Question : setting env var HOT 1
- Fix links in package.json
- Add a pull request template
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from serverless-dotenv-plugin.