Preview only environment group

Hello there,

We currently have a prod environment group which we use across all prod services/workers.

Is there a way to use e.g. a preview environment group for preview deployments only? Can’t quite figure out how to express this in the yaml file, if at all possible.

I know there’s a previewValue field for individual environment variable overrides, but ideally we’d like to have a separate environment variable group used for all preview deployments.


1 Like

Also it seems like I can’t override a variable in my prod env group like follows:

      - key: MY_KEY
        previewValue: ***
      - fromGroup: prod # Attempting to override MY_KEY from here

Sync complains stating value doesn’t exist - doesn’t seem to be too easy to use the preview deployments when relying heavily upon environment groups.

Is there a way to use e.g. a preview environment group for preview deployments only?

You can define the env-based values in your YAML file like this, and then use fromGroup in your services:

- name: global-ev-group
  - key: key-1
    value: prod-value
    previewValue: preview-value

The only issue here would be that the preview environments will each create a copy of the environment group, though env groups are free of charge and get deleted as soon as your PR is closed.

… it seems like I can’t override a variable in my prod env group

Since we are using the YAML format, you will need to remove the - from your fromGroup line.

Hi @mahsa - the problem is that the secret keys are sensitive so I don’t want to store them in the YAML file & commit them.

It’s almost like we need something like the following:

fromGroup: prod
previewFromGroup: staging

Hi @mtford,

What you’re saying definitely makes sense. Right now, there’s no way to have preview-specific configuration for environment variables that isn’t defined directly in the render.yaml. This is something I think would benefit a lot of users who are using preview environments, so I’ve created an internal issue to track this.

In the mean time, the only solutions I can think of are workarounds, like injecting two environment variable groups with different keys (like *_PROD and *_PREVIEW) and conditionally selecting between them in your run script. This obviously isn’t ideal since the production values would still be available in the preview environment services, so depending on your security requirements, this workaround might not be acceptable for you.


I second this request. I wouldn’t really have a need to dive into the render.yaml if there was simply a way to select a different environment for pull request previews.

Guessing this will be a pretty common use case amongst production applications. Currently we have our pull request builds point at a staging api instead of our production api. Trying to get our app deployment working in Preview and this was the first hiccup I ran into. Otherwise I’m really liking the platform!

FYI this was easily configured in Heroku using “Review app config vars”. Not to distract too much from this thread, but it’d also be nice to include a UI control for the render.yaml parameter previewsExpireAfterDays. Not sure if that shows up once I get things working, but was surprised that I didn’t see this in the settings page.

Thanks for your feedback @BradRyan! I’ve made note of it in the internal issue Dan mentioned.

1 Like

+1 to this feature!