Skip to content
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

.env.local overrides other .env files #11708

Open
4 tasks done
HaaLeo opened this issue Jan 26, 2023 · 3 comments
Open
4 tasks done

.env.local overrides other .env files #11708

HaaLeo opened this issue Jan 26, 2023 · 3 comments
Labels

Comments

@HaaLeo
Copy link

HaaLeo commented Jan 26, 2023

Are you certain it's a bug?

  • Yes, it looks like a bug

Is the issue caused by a plugin?

  • It is not a plugin issue

Are you using the latest v3 release?

  • Yes, I'm using the latest v3 release

Is there an existing issue for this?

  • I have searched existing issues, it hasn't been reported yet

Issue description

I have a minimal serverless app with two .env files

  • .env.local
    MSG='I am local'
  • .env.dev
    MSG='I am dev'

Now when I package my app and with sls package --package ../../dist/packages/dev/query-api --stage dev --verbose the resources where I reference the env var via ${env:MSG} gets labeled with I am local instead of I am dev.

Service configuration (serverless.yml) content

service: my-service

useDotenv: true # See https://www.serverless.com/framework/docs/environment-variables/

plugins:
  - serverless-webpack
  - serverless-offline
  - serverless-plugin-reducer

package:
  individually: true

provider:
  name: aws
  runtime: nodejs18.x
  region: ${opt:region, 'eu-central-1'}
  stage: ${opt:stage, 'dev'}
  endpointType: REGIONAL
  httpApi:
    cors: true

functions:
  main:
    handler: src/main.handler
    memorySize: 256
    timeout: 29
    environment:
      MSG: ${env:MSG}
    events:
      - httpApi: # ApiGatewayV2
          method: any
          path: /{proxy+}

Command name and used flags

sls package --package ../../dist/packages/dev/query-api --stage dev --verbose

Command output

N/A

Environment information

Framework Core: 3.26.0 (local)
Plugin: 6.2.2
SDK: 4.3.2
@medikoo
Copy link
Contributor

medikoo commented Jan 26, 2023

@HaaLeo report misses service configuration

@HaaLeo
Copy link
Author

HaaLeo commented Feb 14, 2023

@medikoo I updated the description

@HaaLeo HaaLeo removed their assignment Feb 14, 2023
@medikoo
Copy link
Contributor

medikoo commented Feb 20, 2023

@HaaLeo what happens if you do not use serverless-offline plugin? Do you observe same behavior?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants