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

Serverless deploy does not pick up env vars from .env.production, when also defined in .env.defaults #4548

Open
dac09 opened this issue Feb 22, 2022 · 4 comments
Labels

Comments

@dac09
Copy link
Contributor

dac09 commented Feb 22, 2022

Say you have a .env.defaults with DATABASE_URL defined

#.env.defaults file
DATABASE_URL=postgresql://postgres@localhost:5432/deploy-target-serverless

And after running yarn rw deploy sls --first-run, and adding your DATABASE_URL varyour .env.production looks like this:

#.env.production
DATABASE_URL=postgresql://postgres:[email protected]/postgres?connection_limit=1
API_URL=xxx

The deploys graphql lambda will use the DB defined in the defaults file.

Expected behaviour

Env vars should be loaded like:

.env.defaults -> .env -> .env.production, each one overriding anything with the same name

@dac09 dac09 added bug/confirmed We have confirmed this is a bug action/add-to-release labels Feb 22, 2022
@jtoar jtoar added this to Release Feb 22, 2022
@jtoar jtoar moved this to In progress in Release Feb 22, 2022
@jtoar jtoar added this to Triage Feb 22, 2022
@jtoar jtoar moved this to Todo in Triage Feb 22, 2022
@thedavidprice
Copy link
Contributor

@dac09 I just want to make sure you confirmed this behavior on your setup. For me, I'm not sure if the conflict was due to what you describe here or that my local deploys were trying to use Env Var values from the Serverless Dashboard even though I wasn't able to deploy via the CI/CD service.

I resolve my problem by 1) adding Env Vars to the Serverless dashboard apps and 2) using the param syntax in my yaml.

Note: I thought this setup would work in my favor as I'm now creating a GitHub workflow to deploy — not having to manage env var in GitHub would be great, right?!? But the deploy serverless is failing 'cause it can't find the env vars... 🤦‍♂️

@dac09
Copy link
Contributor Author

dac09 commented Feb 22, 2022

Yes @thedavidprice I did confirm this behaviour! I just used your project, but removed the org/app, and since I didn't have your local .serverless cached files or .env.production I think was a legit repro 👍

@jtoar jtoar removed this from Triage Apr 15, 2022
@jtoar jtoar moved this from In progress to Todo in Release Apr 15, 2022
@jtoar jtoar added this to Main May 5, 2022
@jtoar jtoar moved this to Backlog in Main May 5, 2022
@jtoar jtoar removed this from Release May 6, 2022
@thedavidprice
Copy link
Contributor

Update

Confirming this is still a problem, which is exacerbated because we instruct users to create .env.production in the Serverless Deploy Docs. Based on the docs, it's expected 1) you should continue to use .env.production and 2) redwood supports .env.context file naming. It does not.

See also #5785 for an example of the confusion this creates.

Next Steps

We need to determine if we want to support this behavior. At this time, it's a low priority. If someone wants to take it on, we could support the effort.

Update Documentation

A a minimum, we can update the Serverless Deploy docs and remove the .env.production instructions.

cc @jtoar @Josh-Walker-GM

@Yuvraj102
Copy link

Hello, I'd love to progress on this, Pls assign it to me.

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

No branches or pull requests

4 participants