Giter Club home page Giter Club logo

Comments (11)

ds17f avatar ds17f commented on July 27, 2024 1

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.

orels1 avatar orels1 commented on July 27, 2024 1

Have the same issue, and it's pretty annoying =(

from serverless-dotenv-plugin.

andidev avatar andidev commented on July 27, 2024

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.

colynb avatar colynb commented on July 27, 2024

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.

colynb avatar colynb commented on July 27, 2024

I published a new version. Go ahead and give it another try. Thanks for your help!

from serverless-dotenv-plugin.

andidev avatar andidev commented on July 27, 2024

@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.

colynb avatar colynb commented on July 27, 2024

from serverless-dotenv-plugin.

andidev avatar andidev commented on July 27, 2024

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.

colynb avatar colynb commented on July 27, 2024

@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.

andidev avatar andidev commented on July 27, 2024

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.

orels1 avatar orels1 commented on July 27, 2024

@colynb That update fixed my issue! Thanks a lot.

from serverless-dotenv-plugin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.