It would be really nice to have the following syntax available in
- fromGroup: my-production-env-group
- fromGroupPreviewOverride: my-preview-env-group
This problem has come up several times in the community and is one of the most important parts of a streamlined CI/CD workflow. I would love to see it on the roadmap :)
Problem statement
Currently, there are 3 options for overriding environment variables in preview environments:
Solution 1
Define them in plaintext within
- key: MY_ENV_VAR
value: production-value
previewValue: preview-value
This works for values that can be shared, but is not suitable for private secrets (which is a pretty common use-case)
Solution 2
Define them with
sync: false
fill them in on each PR.
This works, but is extremely time consuming, especially if your env file has 10+ variables to fill in.
Solution 3 (workaround)
Omit environment groups from
altogether, but still reference them in your services. For example:
- fromGroup: my-production-env-group
- fromGroup: my-preview-env-group
From here, you must write additional logic into your application to choose the correct variable based on the environment.
let myVariable;
if (process.env.NODE_ENV === 'development') {
myVariable = process.env.LOCAL_VALUE
if (process.env.NODE_ENV === 'production') {
if (process.env.IS_PULL_REQUEST) {
myVariable = process.env.PREVIEW_VALUE
} else {
myVariable = process.env.PROD_VALUE
In my opinion, this 3rd solution is the best, but still isn't great because it requires you to expose production variables in your preview environment.