Do variables in ENV groups override regular ENV variables?

Use case:

I would like to use the same YAML file to generate a staging env and a prod env. I would like the following behavior:

  1. I put the ENV group in the YAML file
  2. I put all the relevant ENV variables in the group
  3. I override some ENV variables in the specific services

The staging and the prod env both have the variables from the env group, and the specific variables for each service override the ones in the group.

The documentation really should say how we determine what takes priority on what.

2 Likes

Hi @Trevoke,

I believe this is a great use case for Render’s Preview Environments Preview Environments | Render · Cloud Hosting for Developers. With Preview Environments you are able to override environment variables and use environment groups to propagate sync: false environment variables for those preview environments in a single YAML file.

Hi @tyler Can you please give an example of the use case you mentioned?

Hi Rajanikant,

Are you looking for a specific case or just more details on what is outlined above?

It may be only me, but I didn’t understand the example given on the link, about the environments getting/not getting copied in the preview environment. A detailed example would be super helpful!

Hi there, apologies for the delayed response, maybe I can explain the example a bit more. For certain environment variables you have the option to label them sync: false this allows you to enter a value for those variables when you deploy your main service for the first time. When using preview environments, the environment variables with these labels won’t be automatically copied from the main service to the preview environment. The way you achieve copying those variables to the preview environment is by creating an environment group with the variables that you want copied. That said, there is a known issue with this right now and the recommended way to manage environment variables with preview environments is to create an environment group using the dashboard and then reference that group in your render.yaml using fromGroup: <group name>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.