sladg / nextjs-lambda

Lambda deployments for Nextjs12 & Nextjs13 (standalone). Easy CLI commands to get your standalone Next output to run in AWS Lambda (not @Edge)! Uses CDK in behind and produces code zips importable to Terraform, Serverless, Azure, etc.
MIT License
169 stars 19 forks source link

Figure out passing of env vars into CDK when used as CLI #42

Closed sladg closed 1 year ago

sladg commented 1 year ago

I want to be able to pass environment variables during deployment, at the same time, I don't want to manage CDK myself as that's unnecessary overhead.

We need a convention on how to pass env vars to Lambda, without exposing all env vars as some of them might be private / unnecessary for app run.

sladg commented 1 year ago

Consider .env file. In case .env file is present during build, it will load on start from it. Basically, next build propagates the file into output and we zip it then.

We should consider that .env file is gonna propagate to the final build and into the code.

Next server's priority when resolving env vars (from top):

process.env
.env.$(NODE_ENV).local
.env.local (Not checked when NODE_ENV is test.)
.env.$(NODE_ENV)
.env
sladg commented 1 year ago

Support implemented by https://github.com/sladg/nextjs-lambda/commit/a85085d6968726dcea70def9ded4eb5f378d824a. Version ^3.13.0