changing Balena environment variable

Hi there,

We have devices in an application called “in-production” and “in-office”.

I have some code that read the BALENA_APP_NAME environment variable. Based on the application name “in-production” or “in-office”, I want to enable/disable some feature on the device.

I prefer not to test this in the in-production fleet.

I was thinking of changing the BALENA_APP_NAME for some “in-office” devices to see if the “in-production” condition runs fine.

My question is: Can I easily change the Balena environment variable value (in this example BALENA_APP_NAME) without consequences? For example changing the BALENA_APP_NAME, does it sync directly to another application or something or just reset after reboot?

Devices running on the raspberrypi3 (OS image).

Hi robbie,

could you please elaborate on what you mean by changing the value of BALENA_APP_NAME? The variable can not really be set from the outside - it is filled in automatically and it is not possible to define such variable via the dashboard as variables starting with BALENA_ and RESIN_ are reserved. If I understand your question correctly - no, it is not easily possible to change the value without consequences. Even if you managed to somehow achieve that it is not supported and your application should not rely on such behavior.

Is there any particular reason why you need to build the condition around BALENA_APP_NAME rather than a custom variable that switches the modes? The custom variable sounds like a better solution for you - you can set a fleet-wide default (or a generic default in your app if the variable is unset) and override per-device when you need to do testing.